aboutsummaryrefslogtreecommitdiff
path: root/bfd/ChangeLog
diff options
context:
space:
mode:
authorAndrew Burgess <andrew.burgess@embecosm.com>2021-10-23 09:59:25 +0100
committerAndrew Burgess <aburgess@redhat.com>2022-03-22 10:05:05 +0000
commit25209e2c6979c3838e14e099f0333609810db280 (patch)
treec3a6ecdc110db913c886182431031054a1461cf0 /bfd/ChangeLog
parent6c111a4ec26ba4a1343cb788c34e4bccce65bfeb (diff)
downloadgdb-25209e2c6979c3838e14e099f0333609810db280.zip
gdb-25209e2c6979c3838e14e099f0333609810db280.tar.gz
gdb-25209e2c6979c3838e14e099f0333609810db280.tar.bz2
gdb/python: add gdb.format_address function
Add a new function, gdb.format_address, which is a wrapper around GDB's print_address function. This method takes an address, and returns a string with the format: ADDRESS <SYMBOL+OFFSET> Where, ADDRESS is the original address, formatted as hexadecimal, SYMBOL is a symbol with an address lower than ADDRESS, and OFFSET is the offset from SYMBOL to ADDRESS in decimal. If there's no SYMBOL suitably close to ADDRESS then the <SYMBOL+OFFSET> part is not included. This is useful if a user wants to write a Python script that pretty-prints addresses, the user no longer needs to do manual symbol lookup, or worry about correctly formatting addresses. Additionally, there are some settings that effect how GDB picks SYMBOL, and whether the file name and line number should be included with the SYMBOL name, the gdb.format_address function ensures that the users Python script also benefits from these settings. The gdb.format_address by default selects SYMBOL from the current inferiors program space, and address is formatted using the architecture for the current inferior. However, a user can also explicitly pass a program space and architecture like this: gdb.format_address(ADDRESS, PROGRAM_SPACE, ARCHITECTURE) In order to format an address for a different inferior. Notes on the implementation: In py-arch.c I extended arch_object_to_gdbarch to add an assertion for the type of the PyObject being worked on. Prior to this commit all uses of arch_object_to_gdbarch were guaranteed to pass this function a gdb.Architecture object, but, with this commit, this might not be the case. So, with this commit I've made it a requirement that the PyObject be a gdb.Architecture, and this is checked with the assert. And in order that callers from other files can check if they have a gdb.Architecture object, I've added the new function gdbpy_is_architecture. In py-progspace.c I've added two new function, the first progspace_object_to_program_space, converts a PyObject of type gdb.Progspace to the associated program_space pointer, and gdbpy_is_progspace checks if a PyObject is a gdb.Progspace or not.
Diffstat (limited to 'bfd/ChangeLog')
0 files changed, 0 insertions, 0 deletions