Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DWARF CFI: use a stack for restore/remember opcodes #3480

Merged

Conversation

javierhonduco
Copy link
Contributor

@javierhonduco javierhonduco commented Aug 23, 2023

Implementing the DW_CFA_remember_state and DW_CFA_restore_state according to the DWARF specification requires us to create a stack that can store an arbitrary number of elements, that is, there could be multiple "pushes" before "popping" them.

From the 5th revision of the spec [0]:

6.4.2.4 Row State Instructions
DW_CFA_remember_state
The DW_CFA_remember_state instruction takes no operands. The required
action is to push the set of rules for every register onto an implicit stack.
DW_CFA_restore_state
The DW_CFA_restore_state instruction takes no operands. The required action
is to pop the set of rules off the implicit stack and place them in the
current row.

0: https://dwarfstd.org/doc/DWARF5.pdf

Fixes: #3206

pkg/dwarf/frame/table.go Outdated Show resolved Hide resolved
Implementing the `DW_CFA_remember_state` and `DW_CFA_restore_state`
according to the DWARF specification requires us to create a stack that
can store an arbitrary number of elements, that is, there could be
multiple "pushes" before "popping" them.

From the 5th revision of the spec [0]:

> 6.4.2.4 Row State Instructions
> DW_CFA_remember_state
> 	The DW_CFA_remember_state instruction takes no operands. The required
>	action is to push the set of rules for every register onto an implicit stack.
>	DW_CFA_restore_state
> DW_CFA_restore_state
>	The DW_CFA_restore_state instruction takes no operands. The required action
>	is to pop the set of rules off the implicit stack and place them in the
>	current row.

- [0]: https://dwarfstd.org/doc/DWARF5.pdf

Signed-off-by: Francisco Javier Honduvilla Coto <javierhonduco@gmail.com>
@javierhonduco javierhonduco force-pushed the remember-restore-dwarf-cfi-fixes branch from b52b69a to 86b6964 Compare August 23, 2023 13:10
Copy link
Member

@aarzilli aarzilli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Member

@derekparker derekparker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@derekparker derekparker merged commit 908876d into go-delve:master Aug 23, 2023
1 check passed
@javierhonduco javierhonduco deleted the remember-restore-dwarf-cfi-fixes branch August 24, 2023 10:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

DWARF unwinding (CFI) fixes
3 participants