[Lldb-commits] [PATCH] Minimal API support for non-8-bit byte targets

jingham at apple.com jingham at apple.com
Mon Oct 20 11:12:21 PDT 2014


> On Oct 20, 2014, at 6:09 AM, Matthew Gardiner <mg11 at csr.com> wrote:
> 
> Hi clayborg, emaste,
> 
> In order to write applications with the lldb C++ API which support non-8-bit bytes targets, it is necessary to extend the API somewhat.
> 
> To use lldb's ReadMemory interface, which accepts a buffer sized by the host's definition of a byte, I have added the following "discovery" functions:
> 
> SBSection::GetTargetByteSize
> SBTarget::GetCodeByteSize
> SBTarget::GetDataByteSize
> 
> additionally I have added SBTarget::ResolveFileAddress, which resolves a file address to a section. With the above discovery functions, my test C++ application, can correctly deduce the host buffer allocation necessary, and decode the read data, for an address read on the target. 
> 
> I added SBTarget::ReadMemory too, so that my test application can read memory (straight from the object file) without a running process. This function merely being a wrapper on the existent Target::ReadMemory.
> 
> (As an aside I added SBTarget::GetPlatform, since I found this useful as a sanity check when using my test C++ application.)
> 
> For each C++ API routine I have added a test case. I've run these case on linux and FreeBSD to my satisfaction. I've assumed that these tests will work on MACH-O, so I did not decorate them with "@dwarf_test". Feel free to comment if this is considered to be a poor omission.

The @dwarf test is because Mac OS X has two ways of handling debug information, (1) where we leave the debug information in .o files and use an associated "debug map" built by the linker - this is for development and provides fast turnaround since you don't have to link all the DWARF to build the executable, and (2) using a "dSYM" constructed by the DWARF linker (dsymutil).  Since these are two pretty different modes of debugging, we run all tests both ways.  But of course, dSYM's aren't available anywhere but OS X, which is why that test only gets run on OS X.  I'd like to keep doing that for new tests, if you don't mind...

Jim


> 
> http://reviews.llvm.org/D5867
> 
> Files:
>  include/lldb/API/SBSection.h
>  include/lldb/API/SBTarget.h
>  include/lldb/Target/Target.h
>  scripts/Python/interface/SBSection.i
>  scripts/Python/interface/SBTarget.i
>  source/API/SBSection.cpp
>  source/API/SBTarget.cpp
>  source/Target/Target.cpp
>  test/lldbtest.py
>  test/python_api/section/Makefile
>  test/python_api/section/TestSectionAPI.py
>  test/python_api/section/main.c
>  test/python_api/target/TestTargetAPI.py
>  test/python_api/target/main.c
> <D5867.15138.patch>_______________________________________________
> lldb-commits mailing list
> lldb-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/lldb-commits





More information about the lldb-commits mailing list