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: Group
Subject: Re: How gdb accesses another process variable
Date: Tue, 20 Apr 2010 16:46:25 -0500

Hi, 
Thanks for the reply. But, my question is how does OS is taking care of giving access to gdb to access another process variables. There should be some sort of privileged access to gdb to access another process variables, which i would like to know more about. Thanks in advance.

On Tue, Apr 20, 2010 at 3:40 PM, Charles Manning <address@hidden> wrote:
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]