* Use debug registers directly in programs?
@ 2007-04-03 7:13 Wang Yi
2007-04-03 7:32 ` Mathieu Lacage
0 siblings, 1 reply; 3+ messages in thread
From: Wang Yi @ 2007-04-03 7:13 UTC (permalink / raw)
To: gdb
Hi, all
gdb is a general purpose debugger, it's very strong.
But on some specific conditions, somebody would like to provide a
mechanism to let the program debug itself. I mean to provide a subset
function of gdb's, such as only use CPU debug registers to set
watchpoints.
I think combining with code instrumentation, this mechanism will
partially fulfill auto-debug function and save our time.
The questions are:
1. Is that feasible to use debug registers in the programs to
debug themselves? I think yes, any confirm?
2. How to use the debug registers? The IA32 manual talks about
these registers but doesn't tell how to use them, the gdb internals
covers many areas but it is too complex for those who have not written
or read a debugger before. Should I read the gdb source?
Leo
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Use debug registers directly in programs?
2007-04-03 7:13 Use debug registers directly in programs? Wang Yi
@ 2007-04-03 7:32 ` Mathieu Lacage
2007-04-03 19:52 ` Michael Snyder
0 siblings, 1 reply; 3+ messages in thread
From: Mathieu Lacage @ 2007-04-03 7:32 UTC (permalink / raw)
To: Wang Yi; +Cc: gdb
On Tue, 2007-04-03 at 15:13 +0800, Wang Yi wrote:
> 1. Is that feasible to use debug registers in the programs to
> debug themselves? I think yes, any confirm?
> 2. How to use the debug registers? The IA32 manual talks about
> these registers but doesn't tell how to use them, the gdb internals
> covers many areas but it is too complex for those who have not written
> or read a debugger before. Should I read the gdb source?
The only way I know of to set the debug registers is to use ptrace and a
program cannot ptrace itself so, you will always need a third-party
program if only to control the debug registers on your behalf.
Mathieu
--
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Use debug registers directly in programs?
2007-04-03 7:32 ` Mathieu Lacage
@ 2007-04-03 19:52 ` Michael Snyder
0 siblings, 0 replies; 3+ messages in thread
From: Michael Snyder @ 2007-04-03 19:52 UTC (permalink / raw)
To: Mathieu Lacage; +Cc: Wang Yi, gdb
On Tue, 2007-04-03 at 09:30 +0200, Mathieu Lacage wrote:
> On Tue, 2007-04-03 at 15:13 +0800, Wang Yi wrote:
>
> > 1. Is that feasible to use debug registers in the programs to
> > debug themselves? I think yes, any confirm?
> > 2. How to use the debug registers? The IA32 manual talks about
> > these registers but doesn't tell how to use them, the gdb internals
> > covers many areas but it is too complex for those who have not written
> > or read a debugger before. Should I read the gdb source?
>
> The only way I know of to set the debug registers is to use ptrace and a
> program cannot ptrace itself so, you will always need a third-party
> program if only to control the debug registers on your behalf.
Yes, instructions to access the debug registers are almost always
privileged instructions. User programs cannot use them. Even gdb
cannot access them directly, it has to ask the Kernel to do it.
Hence the ptrace interface, and as Mathieu says, a program cannot
ptrace itself.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2007-04-03 19:52 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-04-03 7:13 Use debug registers directly in programs? Wang Yi
2007-04-03 7:32 ` Mathieu Lacage
2007-04-03 19:52 ` Michael Snyder
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox