views:

112

answers:

1

Hello! There are two stacks in the program: one is created by OS and the second is created by program itself to run some code with it.

When the program crashes in the second stack, I want to switch to the main stack in gdb and see the backtrace. Is it possible?

I tried to save the rsp to a variable and change it after the crash, but the resulting backtrace was not right. I think gdb cannot differentiate frames in stack.

A: 

If you have two threads with two stacks you can query the thread by 'info threads'. After you know which thread's stack you want to see select it with the 'thread' command. Put the number of the thread after the command.

Then you only need to query the stack by 'bt'

Vereb
No, there is no threads, program behaves like JIT, and runs compiled program inside it. So question is how can I collect information about program call stack contents in runtime and how can give it to GDB after crash to restore main stack.