llvm-project/lldb/examples
Greg Clayton ef8180a3f6 <rdar://problem/14972424>
When debugging with the GDB remote in LLDB, LLDB uses special packets to discover the
registers on the remote server. When those packets aren't supported, LLDB doesn't
know what the registers look like. This checkin implements a setting that can be used
to specify a python file that contains the registers definitions. The setting is:

(lldb) settings set plugin.process.gdb-remote.target-definition-file /path/to/module.py

Inside module there should be a function:

def get_dynamic_setting(target, setting_name):

This dynamic setting function is handed the "target" which is a SBTarget, and the 
"setting_name", which is the name of the dynamic setting to retrieve. For the GDB
remote target definition the setting name is 'gdb-server-target-definition'. The
return value is a dictionary that follows the same format as the OperatingSystem
plugins follow. I have checked in an example file that implements the x86_64 GDB
register set for people to see:

    examples/python/x86_64_target_definition.py
    
This allows LLDB to debug to any archticture that is support and allows users to
define the registers contexts when the discovery packets (qRegisterInfo, qHostInfo)
are not supported by the remote GDB server.

A few benefits of doing this in Python:
1 - The dynamic register context was already supported in the OperatingSystem plug-in
2 - Register contexts can use all of the LLDB enumerations and definitions for things
    like lldb::Format, lldb::Encoding, generic register numbers, invalid registers 
    numbers, etc.
3 - The code that generates the register context can use the program to calculate the
    register context contents (like offsets, register numbers, and more)
4 - True dynamic detection could be used where variables and types could be read from 
    the target program itself in order to determine which registers are available since
    the target is passed into the python function.
    
This is designed to be used instead of XML since it is more dynamic and code flow and
functions can be used to make the dictionary.

llvm-svn: 192646
2013-10-15 00:14:28 +00:00
..
customization Warn about an example script being obsoleted by new native features and just an example 2012-03-16 01:25:01 +00:00
darwin/heap_find Fixed a crash in objc_refs caused by improper 2013-08-13 00:53:33 +00:00
functions Added the ability options to: 2013-06-14 00:30:23 +00:00
interposing/darwin/fd_interposing Revert accidental commit. 2012-02-21 19:02:29 +00:00
lookup Remove unneeded include. 2013-06-13 23:56:47 +00:00
plugins/commands Replace printf with result.Printf, so that the plugin shows its output with any configuration of the LLDB I/O streams (esp. useful in graphic environments such as Xcode) 2012-10-30 18:01:15 +00:00
python <rdar://problem/14972424> 2013-10-15 00:14:28 +00:00
scripting Add source files for Python scripting example (coming soon). 2011-06-02 23:23:47 +00:00
summaries An example of data formatters that generate a summary for a Unicode UTF encoded string represented as a (pointer,length) pair 2013-10-08 17:29:27 +00:00
synthetic This is an example synthetic provider for libc++ unordered (multi) maps&set 2013-09-04 17:48:52 +00:00
test Modified .lldb-loggings now to direct the lldb log files to the same session directory which also houses the test logs. 2012-08-22 20:25:33 +00:00