Re: [Valgrind-users] Recursive `who-points-at`
On 2/26/2023 4:29 AM, Philippe Waroquiers wrote: On Fri, 2023-02-24 at 10:42 -0700, User 10482 wrote: Dear All, I am looking to fix dangling pointer issue and was pleasantly surprised to find the `who-points-at` functionality in valgrind which tells the stack variable names (assuming --read-var-info=yes) and any addresses on heap with holding the searched address. [link](https://valgrind.org/docs/manual/mc-manual.html#mc-manual.monitor-commands) The tool is just splendid but I wish there was some way to do it recursively on the heap addresses (i.e who-points-at on the output of previous who-points-at) until we get the stack variable names holding the dangling pointers; something like how core-analyzer's `ref` command does. [link]( https://core-analyzer.sourceforge.net/index_files/Page600.html). Yes, a recursive who-points-at would be a nice thing to have. I have added this on my list of things to do (one day, whenever I have time :(). On a side note, is there a way to know which variable/type a heap address points to? That will be helpful too. The only information valgrind has about a (live) heap block is the stack trace that allocated it. Valgrind does not know the type of the object for which this memory was allocated. Unclear to me how that can be implemented (at least without support of the compiler). I wonder if gdb (or whatever debugger) info about the types of the pointers would allow providing useful information? Presumably that could be had if the executable had the information kept with it and not stripped. Best - Eliot Moss ___ Valgrind-users mailing list Valgrind-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/valgrind-users
Re: [Valgrind-users] Recursive `who-points-at`
On Fri, 2023-02-24 at 10:42 -0700, User 10482 wrote: > Dear All, > > I am looking to fix dangling pointer issue and was pleasantly surprised to > find the > `who-points-at` functionality in valgrind which tells the stack variable > names (assuming > --read-var-info=yes) and any addresses on heap with holding the searched > address. > [link](https://valgrind.org/docs/manual/mc-manual.html#mc-manual.monitor-commands) > > The tool is just splendid but I wish there was some way to do it recursively > on the heap > addresses (i.e who-points-at on the output of previous who-points-at) until > we get the > stack variable names holding the dangling pointers; something like how > core-analyzer's > `ref` command does. [link]( > https://core-analyzer.sourceforge.net/index_files/Page600.html). Yes, a recursive who-points-at would be a nice thing to have. I have added this on my list of things to do (one day, whenever I have time :(). > > On a side note, is there a way to know which variable/type a heap address > points to? > That will be helpful too. The only information valgrind has about a (live) heap block is the stack trace that allocated it. Valgrind does not know the type of the object for which this memory was allocated. Unclear to me how that can be implemented (at least without support of the compiler). > > Thanks and have a good day! > > best, > Abhi > ___ > Valgrind-users mailing list > Valgrind-users@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/valgrind-users ___ Valgrind-users mailing list Valgrind-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/valgrind-users
[Valgrind-users] Recursive `who-points-at`
Dear All, I am looking to fix dangling pointer issue and was pleasantly surprised to find the `who-points-at` functionality in valgrind which tells the stack variable names (assuming --read-var-info=yes) and any addresses on heap with holding the searched address. [link]( https://valgrind.org/docs/manual/mc-manual.html#mc-manual.monitor-commands) The tool is just splendid but I wish there was some way to do it recursively on the heap addresses (i.e who-points-at on the output of previous who-points-at) until we get the stack variable names holding the dangling pointers; something like how core-analyzer's `ref` command does. [link](https://core-analyzer.sourceforge.net/index_files/Page600.html). On a side note, is there a way to know which variable/type a heap address points to? That will be helpful too. Thanks and have a good day! best, Abhi ___ Valgrind-users mailing list Valgrind-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/valgrind-users