|
From: E. G. P. B. <p....@es...> - 2016-07-07 13:16:00
|
I'm using callgrind to analyse a c++ program (roofit) which builds a large tree of many interdependent objects of a few classes. Ideally, I would like to track not only the function calls, but also from (and to) which object they are called, so for instance including the address of the passed `this` pointer. Is such a thing possible and/or has it been tried before? And if not, would it be difficult to implement? The alternative would be to build some kind of accounting system into the base classes in my code itself, but if it's easy in valgrind, that would be far preferable, since others can then also use it and I wouldn't have to mess up my own code :) Without having any knowledge of the valgrind source, I would imagine that it could be implemented similarly or as a generalization of the seperate-callers options. Cheers, Patrick |
|
From: Jim C. <jim...@gm...> - 2016-07-07 14:46:35
|
On Thu, Jul 7, 2016 at 8:59 AM, E. G. Patrick Bos <p....@es...> wrote: > I'm using callgrind to analyse a c++ program (roofit) which builds a > large tree of many interdependent objects of a few classes. Ideally, I > would like to track not only the function calls, but also from (and to) > which object they are called, so for instance including the address of > the passed `this` pointer. > > Is such a thing possible and/or has it been tried before? And if not, > would it be difficult to implement? > > take a look at http://rr-project.org/ with it, you can record a run of your program then play it back, deterministically, in gdb. Once you identify the object addresses giving you trouble, you can set watchpoints on them, replay, and catch the origins of the eventual segfault I havent used it in earnest yet, but its at the top of my must-learn-tools list. Id love to see valgrind running one of these recorded sessions, it would yield a tremendous amount of info for use in further gdb replay-sessions |
|
From: Josef W. <Jos...@gm...> - 2016-07-29 08:41:50
|
Am 07.07.2016 um 14:59 schrieb E. G. Patrick Bos: > I'm using callgrind to analyse a c++ program (roofit) which builds a > large tree of many interdependent objects of a few classes. Ideally, I > would like to track not only the function calls, but also from (and to) > which object they are called, so for instance including the address of > the passed `this` pointer. > > Is such a thing possible and/or has it been tried before? And if not, > would it be difficult to implement? Not really. When a new function is called, you can make up a new fn_node struct whose name can embed the address of the 'this' pointer. However, you would get a separate function called for every object. Not sure this scales well. Quite some time ago I had a patch doing similar stuff, but looking up the stack or registers for parameter values depends on the calling convention/ABI which is architecture/OS specific. I only did this for amd64, and it was working nice, but it never went in. I can search for the patch and send it to you. Josef > The alternative would be to build some kind of accounting system into > the base classes in my code itself, but if it's easy in valgrind, that > would be far preferable, since others can then also use it and I > wouldn't have to mess up my own code :) > > Without having any knowledge of the valgrind source, I would imagine > that it could be implemented similarly or as a generalization of the > seperate-callers options. > > Cheers, > Patrick > > ------------------------------------------------------------------------------ > Attend Shape: An AT&T Tech Expo July 15-16. Meet us at AT&T Park in San > Francisco, CA to explore cutting-edge tech and listen to tech luminaries > present their vision of the future. This family event has something for > everyone, including kids. Get more information and register today. > http://sdm.link/attshape > _______________________________________________ > Valgrind-users mailing list > Val...@li... > https://lists.sourceforge.net/lists/listinfo/valgrind-users > |
|
From: Patrick B. <p....@es...> - 2016-07-29 12:36:11
|
Op 29 jul. 2016, om 10:41 heeft Josef Weidendorfer <Jos...@gm...> het volgende geschreven: > Am 07.07.2016 um 14:59 schrieb E. G. Patrick Bos: >> I'm using callgrind to analyse a c++ program (roofit) which builds a >> large tree of many interdependent objects of a few classes. Ideally, I >> would like to track not only the function calls, but also from (and to) >> which object they are called, so for instance including the address of >> the passed `this` pointer. >> >> Is such a thing possible and/or has it been tried before? And if not, >> would it be difficult to implement? > > Not really. > > When a new function is called, you can make up a new fn_node struct > whose name can embed the address of the 'this' pointer. However, you > would get a separate function called for every object. Not sure this > scales well. > > Quite some time ago I had a patch doing similar stuff, but looking > up the stack or registers for parameter values depends on the calling > convention/ABI which is architecture/OS specific. I only did this for > amd64, and it was working nice, but it never went in. > > I can search for the patch and send it to you. If it's not too much trouble, that would be wonderful! Looking forward to receiving it. I'm not too concerned about scaling, so anything you have would be great. Cheers, Patrick > > Josef > > >> The alternative would be to build some kind of accounting system into >> the base classes in my code itself, but if it's easy in valgrind, that >> would be far preferable, since others can then also use it and I >> wouldn't have to mess up my own code :) >> >> Without having any knowledge of the valgrind source, I would imagine >> that it could be implemented similarly or as a generalization of the >> seperate-callers options. >> >> Cheers, >> Patrick >> >> ------------------------------------------------------------------------------ >> Attend Shape: An AT&T Tech Expo July 15-16. Meet us at AT&T Park in San >> Francisco, CA to explore cutting-edge tech and listen to tech luminaries >> present their vision of the future. This family event has something for >> everyone, including kids. Get more information and register today. >> http://sdm.link/attshape >> _______________________________________________ >> Valgrind-users mailing list >> Val...@li... >> https://lists.sourceforge.net/lists/listinfo/valgrind-users >> > > ------------------------------------------------------------------------------ > _______________________________________________ > Valgrind-users mailing list > Val...@li... > https://lists.sourceforge.net/lists/listinfo/valgrind-users |
|
From: Josef W. <Jos...@gm...> - 2016-08-02 10:12:57
Attachments:
seppar.patch
|
Am 29.07.2016 um 13:03 schrieb Patrick Bos:
>> I can search for the patch and send it to you.
>
> If it's not too much trouble, that would be wonderful! Looking forward to receiving it. I'm not too concerned about scaling, so anything you have would be great.
Attached. It should apply to current SVN version (probably also last VG
release).
Note that this patch only uses "Int v = sp[sep->parnum];" (search for it
in the patch)
to access the parnum'th (4-byte) integer parameter of a function, with
sp being the
stack pointer at function entry.
This only works with x86 (32bit). Look up the C ABI calling conventions
to see how to
get at parameters for amd64. amd64 uses registers to pass 1st 6 integer
values.
Register values can be found in the architecture state struct
"ThreadArchState arch",
which can be accessed via "VG_(threads)[tid].arch" in tool functions,
tid is the
current thread ID. For example, for amd64 and register RDI, which holds
the first
integer parameter (I would assume this to map to the "this" pointer with
C++), this
should be
VG_(threads)[tid].arch.vex.guest_RDI
This should make it very easy to accomplish what you want.
Cheers,
Josef
|