Linux(MIPS): Temporarily "change" register contents when viewing core dump
Some of the threads in my app are sat in optimized functions and when I debug the app, gdb can't backtrace from those functions. But I've looked at the assembler and can partially unwind the stack by hand up to the previous function's frame by doing something like:
set $old_ra = $ra
set $old_sp = $sp
set $ra = *(unsigned long*)($sp+28)
set $sp = $sp + 48
bt
set $ra = $old_ra
set $sp = $old_sp
This works perfectly if I'm doing live debugging, and it succes开发者_如何学运维sfully shows a complete backtrace. I want to be able to do the same offline when looking at a core dump. Obviously the concept of poking a register is meaningless in a core dump, but is there a way to tell gdb "just use this value for the register" so I can do a similar backtrace?
Not out of the box. The only way I found is to physically modify the core file. ELF core file would usually have one or more 'reg' sections that contain process' registers. All you need is to figure out where exactly in that section is the register you want to change and then edit the file, put the new value there and re-run GDB.
精彩评论