Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Send Ctrl-C to app in LLDB

I have an CLI app that is seg faulting during termination (After sending a Ctrl-C)

Pressing Ctrl-C in lldb naturally pauses execution.

Then I try: (lldb)process signal SIGINT (lldb)process continue

But that doesn't actually seem to do anything to terminate the app.

Also tried: (lldb)process signal 2

like image 916
orb360 Avatar asked Aug 21 '14 15:08

orb360


2 Answers

The debugger uses ^C for interrupting the target, so it assumes that you don't actually want the ^C propagated to the target. You can change this behavior by using the "process handle" command:

(lldb) process handle SIGINT -p true

telling lldb to "pass" SIGINT to the process.

If you had stopped the process in lldb by issuing a ^C, then when you change the process handle as shown here and continue, that SIGINT will be forwarded to the process.

If you stopped for some other reason, after specifying SIGINT to be passed to the process, you can generate a SIGINT by getting the PID of the debugee using the process status and send a SIGINT directly to said process using platform shell:

(lldb) process status 
(lldb) platform shell kill -INT {{PID from previous step}}
(lldb) continue
like image 70
Jim Ingham Avatar answered Sep 28 '22 11:09

Jim Ingham


The easiest way I found was just to send the process a SIGINT directly. Take the pid of the debuggee process (which process status will show you) and run

kill -INT <pid>

from another terminal.

like image 32
nneonneo Avatar answered Sep 28 '22 12:09

nneonneo