gdb
[Top][All Lists]
Advanced

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

Re: How gdb accesses another process variable


From: Charles Manning
Subject: Re: How gdb accesses another process variable
Date: Wed, 21 Apr 2010 08:40:06 +1200
User-agent: KMail/1.9.10

On Tuesday 20 April 2010 08:49:59 CygwinUser wrote:
> Hi,
>
> I see the feature provided by gdb, that we can set a variable (using set
> command) for a running process
> through gdb. Can any one tell me how can gdb (as a process) could access
> the variables of other process.
> I guess its more of a OS related doubt. Please let me know. Thanks.

You can do this in *nix (Linux etc) and I guess cygwin too through the attach 
command.

The gdb attach command lets you attach to a running process.

eg.

Start  ./foo running in one terminal.

In another terminal
$ ps -ef
note down process number of the process you want. Let's say 12345.
$ gdb ./foo
(gdb) attach 12345
(gdb) 
at this point  you have attached to the process and stopped it and can debug, 
single step etc just like any other debugged process.
Let's set var to 10.
(gdb) p var=10
You can then detach from the process with
(gdb) detach




reply via email to

[Prev in Thread] Current Thread [Next in Thread]