Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
Please login to access the resource
SUSE:SLE-15-SP1:Update
gdb
gdb-tdep-aarch64-fix-frame-address-of-last-insn...
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File gdb-tdep-aarch64-fix-frame-address-of-last-insn.patch of Package gdb
From 433568090645c05d3b7fdbb1a4ae0887e96d9cc0 Mon Sep 17 00:00:00 2001 From: Tom de Vries <tdevries@suse.de> Date: Mon, 23 Jan 2023 16:49:36 +0100 Subject: [PATCH 1/2] [gdb/tdep, aarch64] Fix frame address of last insn Consider the test-case test.c, compiled without debug info: ... void foo (const char *s) { } int main (void) { foo ("foo"); return 0; } ... Disassembly of foo: ... 0000000000400564 <foo>: 400564: d10043ff sub sp, sp, #0x10 400568: f90007e0 str x0, [sp, #8] 40056c: d503201f nop 400570: 910043ff add sp, sp, #0x10 400574: d65f03c0 ret ... Now, let's do "info frame" at each insn in foo, as well as printing $sp and $x29 (and strip the output of info frame to the first line, for brevity): ... $ gdb -q a.out Reading symbols from a.out... (gdb) b *foo Breakpoint 1 at 0x400564 (gdb) r Starting program: a.out Breakpoint 1, 0x0000000000400564 in foo () (gdb) display /x $sp 1: /x $sp = 0xfffffffff3a0 (gdb) display /x $x29 2: /x $x29 = 0xfffffffff3a0 (gdb) info frame Stack level 0, frame at 0xfffffffff3a0: (gdb) si 0x0000000000400568 in foo () 1: /x $sp = 0xfffffffff390 2: /x $x29 = 0xfffffffff3a0 (gdb) info frame Stack level 0, frame at 0xfffffffff3a0: (gdb) si 0x000000000040056c in foo () 1: /x $sp = 0xfffffffff390 2: /x $x29 = 0xfffffffff3a0 (gdb) info frame Stack level 0, frame at 0xfffffffff3a0: (gdb) si 0x0000000000400570 in foo () 1: /x $sp = 0xfffffffff390 2: /x $x29 = 0xfffffffff3a0 (gdb) info frame Stack level 0, frame at 0xfffffffff3a0: (gdb) si 0x0000000000400574 in foo () 1: /x $sp = 0xfffffffff3a0 2: /x $x29 = 0xfffffffff3a0 (gdb) info frame Stack level 0, frame at 0xfffffffff3b0: pc = 0x400574 in foo; saved pc = 0x40058c (gdb) si 0x000000000040058c in main () 1: /x $sp = 0xfffffffff3a0 2: /x $x29 = 0xfffffffff3a0 ... The "frame at" bit lists 0xfffffffff3a0 except at the last insn, where it lists 0xfffffffff3b0. The frame address is calculated here in aarch64_make_prologue_cache_1: ... unwound_fp = get_frame_register_unsigned (this_frame, cache->framereg); if (unwound_fp == 0) return; cache->prev_sp = unwound_fp + cache->framesize; ... For insns after the prologue, we have cache->framereg == sp and cache->framesize == 16, so unwound_fp + cache->framesize gives the wrong answer once sp has been restored to entry value by the before-last insn. Fix this by detecting the situation that the sp has been restored. This fixes PRs tdep/30010 and tdep/30011. This also fixes the aarch64 FAILs in gdb.reverse/solib-precsave.exp and gdb.reverse/solib-reverse.exp I reported in PR gdb/PR29721. Tested on aarch64-linux. PR tdep/30010 PR tdep/30011 Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30010 Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30011 --- gdb/aarch64-tdep.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/gdb/aarch64-tdep.c b/gdb/aarch64-tdep.c index 3cc0d3b234d..499b87ef480 100644 --- a/gdb/aarch64-tdep.c +++ b/gdb/aarch64-tdep.c @@ -145,6 +145,8 @@ static const char *const aarch64_mte_register_names[] = "tag_ctl" }; +static int aarch64_stack_frame_destroyed_p (struct gdbarch *, CORE_ADDR); + /* AArch64 prologue cache structure. */ struct aarch64_prologue_cache { @@ -996,7 +998,10 @@ aarch64_make_prologue_cache_1 (frame_info_ptr this_frame, if (unwound_fp == 0) return; - cache->prev_sp = unwound_fp + cache->framesize; + cache->prev_sp = unwound_fp; + if (!aarch64_stack_frame_destroyed_p (get_frame_arch (this_frame), + cache->prev_pc)) + cache->prev_sp += cache->framesize; /* Calculate actual addresses of saved registers using offsets determined by aarch64_analyze_prologue. */ base-commit: 11c93dc64f6137214809583d9c5a775b18b4f027 -- 2.35.3
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor