You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -680,6 +682,90 @@ One can perform manual symbolication of a crash log or an executable using LLDB
680
682
without running the actual executable. For a detailed guide on how to do this,
681
683
see: https://lldb.llvm.org/symbolication.html.
682
684
685
+
## Viewing allocation history, references, and page-level info
686
+
687
+
The `malloc_history` tool (macOS only) shows the history of `malloc` and `free`
688
+
calls for a particular pointer. To enable malloc_history, you must run the
689
+
target process with the environment variable MallocStackLogging=1. Then you can
690
+
see the allocation history of any pointer:
691
+
692
+
malloc_history YourProcessName 0x12345678
693
+
694
+
By default, this will show a compact call stack representation for each event
695
+
that puts everything on a single line. For a more readable but larger
696
+
representation, pass -callTree.
697
+
698
+
This works even when you have the process paused in the debugger!
699
+
700
+
The `leaks` tool (macOS only) can do more than just find leaks. You can use its
701
+
pointer tracing engine to show you where a particular block is referenced:
702
+
703
+
leaks YourProcessName --trace=0x12345678
704
+
705
+
Like malloc_history, this works even when you're in the middle of debugging the
706
+
process.
707
+
708
+
Sometimes you just want to know some basic info about the region of memory an
709
+
address is in. The `memory region` lldb command will print out basic info about
710
+
the region containing a pointer, such as its permissions and whether it's stack,
711
+
heap, or a loaded image.
712
+
713
+
lldb comes with a heap script that offers powerful tools to search for pointers:
714
+
715
+
(lldb) p (id)[NSApplication sharedApplication]
716
+
(id) $0 = 0x00007fc50f904ba0
717
+
(lldb) script import lldb.macosx.heap
718
+
"crashlog" and "save_crashlog" command installed, use the "--help" option for detailed help
719
+
"malloc_info", "ptr_refs", "cstr_refs", "find_variable", and "objc_refs" commands have been installed, use the "--help" options on these commands for detailed help.
0 commit comments