This is an archive of the discontinued LLVM Phabricator instance.

Minimal API support for non-8-bit byte targets
Needs ReviewPublic

Authored by mg11 on Oct 20 2014, 6:09 AM.

Details

Summary

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.

Diff Detail

Event Timeline

mg11 updated this revision to Diff 15138.Oct 20 2014, 6:09 AM
mg11 retitled this revision from to Minimal API support for non-8-bit byte targets.
mg11 updated this object.
mg11 edited the test plan for this revision. (Show Details)
mg11 added reviewers: clayborg, emaste.
mg11 added a subscriber: Unknown Object (MLST).
mg11 updated this revision to Diff 15168.Oct 21 2014, 12:36 AM
mg11 added a reviewer: jingham.

I've uploaded a new diff, which I believe addresses Jim's comments, that is, I've bifurcated each of the tests which I added in the first diff into a dwarf and dsym version.

emaste edited edge metadata.Sep 8 2016, 7:14 AM

This change will no longer apply. Is it still desired? If so, can you please rebase the patch.

emaste resigned from this revision.Sep 7 2023, 6:40 AM
Herald added a project: Restricted Project. · View Herald TranscriptSep 7 2023, 6:40 AM