10

I'd like to have the following command init my .lldbinit.

process handle SIGPROF -n false -p true -s false

The problem is that lldb won't run this command when it starts up and doesn't yet have a process.

error: Aborting reading of commands after command #1: ' process handle SIGPROF -n false -p true -s false' failed with error: No current target; cannot handle signals until you have a valid target and process.

How can I tell lldb to apply this command whenever it does have a process?

Praxeolitic
  • 22,455
  • 16
  • 75
  • 126

2 Answers2

2

As of right now, I don't think you can

Allowing this would require one of two things:

  • a model where LLDB records your preferences and applies them to processes as they come about (only the first one? all of them?)
  • a model where LLDB has "event hooks" for things like a process has shown up, a process has gone away, and you could script the hook (via LLDB commands or Python) to perform certain actions, including setting signal handling
Enrico Granata
  • 3,303
  • 18
  • 25
2

One workaround for this is to take the set of commands you want to run in lldb after the file you are debugging is loaded, put them in a file, and run:

$ lldb -s <command file> <FileToBeDebugged>

Then if you like this and use it often, you can make a shell alias of part up to .

If you are using Xcode, a common trick is to set a breakpoint at main in your project, put the commands you want to run there, and then make it "auto-continue".

Jim Ingham
  • 25,260
  • 2
  • 55
  • 63
  • Oh of course, I hadn't thought of the auto-continue, great idea. – Praxeolitic Sep 17 '14 at 22:15
  • didn't work for me on lldb 6.0.0: after writing `Executing commands in ...` it fails with `error: No current process; cannot handle signals until you have a valid process.` when my command is `process handle --stop false --notify false SIGUSR1 SIGUSR2` – V-R Aug 01 '19 at 12:14