Re: How to read register values

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 8/12/05, Erik Mouw <J.A.K.Mouw@xxxxxxxxxxxxxx> wrote:
> On Fri, Aug 12, 2005 at 09:06:22PM +0700, Nguyen Anh Phu wrote:
> > On 8/12/05, Erik Mouw <J.A.K.Mouw@xxxxxxxxxxxxxx> wrote:
> > > On Fri, Aug 12, 2005 at 08:53:36PM +0700, Nguyen Anh Phu wrote:
> > > > if I don't use kernel module, how do I read registers of threads in
> > > > current process?
> > >
> > > In userland you could use gdb.
> > >
> >
> > Is there anyway to read them inside the program?
> 
> With some inline assembly. On x86, you could try something like:
> 
>   int cs_val;
> 
>   asm("mov %%cs, %0": "=r"(cs_val));
> 
> I haven't tested this, so I have no idea if I have the inline assembly
> syntax correct.
> 
> BTW, this kind of stuff is not useful from within a program. A running
> program will modify its own registers. Why do you think this can be
> useful for you?
> 

Oh, of course I don't want to modify registers from within program, in
fact, I want to monitor stack usage of my program, so I want to read
esp register and compare it with start address of stack. Is there a
"non-asm" way to do?

Regards,

-- 
Phu

--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
FAQ:           http://kernelnewbies.org/faq/



[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux