Closed renzhengeek closed 10 years ago
In newer versions of Granary, visit_app/host_instructions
are not static methods. Just remove the static
from them in the instrument.h
header.
Newer versions of Granary also don't expose thread_state_handle
as an argument to visit_app/host_instructions
, so you can remove that argument.
I suggest trying to compare the structure of the policy classes in the leak_detector
client to those in the null
client.
Also remove uses of leak_detector::
, i.e. turn something like leak_detector::visit_host_instructions
into visit_host_instructions
.
Okay, thanks ;)
Another compiling error occurs:
CXX [GR-CLIENT] clients/watchpoints/clients/leak_detector/descriptor.cc
In file included from /home/renzhen/granary/granary/globals.h:528:0,
from /home/renzhen/granary/granary/client.h:12,
from /home/renzhen/granary/clients/watchpoints/instrument.h:12,
from clients/watchpoints/clients/leak_detector/descriptor.cc:9:
/home/renzhen/granary/granary/bump_allocator.h: In instantiation of ‘struct granary::bump_pointer_allocator<client::wp::descriptor_allocator_config>’:
/home/renzhen/granary/granary/utils.h:165:47: required from ‘struct granary::static_data<granary::bump_pointer_allocator<client::wp::descriptor_allocator_config> >’
clients/watchpoints/clients/leak_detector/descriptor.cc:67:7: required from here
/home/renzhen/granary/granary/bump_allocator.h:83:47: error: ‘SHARE_DEAD_SLABS’ is not a member of ‘client::wp::descriptor_allocator_config’
SHARE_DEAD_SLABS = !IS_SHARED && !!Config::SHARE_DEAD_SLABS,
^
make: *** [/home/renzhen/granary/bin/clients/watchpoints/clients/leak_detector/descriptor.o] Error 1
some questions:
bump_pointer_allocator
? do we use it for code cache management?
2.The error seems occuring cause of wrong uage of Config
,so Config
is a interface for user?
and how to use it to fix the error?Thanks ;)
The bump_pointer_allocator
is a simple allocate-only allocator. I.e. objects allocated cannot be freed, unless you free only the most recently allocated object, or all of the objects. The way it works is that it is backed by large slabs of memory, and allocation happens by "bumping" a pointer (incrementing it).
Bump pointer allocators are configured with various parameters. I suggest looking at current uses of bump pointer allocators (e.g. in https://github.com/Granary/granary/blob/master/granary/state.h#L80), what they use for configurations, and what is documented here (https://github.com/Granary/granary/blob/master/granary/bump_allocator.h#L49) and that should put you in a position to solve the problem ;-)
I think the issue is https://github.com/Granary/granary/blob/release/clients/watchpoints/clients/leak_detector/thread.cc#L15. I suggest getting rid of this line, and then solve the resulting compiler errors by appending types:: to the erroneous type/function names. For example:
struct task_struct ---> types::task_struct struct thread_info ---> types::thread_info kmalloc ---> types::kmalloc
On 8 April 2014 04:37, Ren Zhen notifications@github.com wrote:
Thanks ;) I solve this by adding SHARE_DEAD_SLABS = true into struct descriptor_allocator_config.
But more tirvial errors occur like the following:
CXX [GR-CLIENT] clients/watchpoints/clients/leak_detector/thread.cc clients/watchpoints/clients/leak_detector/thread.cc:34:9: error: reference to 'uint64_t' is ambiguous uint64_t thread_state; ^ In file included from /usr/lib/gcc/x86_64-linux-gnu/4.8/include/stdint.h:11:0, from /home/renzhen/granary/granary/globals.h:16, from /home/renzhen/granary/granary/list.h:14, from clients/watchpoints/clients/leak_detector/thread.cc:9: /usr/lib/gcc/x86_64-linux-gnu/4.8/include/stdint-gcc.h:55:25: note: candidates are: typedef long unsigned int uint64_t typedef UINT64_TYPE uint64_t; ^ In file included from /home/renzhen/granary/granary/types.h:50:0, from clients/watchpoints/clients/leak_detector/thread.cc:10: /home/renzhen/granary/granary/gen/kernel_types.h:3044:15: note: typedef granary::types::__u64 granary::types::uint64_t typedef __u64 uint64_t ; ^ clients/watchpoints/clients/leak_detector/thread.cc:34:9: error: 'uint64_t' does not name a type uint64_t thread_state; ^ clients/watchpoints/clients/leak_detector/thread.cc:37:24: error: 'locked_hash_table' was not declared in this scope static static_data<locked_hash_table<app_pc, app_pc>> object_scan_list; ^ clients/watchpoints/clients/leak_detector/thread.cc:37:50: error: wrong number of template arguments (2, should be 1) static static_data<locked_hash_table<app_pc, app_pc>> object_scan_list; ^ In file included from /home/renzhen/granary/granary/globals.h:520:0, from /home/renzhen/granary/granary/list.h:14, from clients/watchpoints/clients/leak_detector/thread.cc:9: /home/renzhen/granary/granary/utils.h:164:12: error: provided for 'template
struct granary::static_data' struct static_data { ^ clients/watchpoints/clients/leak_detector/thread.cc:37:56: error: expected unqualified-id before '>' token static static_data<locked_hash_table<app_pc, app_pc>> object_scan_list; ^ clients/watchpoints/clients/leak_detector/thread.cc:38:24: error: 'hash_set' was not declared in this scope static static_data<hash_set > watchpoint_collect_list; Could you give some hints to solve this problem? All the best for you:)
Reply to this email directly or view it on GitHubhttps://github.com/Granary/granary/issues/25#issuecomment-39824138 .
Thanks ;)
There is still compiler errors;
clients/watchpoints/clients/leak_detector/thread.cc:37:24: error: ‘locked_hash_table’ was not declared in this scope
static static_data<locked_hash_table<app_pc, app_pc>> object_scan_list;
^
clients/watchpoints/clients/leak_detector/thread.cc:37:50: error: wrong number of template arguments (2, should be 1)
static static_data<locked_hash_table<app_pc, app_pc>> object_scan_list;
^
In file included from /home/renzhen/granary/granary/globals.h:520:0,
from /home/renzhen/granary/granary/list.h:14,
from clients/watchpoints/clients/leak_detector/thread.cc:9:
/home/renzhen/granary/granary/utils.h:164:12: error: provided for ‘template<class T> struct granary::static_data’
struct static_data {
^
clients/watchpoints/clients/leak_detector/thread.cc:37:56: error: expected unqualified-id before ‘>’ token
static static_data<locked_hash_table<app_pc, app_pc>> object_scan_list;
Looks like you might be missing an #include
for wherever the locked_hash_table
data structure is defined.
When you see an error like 'X' was not declared in this scope
, then search the code base for X
, and if it exists, make sure that you're including the header file in which X
is declared/defined.
In this particular case, it looks like the file that you want is https://github.com/Granary/granary/blob/master/granary/hash_table.h#L373
I try appending granary::
to locked_hash_table,then there is still compiler errors like:
CXX [GR-CLIENT] clients/watchpoints/clients/leak_detector/instrument.cc
CXX [GR-CLIENT] clients/watchpoints/clients/leak_detector/descriptor.cc
CXX [GR-CLIENT] clients/watchpoints/clients/leak_detector/thread.cc
clients/watchpoints/clients/leak_detector/thread.cc:36:24: error: ‘locked_hash_table’ is not a member of ‘granary’
static static_data<granary::locked_hash_table<app_pc, app_pc>> object_scan_list;
^
clients/watchpoints/clients/leak_detector/thread.cc:36:24: error: ‘locked_hash_table’ is not a member of ‘granary’
clients/watchpoints/clients/leak_detector/thread.cc:36:59: error: wrong number of template arguments (2, should be 1)
static static_data<granary::locked_hash_table<app_pc, app_pc>> object_scan_list;
locked_hash_table
is in the namespace granary
:https://github.com/Granary/granary/blob/release/granary/hash_table.h#L378
Okay, thanks.
there is a another make error like this:
AS [M] /home/renzhen/granary/bin/./granary/kernel/hotpatch.o
AS [M] /home/renzhen/granary/bin/./granary/kernel/state.o
AS [M] /home/renzhen/granary/bin/./granary/kernel/interrupt.o
AS [M] /home/renzhen/granary/bin/./granary/x86/init.o
make[2]: *** No rule to make target `/home/renzhen/granary/bin/clients/watchpoints/clients/leak_detector/kernel/leakpolicy_scan.o', needed by `/home/renzhen/granary/bin/granary.o'. Stop.
make[1]: *** [_module_/home/renzhen/granary/bin] Error 2
make[1]: Leaving directory `/home/renzhen/linux-3.8'
make: *** [all] Error 2
Do I miss something in Makefile or else?
Here are leak detector client relatives in my current makefile:
ifeq ($(GR_CLIENT),leak_detector)
GR_CXX_FLAGS += -DCLIENT_WATCHPOINT_LEAK
GR_WP_INCLUDE_DEFAULT = 1
GR_OBJS += $(BIN_DIR)/clients/watchpoints/clients/leak_detector/access_descriptor.o
GR_OBJS += $(BIN_DIR)/clients/watchpoints/clients/leak_detector/instrument.o
GR_OBJS += $(BIN_DIR)/clients/watchpoints/clients/leak_detector/descriptor.o
GR_OBJS += $(BIN_DIR)/clients/watchpoints/clients/leak_detector/thread.o
ifeq ($(KERNEL),1)
GR_MOD_OBJS += clients/watchpoints/clients/leak_detector/kernel/leakpolicy_scan.o
else
GR_OBJS += $(BIN_DIR)/clients/watchpoints/user/posix/signal.o
endif
endif
solved by adding GR_MOD_OBJS
here:
787 # Compile granary
788 all: $(GR_PGO_TARGET) $(GR_OBJS) $(GR_MOD_OBJS)
789 @$(GR_MAKE)
790 @echo " [.] Granary has been built."
but another error occurs like:
CXX [GR] /home/renzhen/granary/granary/kernel/state.cc
CXX [GR] /home/renzhen/granary/granary/kernel/interrupt.cc
AS [GR] granary/x86/init.asm
cc -c -o clients/watchpoints/clients/leak_detector/kernel/leakpolicy_scan.o clients/watchpoints/clients/leak_detector/kernel/leakpolicy_scan.c
clients/watchpoints/clients/leak_detector/kernel/leakpolicy_scan.c:9:26: fatal error: linux/module.h: No such file or directory
#include <linux/module.h>
^
compilation terminated.
make: *** [clients/watchpoints/clients/leak_detector/kernel/leakpolicy_scan.o] Error 1
Try adding the following line to here: https://github.com/Granary/granary/blob/release/Makefile#L521
GR_MAKE += cp $(addprefix $(SOURCE_DIR)/,$(GR_MOD_OBJS:.o=.c)) $(BIN_DIR)/ ;
Not sure if that will actually work. What I think needs to be done is that the source files associated with the GR_MOD_OBJS
need to be copied into the same relative location, but within the bin
(BIN_DIR
) dir.
I do the following:
GR_MAKE += cp $(SOURCE_DIR)/Makefile $(BIN_DIR)/Makefile ;
GR_MAKE += cp $(addprefix $(SOURCE_DIR)/,$(GR_MOD_OBJS:.o=.c)) $(BIN_DIR)/ ;
GR_MAKE += make -C $(KERNEL_DIR) M=$(BIN_DIR) GR_KBUILD_SOURCE_DIR=$(SOURCE_DIR) modules
eroro is the following:
AS [M] /home/renzhen/granary/bin/./granary/kernel/interrupt.o
AS [M] /home/renzhen/granary/bin/./granary/x86/init.o
make[2]: *** No rule to make target `/home/renzhen/granary/bin/clients/watchpoints/clients/leak_detector/kernel/leakpolicy_scan.o', needed by `/home/renzhen/granary/bin/granary.o'. Stop.
make[1]: *** [_module_/home/renzhen/granary/bin] Error 2
make[1]: Leaving directory `/home/renzhen/linux-3.8'
make: *** [all] Error 2
And I see it actually copy leakpolicy_scan.c into ${BIN_DIR}.
Does /home/renzhen/granary/bin/clients/watchpoints/clients/leak_detector/kernel/leakpolicy_scan.c
exist? (in that exact location)
If it doesn't, then try manually copying it there, then re-building but without doing a make clean
.
solved by modify the following:
GR_MOD_OBJS += ${BIN_DIR}/leakpolicy_scan.o
AND
GR_MAKE += cp clients/watchpoints/clients/leak_detector/kernel/leakpolicy_scan.c $(BIN_DIR)/ ;
Hi all, I want to make
leak detector
work for currentgranary
. So,I start trying this step: 1.git checkout origin/release
in original git repo of granary; 2.git checkout -b leek_detector
in another experimental repo of granary; 3.cp -r path-to-orgin/client/watchpoint/cllient/leak_detector path-to-exp/client/watchpoint/client
; 4.Add in leak-detector relatives in makefile according to make file in origin/release brantch.5.make with leak_detector specified. 6.comping error occurs like the following:
I almostly know what is the reason,i.e.,using class non-static function member through
::
.code is here https://github.com/Granary/granary/blob/release/clients/watchpoints/clients/leak_detector/instrument.cc#L207 and https://github.com/Granary/granary/blob/release/clients/watchpoints/clients/leak_detector/instrument.cc#L230.I try to make those functions static, but incur more errors like the following:
Please give some advice about How to handle it? Thanks!