Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sending signals in LLDB

Tags:

signals

lldb

I'm using LLDB as a standalone debugger, and I was wondering if there is a way to send signals in LLDB, same way you can do it in GDB (i.e signal SIGINT)

like image 755
skittle Avatar asked Oct 12 '14 21:10

skittle


2 Answers

Look at the process signal and process handle commands. e.g. with a program like

#include <signal.h>
#include <stdio.h>
#include <unistd.h>

void handler (int in)
{
    puts ("signal handled");
}

int main()
{
    signal (SIGUSR1, handler);
    while (1) 
        sleep (1);
}

if I attach to this with an lldb in another window (so I can type commands to lldb while the process is running -- if I run this program under lldb, the input/output when the program is running will go to the program, not lldb), I can tell lldb to not stop process execution when I send a SIGUSR1 signal (its default is to stop execution so you need to continue it again) and I can send the signal. e.g.

(lldb) pro handle -s false SIGUSR1
NAME        PASS   STOP   NOTIFY
==========  =====  =====  ======
SIGUSR1     true   false  true 
(lldb) pro signal SIGUSR1
Process 6628 stopped and restarted: thread 1 received signal: SIGUSR1

and I'll see signal handled output in the other window, showing that my signal handler was called.

like image 177
Jason Molenda Avatar answered Oct 23 '22 09:10

Jason Molenda


Try process signal <signal>.

like image 21
f1rewatch Avatar answered Oct 23 '22 10:10

f1rewatch