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]

Re: Use debug registers directly in programs?


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.


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