Corrected stack start and end in stack_thunk_dump_stack(). by mhightower83 · Pull Request #7085 · esp8266/Arduino · GitHub
Skip to content

Corrected stack start and end in stack_thunk_dump_stack().#7085

Merged
earlephilhower merged 1 commit into
esp8266:masterfrom
mhightower83:pr-bear-stack-dump
Feb 16, 2020
Merged

Corrected stack start and end in stack_thunk_dump_stack().#7085
earlephilhower merged 1 commit into
esp8266:masterfrom
mhightower83:pr-bear-stack-dump

Conversation

@mhightower83

Copy link
Copy Markdown
Contributor

No description provided.

@earlephilhower

Copy link
Copy Markdown
Collaborator

@mhightower83

Copy link
Copy Markdown
Contributor Author

Sorry to create confusion.

stack_thunk_ptr = (uint32_t *)malloc(_stackSize * sizeof(uint32_t));
stack_thunk_top = stack_thunk_ptr + _stackSize - 1;

What I was looking at, was that stack_thunk_top is larger stack_thunk_ptr.
Which means pos starting at a value greater than stack_thunk_ptr in the while loops below.
So they are skipped and never run.

void stack_thunk_dump_stack()
{
uint32_t *pos = stack_thunk_top;
while (pos < stack_thunk_ptr) {
if ((pos[0] != _stackPaint) || (pos[1] != _stackPaint) || (pos[2] != _stackPaint) || (pos[3] != _stackPaint))
break;
pos += 4;
}
ets_printf(">>>stack>>>\n");
while (pos < stack_thunk_ptr) {
ets_printf("%08x: %08x %08x %08x %08x\n", (int32_t)pos, pos[0], pos[1], pos[2], pos[3]);
pos += 4;
}

BearSSL stack printing is handled locally in postmortem. The function stack_thunk_dump_stack() is not called.

if (sp_dump > stack_thunk_get_stack_bot() && sp_dump <= stack_thunk_get_stack_top()) {
// BearSSL we dump the BSSL second stack and then reset SP back to the main cont stack
ets_printf_P(PSTR("\nctx: bearssl\nsp: %08x end: %08x offset: %04x\n"), sp_dump, stack_thunk_get_stack_top(), offset);
print_stack(sp_dump + offset, stack_thunk_get_stack_top());
offset = 0; // No offset needed anymore, the exception info was stored in the bssl stack
sp_dump = stack_thunk_get_cont_sp();
}

@earlephilhower

Copy link
Copy Markdown
Collaborator

@earlephilhower earlephilhower merged commit 321d256 into esp8266:master Feb 16, 2020
@mhightower83 mhightower83 deleted the pr-bear-stack-dump branch January 13, 2021 18:08
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.

2 participants