[DynInst_API:] Variable size and frame pointers


Date: Mon, 18 Aug 2014 10:39:56 +0200
From: Fabian Mager <fabian.mager@xxxxxxxxxxxxxx>
Subject: [DynInst_API:] Variable size and frame pointers
Hello all,

I have two questions. Therefore, I uploaded a small mutatee program (http://pastebin.com/1wsuSRmE) and the respective mutator program (http://pastebin.com/KyXUC9mm). The output is the following:

> clang -Wall -g -O0 struct.c -o struct
> clang++ -Wall -g -O0 -std=c++11 procapi.cpp -I... -L... -lpcontrol -lstackwalk -lsymtabAPI -o procapi
> ./procapi

stack from bottom to top:
ÂÂÂ fooÂÂÂ FP: 140736267700336ÂÂÂ SP: 140736267700312
ÂÂÂ mainÂÂÂ FP: 140736267700336ÂÂÂ SP: 140736267700320
ÂÂÂ __libc_start_mainÂÂÂ FP: 0ÂÂÂ SP: 140736267700352
ÂÂÂ _startÂÂÂ FP: 0ÂÂÂ SP: 140736267700544

parameters:
ÂÂÂ s: s_t -- 8 Bytes
ÂÂÂ Â--> Setting size to 0
ÂÂÂ s: s_t -- 16 Bytes

greetings from foo!

Variable s of type struct s_t has a size of 16 Bytes on my system. I don't understand why getSize() returns 8 Bytes on the first attempt and after calling setSize(0), it returns the correct 16 Bytes. The sizes vary a bit when using gcc instead of clang but they are still not equal.

The second question focuses on the frame pointers (FP). foo and main have the same FP but that should not be the case and causes troubles when I later on try to get the actual parameter values with getLocalVariableValue(). I assume the reason for that is the way I set the breakpoint (process->addBreakpoint(f_foo->getOffset(), breakpoint)). How do I set the breakpoint to the beginning of the function call?
[← Prev in Thread] Current Thread [Next in Thread→]