From: jh--- via Gdb <gdb@sourceware.org>
To: gdb@sourceware.org
Subject: Creating and using dwarf information for ARMv7-A exception handlers
Date: Wed, 26 Nov 2025 11:00:50 +0100 [thread overview]
Message-ID: <6af4b8e63d0f1e9ec75d5ca4452874a8@clesse.com> (raw)
In-Reply-To: <51ebaf670472865c9abb31854e16c795@clesse.com>
Hi,
I am working on an embedded target with a Cortex-A9 CPU. There is a
debug tool based on Eclipse and gdb 10.2.
I would like (if it is possible) to have a complete stack trace when my
code is in the SVC handler.
I can place a breakpoint at the beginning of my SVC handler, and LR_SVC
has the right value, but the function call stack is not good (later when
I change the CPSR mode from SVC to SYS, the call stack gets better, but
does not go back to the calling USR mode - but that's expected, since I
change SP and haven't written the needed cfi code yet. But going back to
the USR call stack is my ideal objective).
I tried to set the stack base (CFA if I understood properly) to R13_SVC
(register 164 according to aadwarf32.pdf). I don't know if it works, but
at least, I get something when I dwarfdump asm_vector.o.
I also tried to set the return address to R14_SVC (register 165
according to aadwarf32.pdf), this produces the "return_address_register
165" (instead of 14 which is LR as expected) output of dwarfdump. But
the call stack does not change in gdb (or more precisely in Eclipse).
The code is compile with arm-none-eabi-gcc 11.2.0
Here is what I tried:
SVCHandler: // CPSR mode is SVC
.type SVCHandler,%function
.cfi_sections .debug_frame
.cfi_startproc
.cfi_def_cfa_register 164 //sp_svc
.cfi_return_column 165 //lr_svc
PUSH {R0-R3}
// Do some stuff, changing CPSR mode to SYS
// Change CPSR mode back to SVC
POP {R0-R3}
SUBS PC, LR, #0
.cfi_endproc
Here is the output of dwarfdump:
fde:
< 0><0x0000035c:0x00000428><><cie offset 0x00000000::cie index
0><fde offset 0x00000014 length: 0x0000000c><eh offset none>
0x0000035c: <off cfa=00(r164) >
cie:
< 0> version 1
cie section offset 0 0x00000000
augmentation
code_alignment_factor 2
data_alignment_factor -4
return_address_register 165
bytes of initial instructions 7
cie length 16
initial instructions
0 DW_CFA_def_cfa r13 0
3 DW_CFA_def_cfa_register r164
6 DW_CFA_nop
What am I doing wrong?
Is there a way to dump the dwarf state in gdb? To try and determine what
it understands of my code and how it is primed when the breakpoint is
triggered.
Is the register number wrong? Is it something on the gdb side?
Best regards,
JH.
next parent reply other threads:[~2025-11-26 10:02 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <1916c229fb1f148902bf15a1b60dedbe@clesse.com>
[not found] ` <51ebaf670472865c9abb31854e16c795@clesse.com>
2025-11-26 10:00 ` jh--- via Gdb [this message]
2025-11-26 10:05 ` Basile Starynkevitch
2025-11-27 8:13 ` jh--- via Gdb
2025-11-27 8:41 ` Basile Starynkevitch
2025-12-01 19:59 ` Tom Tromey
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=6af4b8e63d0f1e9ec75d5ca4452874a8@clesse.com \
--to=gdb@sourceware.org \
--cc=jh@clesse.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox