* Sending signal to inferior program.
@ 2011-06-06 17:32 logitech
2011-06-06 18:18 ` Jan Kratochvil
0 siblings, 1 reply; 4+ messages in thread
From: logitech @ 2011-06-06 17:32 UTC (permalink / raw)
To: gdb
Hi, I am currently working with the gdb source code. I wish to send a signal
to the inferior program at a specific time. I tried forking a thread in
gdb.c which sends signal to the inferior process. To get its pid, I declared
an extern variable shared between gdb.c and linux-nat.c
But this gives a seg fault. Also the signal doesn't seem to get delivered.
In linux-nat.c
if (debug_linux_nat)
fprintf_unfiltered (gdb_stdlog, "linux_nat_wait: [%s]\n",
target_pid_to_str (ptid));
gpid=ptid.pid; // gpid gets the pid value, the signal is sent to gpid
from gdb.c
Moreover when i debug this with flag set, gpid initially gets the value of
pid of inferior, but later it becomes -1.
Is there any other way in which I can accomplish this.
Thanks
--
View this message in context: http://old.nabble.com/Sending-signal-to-inferior-program.-tp31785488p31785488.html
Sent from the Sourceware - gdb list mailing list archive at Nabble.com.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Sending signal to inferior program.
2011-06-06 17:32 Sending signal to inferior program logitech
@ 2011-06-06 18:18 ` Jan Kratochvil
2011-06-06 20:25 ` logitech
0 siblings, 1 reply; 4+ messages in thread
From: Jan Kratochvil @ 2011-06-06 18:18 UTC (permalink / raw)
To: logitech; +Cc: gdb
On Mon, 06 Jun 2011 19:32:13 +0200, logitech wrote:
> I wish to send a signal to the inferior program at a specific time.
I do not know how is GDB related to it. Cannot you just write an independent
C program which will wait till that time and call kill (thatPID, SIGsome)?
From GDB when you stop the inferior first (CTRL-C) you can send a signal:
(gdb) help signal
Continue program giving it signal specified by the argument.
An argument of "0" means continue program without giving it a signal.
Regards,
Jan
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Sending signal to inferior program.
2011-06-06 18:18 ` Jan Kratochvil
@ 2011-06-06 20:25 ` logitech
2011-06-06 21:03 ` Jan Kratochvil
0 siblings, 1 reply; 4+ messages in thread
From: logitech @ 2011-06-06 20:25 UTC (permalink / raw)
To: gdb
Thanks for the reply, but i'm still a little confused. Isn't what you said
the same thing as forking a thread from gdb which sends the signal. Instead
of CTRL-C, I want the signal to be sent from gdb to the prog. I want to
actually break the execution of the program at a specific time, so to send
the signal to the program at say 100ms.
Thanks again
Jan Kratochvil-3 wrote:
>
> On Mon, 06 Jun 2011 19:32:13 +0200, logitech wrote:
>> I wish to send a signal to the inferior program at a specific time.
>
> I do not know how is GDB related to it. Cannot you just write an
> independent
> C program which will wait till that time and call kill (thatPID, SIGsome)?
>
> From GDB when you stop the inferior first (CTRL-C) you can send a signal:
> (gdb) help signal
> Continue program giving it signal specified by the argument.
> An argument of "0" means continue program without giving it a signal.
>
>
>
> Regards,
> Jan
>
>
--
View this message in context: http://old.nabble.com/Sending-signal-to-inferior-program.-tp31785488p31786813.html
Sent from the Sourceware - gdb list mailing list archive at Nabble.com.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Sending signal to inferior program.
2011-06-06 20:25 ` logitech
@ 2011-06-06 21:03 ` Jan Kratochvil
0 siblings, 0 replies; 4+ messages in thread
From: Jan Kratochvil @ 2011-06-06 21:03 UTC (permalink / raw)
To: logitech; +Cc: gdb
On Mon, 06 Jun 2011 22:25:16 +0200, logitech wrote:
> the same thing as forking a thread from gdb
BTW GDB is not thread safe so the forked thread must not modify anything of
GDB, that is it is easier to just fork() from GDB, which is mostly the same as
running a completely separate program - for example by the GDB `shell'
command.
> Instead of CTRL-C, I want the signal to be sent from gdb to the prog. I want
> to actually break the execution of the program at a specific time, so to
> send the signal to the program at say 100ms.
Maybe like this way?
cat >x <<EOH
set target-async on
set non-stop on
set pagination off
file sleep
run 1h &
define break-in-1sec
shell date --iso=seconds; sleep 1s; date --iso=seconds
interrupt
end
info threads
EOH
gdb -x ./x
GNU gdb (GDB) 7.3.50.20110605-cvs
Copyright (C) 2011 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-unknown-linux-gnu".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Id Target Id Frame
* 1 process 6427 "sleep" (running)
(gdb) break-in-1sec
2011-06-06T23:01:03+0200
2011-06-06T23:01:04+0200
(gdb)
[process 6427] #1 stopped.
0x00007ffff7aeccd0 in __nanosleep_nocancel () at ../sysdeps/unix/syscall-template.S:82
82 T_PSEUDO (SYSCALL_SYMBOL, SYSCALL_NAME, SYSCALL_NARGS)
bt
#0 0x00007ffff7aeccd0 in __nanosleep_nocancel () at ../sysdeps/unix/syscall-template.S:82
#1 0x0000000000403c58 in rpl_nanosleep (requested_delay=0x7fffffffdc20, remaining_delay=0x0) at nanosleep.c:93
#2 0x00000000004032c5 in xnanosleep (seconds=<optimized out>) at xnanosleep.c:111
#3 0x0000000000401416 in main (argc=<optimized out>, argv=<optimized out>) at sleep.c:147
(gdb) info threads
Id Target Id Frame
* 1 process 6427 "sleep" 0x00007ffff7aeccd0 in __nanosleep_nocancel () at ../sysdeps/unix/syscall-template.S:82
(gdb) _
If one runs that break-in-1sec directly from the ./x script it does not work, I
have filed for it:
http://sourceware.org/bugzilla/show_bug.cgi?id=12850
Regards,
Jan
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2011-06-06 21:03 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-06-06 17:32 Sending signal to inferior program logitech
2011-06-06 18:18 ` Jan Kratochvil
2011-06-06 20:25 ` logitech
2011-06-06 21:03 ` Jan Kratochvil
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox