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