Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Fix reporting of callee saved registers with nongnu libuwind #527

Merged
merged 2 commits into from
Mar 23, 2015

Conversation

jkotas
Copy link
Member

@jkotas jkotas commented Mar 21, 2015

The callee saved registers were not preserved for GC stackwalk with nongnu
libunwind that does not provide context pointers. Fixed by adding an extra
space to MachState to preserve them.

To avoid large amounts of copy&pasted code, introduced macro to enumerate
all callee saved registers, similar to existing macro to enumerate all
argument registers. This macro makes the code to copy the register values
between different structures more compact, and less prone to typos.

This is fixing #512

The callee saved registers were not preserved for GC stackwalk with nongnu
libunwind that does not provide context pointers. Fixed by adding an extra
space to MachState to preserve them.

To avoid large amounts of copy&pasted code, introduced macro to enumerate
all callee saved registers, similar to existing macro to enumerate all
argument registers. This macro makes the code to copy the register values
between different structures more compact, and less prone to typos.
CALLEE_SAVED_REGISTER(Rbx) \
CALLEE_SAVED_REGISTER(Rbp)

#define NUM_CALLEE_SAVED_REGISTERS 8

Choose a reason for hiding this comment

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

I think this should be 6 instead of 8?

Copy link
Member Author

Choose a reason for hiding this comment

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

Good catch! The memory corruptions from this typo would not be fun to trace down.

@jkotas jkotas force-pushed the macunwind branch 2 times, most recently from b7f15e1 to b3a674a Compare March 23, 2015 01:10
@jkotas
Copy link
Member Author

jkotas commented Mar 23, 2015

Addressed code review feedback. @sergiy-k PTAL

};

struct CalleeSavedRegistersPointers {
#define CALLEE_SAVED_REGISTER(regname) PTR_TADDR regname;

Choose a reason for hiding this comment

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

I think this needs to be p##regname instead of regname like in other places. Otherwise it will cause a build break.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, I forgot to commit the change - it is fixed now.

@sergiy-k
Copy link

LGTM.

@janvorli
Copy link
Member

LGTM

jkotas added a commit that referenced this pull request Mar 23, 2015
Fix reporting of callee saved registers with nongnu libuwind
@jkotas jkotas merged commit 107e3bd into dotnet:master Mar 23, 2015
@jkotas jkotas deleted the macunwind branch March 23, 2015 18:21
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants