From: dan clark <2clarkd@gmail.com>
To: gdb@sourceware.org
Subject: setting cooked registers desirable feature for coredump analysis but results in error
Date: Mon, 07 Feb 2011 19:01:00 -0000 [thread overview]
Message-ID: <AANLkTikFsKkuaJgL5Qmm9ZpHn5YmfMdECZdFZANHGYoP@mail.gmail.com> (raw)
Hello Gentle readers!
An interesting debug scenario occurs when either a stack is corrupted or a
threading package is unknown by gdb (anything but pthreads?) and one
is left with the binary and a core dump. Let's say this was a remote
system so one can't just re-run the program. A method of getting
some more information out of the resulting entrails is to pick through
known data structures and locate a promising stack pointer, stack base
pointer and program counter. Set the values in GDB and type 'where 2'
to see if the stack unwinds from that point would be a very desirable
feature. Unfortunately GDB 7.2 does not allow registers to be written
for core files. When attempting to set a register value an error is returned.
(gdb) set $rsp=$anaddress
You can't do that without a process to debug.
Clearly setting the hardware device registers is can not be done, but
setting the gdb notion of the registers for analysis of the core dump
could be achieved to facilitate analysis of the entrails.
Perhaps a simple patch could be developed to provide such functionality?
Would the correct place to add such a change be: corelow.c
init_core_ops()
...
core_ops.to_store_registers = core_store_inferior_registers;
core_ops.to_prepare_to_store = core_prepare_to_store;
Seems like the prepare could be simple null function:
static void
core_prepare_to_store (struct regcache *regcache)
{
}
But that leaves the slightly more difficult
static void
core_store_inferior_registers (struct target_ops *ops,
struct regcache *regcache, int regnum)
{
gdb_gregset_t gregset;
/* modify the proper register values here... */
regcache_raw_supply(regcache, regnum, (char *)&gregset);
}
Any suggestions on what an implementation might look like to achieve
debug of a core file?
The above, btw, does not modify the cooked registers within gdb so
info reg are unfortunately not modified quiet so easily...
This was supported by adding an 'ignore' function to to_store_registers
and to_prepare_registers for the target architecture in the early gdb
6.x timeframe. How would it be done in the 7.x codebase?
Thanks for any suggestions!
dan
ps. repost from patches-gdb
next reply other threads:[~2011-02-07 19:01 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-02-07 19:01 dan clark [this message]
2011-02-08 19:53 ` Jan Kratochvil
2011-02-08 20:47 ` Daniel Jacobowitz
2011-02-09 21:31 ` dan clark
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=AANLkTikFsKkuaJgL5Qmm9ZpHn5YmfMdECZdFZANHGYoP@mail.gmail.com \
--to=2clarkd@gmail.com \
--cc=gdb@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox