aboutsummaryrefslogtreecommitdiff
path: root/gdb/python
diff options
context:
space:
mode:
authorTom Tromey <tromey@adacore.com>2023-08-01 13:57:19 -0600
committerTom Tromey <tromey@adacore.com>2023-08-03 09:35:38 -0600
commit30baee6865571bb0385dbc6ee7e06701e1253028 (patch)
treed8056d8e7dcfbe90067a72743b9785904fe8cc85 /gdb/python
parentb1c0ab20809a502b2d2224fecb0dca3ada2e9b22 (diff)
downloadgdb-30baee6865571bb0385dbc6ee7e06701e1253028.zip
gdb-30baee6865571bb0385dbc6ee7e06701e1253028.tar.gz
gdb-30baee6865571bb0385dbc6ee7e06701e1253028.tar.bz2
Use frame.name() in FrameDecorator
A co-worker pointed out that gdb's DAP implementation might return an integer for the name of a stack frame, like: {"id": 1, "name": 93824992310799, ...} This can be seen currently in the logs of the bt-nodebug.exp test case. What is happening is that FrameDecorator falls back on returning the PC when the frame's function symbol cannot be found, relying on the gdb core to look up the minsym and print its name. This can actually yield the wrong answer sometimes, because it falls into the get_frame_pc / get_frame_address_in_block problem -- if the frame is at a call to a noreturn function, the PC in this case might appear to be in the next function in memory. For more on this, see: https://sourceware.org/bugzilla/show_bug.cgi?id=8416 and related bugs. However, there's a different approach we can take: the code here can simply use Frame.name. This handles the PC problem correctly, and gets us the information we need.
Diffstat (limited to 'gdb/python')
-rw-r--r--gdb/python/lib/gdb/FrameDecorator.py15
1 files changed, 4 insertions, 11 deletions
diff --git a/gdb/python/lib/gdb/FrameDecorator.py b/gdb/python/lib/gdb/FrameDecorator.py
index aa9a220..39ee2e2 100644
--- a/gdb/python/lib/gdb/FrameDecorator.py
+++ b/gdb/python/lib/gdb/FrameDecorator.py
@@ -75,17 +75,10 @@ class _FrameDecoratorBase(object):
elif frame.type() == gdb.SIGTRAMP_FRAME:
return "<signal handler called>"
- func = frame.function()
-
- # If we cannot determine the function name, return the
- # address. If GDB detects an integer value from this function
- # it will attempt to find the function name from minimal
- # symbols via its own internal functions.
- if func is None:
- pc = frame.pc()
- return pc
-
- return str(func)
+ func = frame.name()
+ if not isinstance(func, str):
+ func = "???"
+ return func
def address(self):
"""Return the address of the frame's pc"""