[Lldb-commits] [PATCH] [lldb] ASan malloc/free history threads

Kuba Brecka kuba.brecka at gmail.com
Fri Jul 18 21:32:26 PDT 2014


Hi,
I'm sending a patch that is a first take on implementing the ASan debugging facilities into LLDB, namely retrieving malloc/free recorded stack traces for a given address. This has been somewhat discussed in http://lists.cs.uiuc.edu/pipermail/lldb-dev/2014-July/004491.html. What this patch does is:

* Creates a new plugin type, MemoryHistory, and its implementation, MemoryHistoryASan. The reason for a plugin is that we might want to reuse it for other sources of recorded stack frames, like malloc_history (Darwin only).

* The plugin can only be instantiated for a process that has the ASan runtime library loaded. Right now, I'm detecting the presence of the library by checking that a specific symbol exists. Is there a better way?

* Extended the "memory" command and added "memory history [address]" which will call the plugin's GetHistoryThreads function and print out the HistoryThread objects.

* A test case that uses a simple ASanified binary and issues the "memory history" command, validates that the returned stack trace contains the correct line number of where a memory was allocated and freed. The test case requires your compiler to understand -fsanitize=address and basically it should be a very recently build clang (so it has the debugging API from this week).

There's a couple of things that I still need to do. I haven't yet exposed this to the SB API, because the patch is already getting quite big. The instance of MemoryHistory should probably be tied to the Process object (same way LanguageRuntime is), so it doesn't get created for every command.

http://reviews.llvm.org/D4596

Files:
  include/lldb/Core/PluginManager.h
  include/lldb/Target/MemoryHistory.h
  include/lldb/lldb-forward.h
  include/lldb/lldb-private-interfaces.h
  lldb.xcodeproj/project.pbxproj
  source/CMakeLists.txt
  source/Commands/CommandObjectMemory.cpp
  source/Core/PluginManager.cpp
  source/Plugins/CMakeLists.txt
  source/Plugins/Makefile
  source/Plugins/MemoryHistory/CMakeLists.txt
  source/Plugins/MemoryHistory/asan/CMakeLists.txt
  source/Plugins/MemoryHistory/asan/Makefile
  source/Plugins/MemoryHistory/asan/MemoryHistoryASan.cpp
  source/Plugins/MemoryHistory/asan/MemoryHistoryASan.h
  source/Plugins/Process/Utility/HistoryThread.h
  source/Target/CMakeLists.txt
  source/Target/MemoryHistory.cpp
  source/lldb.cpp
  test/functionalities/asan/Makefile
  test/functionalities/asan/TestAsan.py
  test/functionalities/asan/main.c
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D4596.11684.patch
Type: text/x-patch
Size: 35751 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20140719/bf4e0b1e/attachment.bin>


More information about the lldb-commits mailing list