|
From: Chris J. <ch...@at...> - 2004-08-30 09:49:31
Attachments:
valgrind-breakpoints.patch
|
The attached patch adds support for software breakpoints and single stepping
to the Valgrind core. These should be the only changes to existing parts of
the core that are required to support live debugging. Obviously this patch
doesn't add full debugging support in and of itself.
As a quick test the following program:
int main (void) {
__asm__ ("int $3");
return 0;
}
raises SIGILL on Valgrind CVS but SIGTRAP with this patch.
Chris January
---
2004-08-30 Christopher January <ch...@at...>
* coregrind/vg_constants.h: Add VG_TRC_EBP_JMP_BREAKPOINT macro.
* coregrind/vg_dispatch.S (dispatch_boring): Change dispatch_ctr
condition to dispatch_ctr <= 0 (jle).
(dispatch_exceptional): Increment dispatch_ctr on entry. Add check
for
VG_TRC_EBP_JMP_BREAKPOINT.
* coregrind/vg_from_ucode.c (load_ebp_from_JmpKind): Add case for
JmpBreakpoint.
(emit_code) Change dispatch_ctr condition to dispatch_ctr < 0
(CondNL).
* coregrind/vg_include.h: Add single_step and stopped members to
ThreadState type. Add single_step argument to VG_(disBB).
* coregrind/vg_scheduler.c: (name_of_sched_event)): Add case for
VG_TRC_EBP_JMP_BREAKPOINT.
(do_scheduler): When checking if a thread is runnable, also check
it is not stopped. Remove '+1' in assignment to VG_(dispatch_ctr).
Check if thread is in single step mode. Handle exit from base block
due to breakpoint and single step. Remove '-1' in assignment to
done_this_time. Add case for VG_TRC_EBP_JMP_BREAKPOINT.
* coregrind/vg_to_ucode.c (disInstr): Add case fo 0xCC (INT 3).
(VG_(disBB)): Add single_step argument. Add check for single_step
flag.
* coregrind/vg_translate.c (pp_UInstrWorker): Add JmpBreakpoint
case.
(VG_(translate)): Add extra argument to VG_(disBB) call.
* include/vg_skin.h: Define JmpBreakpoint.
--
http://www.atomice.com
|
|
From: Tom H. <th...@cy...> - 2004-08-30 10:00:41
|
In message <018301c48e76$a95bd730$0207a8c0@avocado>
"Chris January" <ch...@at...> wrote:
> The attached patch adds support for software breakpoints and single stepping
> to the Valgrind core. These should be the only changes to existing parts of
> the core that are required to support live debugging. Obviously this patch
> doesn't add full debugging support in and of itself.
>
> As a quick test the following program:
> int main (void) {
> __asm__ ("int $3");
> return 0;
> }
>
> raises SIGILL on Valgrind CVS but SIGTRAP with this patch.
You added a stopped flag to the thread state, and you test it in
several places but you never seem to set it to anything?
The reason I noticed that was that I was trying to see if there
was some reason for adding that flag rather than a new VgTs_Stopped
state that would indicate the same thing.
Tom
--
Tom Hughes (th...@cy...)
Software Engineer, Cyberscience Corporation
http://www.cyberscience.com/
|
|
From: Chris J. <ch...@at...> - 2004-08-30 11:14:22
|
> In message <018301c48e76$a95bd730$0207a8c0@avocado>
> "Chris January" <ch...@at...> wrote:
>=20
> > The attached patch adds support for software breakpoints and single=20
> > stepping to the Valgrind core. These should be the only changes to=20
> > existing parts of the core that are required to support live=20
> > debugging. Obviously this patch doesn't add full debugging=20
> support in=20
> > and of itself.
> >=20
> > As a quick test the following program:
> > int main (void) {
> > __asm__ ("int $3");
> > return 0;
> > }
> >=20
> > raises SIGILL on Valgrind CVS but SIGTRAP with this patch.
>=20
> You added a stopped flag to the thread state, and you test it=20
> in several places but you never seem to set it to anything?
>=20
> The reason I noticed that was that I was trying to see if=20
> there was some reason for adding that flag rather than a new=20
> VgTs_Stopped state that would indicate the same thing.
The stopped flag (like the single_step flag) would be set by the =
debugger.
The reason it's a seperate flag and not a new VgTs_Stopped state is that
when the debugger stops a thread it may be in any state (not just
VgTs_Runnable). When the debugger resumes the thread it needs to restore =
the
state to its previous value. The easiest way to do this is not to modify =
the
state at all and have separate flag.
Chris
|
|
From: Tom H. <th...@cy...> - 2004-08-30 11:21:17
|
In message <01b801c48e82$967ec6c0$0207a8c0@avocado>
"Chris January" <ch...@at...> wrote:
> > You added a stopped flag to the thread state, and you test it
> > in several places but you never seem to set it to anything?
> >
> > The reason I noticed that was that I was trying to see if
> > there was some reason for adding that flag rather than a new
> > VgTs_Stopped state that would indicate the same thing.
>
> The stopped flag (like the single_step flag) would be set by the debugger.
> The reason it's a seperate flag and not a new VgTs_Stopped state is that
> when the debugger stops a thread it may be in any state (not just
> VgTs_Runnable). When the debugger resumes the thread it needs to restore the
> state to its previous value. The easiest way to do this is not to modify the
> state at all and have separate flag.
Ah right. I thought the idea was that it would be set when a breakpoint
was hit but it's more general that.
Tom
--
Tom Hughes (th...@cy...)
Software Engineer, Cyberscience Corporation
http://www.cyberscience.com/
|