Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

LLDB: Show all objects with a pointer to an object in memory

So, at a breakpoint, I have a random object instance. I want to figure out which objects have a pointer to this object. Is there a way to see this in the debugger console? Maybe something that shows me all the objects that have a retain on the object?

Example: I have a NSViewController instance and I want to see all the other objects that hold a pointer this view controller instance. This would be helpful because it would allow me to see the view controller hierarchy that is encapsulating my instance.

Just a crazy thought I had that would really help at times.

like image 527
Jesse Bunch Avatar asked Jun 03 '13 01:06

Jesse Bunch


People also ask

What is LLDB command?

lldb is a next generation, high-performance debugger. It is built as a set of reusable components which highly leverage existing libraries in the larger LLVM Project, such as the Clang expression parser and LLVM disassembler.

What does LLDB stand for?

LLDB (low-level debugger) is part of LLVM The LLVM compiler (low level virtual machine) creates programming languages. LLDB is Apple's “from the ground up” replacement for GDB. The LLDB debugger is analogous to GDB: (The GNU Project Debugger).

Does LLDB have Tui?

You can also expand the regsiters by register class: I'd like to know how to resize the various windows. If you resize the terminal, the size of the stack view pane seems to remain fixed, so the symbol names always end up truncated.

How do you set a breakpoint in LLDB?

In lldb you can set breakpoints by typing either break or b followed by information on where you want the program to pause. After the b command, you can put either: a function name (e.g., b my_subroutine ) a line number (e.g., b 12 )


1 Answers

In lldb, use command script import lldb.macosx.heap to install some memory-searching functions. The ptr_refs command should be able to do what you want; use ptr_refs --help to learn more.

like image 131
Greg Parker Avatar answered Sep 18 '22 13:09

Greg Parker