Mirror of the gdb mailing list
 help / color / mirror / Atom feed
* Custom core file
@ 2016-09-28 13:31 Nikolay Martyanov
  2016-09-28 14:28 ` Duane Ellis
                   ` (2 more replies)
  0 siblings, 3 replies; 10+ messages in thread
From: Nikolay Martyanov @ 2016-09-28 13:31 UTC (permalink / raw)
  To: gdb

Hello guys!

I have a self-written bare-metal hypervisor for x86 arch and I'd like to 
perform postmortem debugging of it's core (not VM, hypervisor itself!).
So the idea is to save physical memory state and later use GDB to 
interpret it.

As I understand, GDB can interpret only `core files`. But I didn't found 
a lot of info about this file format.
Some sources say it should be a specific ELF file with several mandatory 
".note" sections.
Others say `core file` can be in any format and adaptation should be 
done on BFD-level of GDB.

I looked through the code in corelow.c. Now my undestanding is somthing 
like:

1. Save data section of my hypervisor
2. Save current stack state of my hypervisor
3. Save current registers state (MSR?)
4. Define "sys/user.h"-like header with layout description of above 
mentioned structures
5. Using this header, implement function analog to 
`trad_unix_core_file_p()` in file analog to `trad-core.c` (It translates 
my `struct user` to `struct trad_core_struct`)
6. Implement functions like `supply_*regset()` in file like 
`i386-myhyper-nat.c`
7. ??? (magic I didn't realized yet)
8. Profit!

Note, steps 1-3 say nothing about ELF-format. It embarrasses me...

So my question is: am I looking in a right direction? Can you point me 
in to the issues in the plan (or even my understanding)?
Or may be there are any other ways to feed a raw physical memory to GDB?

Thanks,
Nikolay


^ permalink raw reply	[flat|nested] 10+ messages in thread
* RE: Custom core file
@ 2016-09-28 15:31 duane
  2016-09-28 16:37 ` Nikolay Martyanov
  2016-09-28 19:22 ` Nikolay Martyanov
  0 siblings, 2 replies; 10+ messages in thread
From: duane @ 2016-09-28 15:31 UTC (permalink / raw)
  To: Nikolay Martyanov, gdb

>> So, I guess, dump/restore approach works only in two cases:
>> a) debugging live process you have attached to (it's not my case, as I 
>> perform postmortem debug)
>> b) already has loaded core file, which provides a context via saved CPU 
>> state - and it is the way I chose to follow.

For step (B) - first load a dummy (tiny) standard core file - that gives
you a debug context, think of it as a shim.

Then proceed with adding your symbols and using dump/restore to load
your image.





^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2016-09-28 19:22 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-09-28 13:31 Custom core file Nikolay Martyanov
2016-09-28 14:28 ` Duane Ellis
2016-09-28 14:58 ` Jan Kratochvil
2016-09-28 15:18   ` Nikolay Martyanov
2016-09-28 15:33     ` Jan Kratochvil
2016-09-28 16:27       ` Nikolay Martyanov
2016-09-28 15:02 ` Nikolay Martyanov
2016-09-28 15:31 duane
2016-09-28 16:37 ` Nikolay Martyanov
2016-09-28 19:22 ` Nikolay Martyanov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox