This is the mail archive of the gdb@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Hacking gdbserver to capture instruction-level code coverage


Hi,

I have attempted to hack gdbserver 6.5 to log
instruction-level code coverage on a powerpc-linux
system and it seems to work except that examining
variables is broken as a result.  Turning on remote
debugging in gdb and comparing a run using an
unmodified gdbserver and the modified gdbserver seems
to show a difference with the DBAT0 register mapping
in the 'g' packet responses.  It would seem that my
changes have somehow violated something and perhaps
has confused the Linux kernel?

More specifically, I have changed handle_v_cont() in
server.c to do a repeated single step rather than a
continue.  I let the resume_info get built as usual
(and only once), except in the 'c' or 'C' case where I
set resume_info[i].step=1 (since we'll be stepping
repeatedly instead).  Then, at the bottom of the
function, I loop repeatedly, resuming the inferior,
waiting for it to stop, getting the PC of the inferior
and logging it, and then determining whether to repeat
or break out of the loop (based on whether we are
single stepping, continuing or there's a breakpoint at
the current PC location).  After the loop, I free the
resume_info and prepare the resume reply as usual.

Does any of this sound particularly evil?  I can
provide the small patch against the 6.5 source if
anyone needs to see the changes in more detail.

Thanks!
Ron McCall


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]