[Lldb-commits] [PATCH] LLDB AddressSanitizer break on error and report data extraction

Kuba Brecka kuba.brecka at gmail.com
Thu Oct 2 17:29:00 PDT 2014


Hi jasonmolenda, jingham,

This patch gives LLDB some ability to interact with AddressSanitizer runtime library, on top of what we already have (historical memory stack traces provided by ASan). Namely, that's the ability to stop on an error caught by ASan, and access the report information that are associated with it. The report information is also exposed into SB API.

More precisely this patch...
1) adds a new plugin type, InstrumentationRuntime, which should serve as a generic superclass for other instrumentation runtime libraries, these plugins get notified when modules are loaded, so they get a chance to "activate" when a specific dynamic library is loaded
2) an instance of this plugin type, AddressSanitizerRuntime, which activates itself when it sees the ASan dynamic library or founds ASan statically linked in the executable
3) adds a collection of these plugins into the Process class
4) AddressSanitizerRuntime sets an internal breakpoint on __asan::AsanDie(), and when this breakpoint gets hit, it retrieves the report information from ASan
5) this breakpoint is then exposed as a new StopReason, eStopReasonInstrumentation, with a new StopInfo subclass, InstrumentationRuntimeStopInfo
6) the StopInfo superclass is extended with a m_extended_info field (it's a StructuredData::ObjectSP), that can hold arbitrary JSON-like data, which is the way the new plugin provides the report data
7) the "thread info" command now accepts a "-s" flag that prints out the JSON data of a stop reason (same way the "-j" flag works now)
8) SBThread has a new API, GetStopReasonExtendedInfoAsJSON, which dumps the JSON string into a SBStream
9) adds a test case for all of this

I plan to also get rid of the original ASan plugin (memory history stack traces) and use an instance of AddressSanitizerRuntime for that purpose.

http://reviews.llvm.org/D5592

Files:
  include/lldb/API/SBThread.h
  include/lldb/Core/PluginManager.h
  include/lldb/Target/InstrumentationRuntime.h
  include/lldb/Target/InstrumentationRuntimeStopInfo.h
  include/lldb/Target/Process.h
  include/lldb/Target/StopInfo.h
  include/lldb/Target/Thread.h
  include/lldb/lldb-enumerations.h
  include/lldb/lldb-forward.h
  include/lldb/lldb-private-interfaces.h
  lldb.xcodeproj/project.pbxproj
  scripts/Python/interface/SBThread.i
  source/API/SBThread.cpp
  source/Commands/CommandObjectThread.cpp
  source/Core/Debugger.cpp
  source/Core/PluginManager.cpp
  source/Plugins/InstrumentationRuntime/AddressSanitizer/AddressSanitizerRuntime.cpp
  source/Plugins/InstrumentationRuntime/AddressSanitizer/AddressSanitizerRuntime.h
  source/Plugins/InstrumentationRuntime/AddressSanitizer/CMakeLists.txt
  source/Plugins/InstrumentationRuntime/AddressSanitizer/Makefile
  source/Plugins/InstrumentationRuntime/CMakeLists.txt
  source/Target/CMakeLists.txt
  source/Target/InstrumentationRuntime.cpp
  source/Target/InstrumentationRuntimeStopInfo.cpp
  source/Target/Process.cpp
  source/Target/StopInfo.cpp
  source/Target/Thread.cpp
  source/lldb.cpp
  test/functionalities/asan/TestAsan.py
  test/functionalities/asan/TestReportData.py
  test/functionalities/asan/main.c
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D5592.14360.patch
Type: text/x-patch
Size: 59518 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20141003/1ecccf8a/attachment.bin>


More information about the lldb-commits mailing list