0

On a real device, running an iOS app, via Xcode the following lldb commands output to the Xcode console as expected:

(lldb) exp (void)NSLog(@"hello from NSLog");
(lldb) exp (int)printf("hello from printf");

On a real device + Terminal, these commands send no output to the screen. Even if you flush the screen (as recommended here: How can I see printf output when evaluating an expression using the `expr` command in lldb?).

Am I missing a lldb settings command or environment variable?

That said, on a real iOS device + Terminal you can still use the python-lldb scripting commands:

(lldb) script print("hello")
hello

PS - I tried with both zsh and a default bash terminal.

Cœur
  • 37,241
  • 25
  • 195
  • 267
rustyMagnet
  • 3,479
  • 1
  • 31
  • 41
  • 1
    How are you launching the process in the "iOS device + Terminal" case? If you are finger launching and then attaching, stdout is already diverted to the Console log, and lldb can't see it. – Jim Ingham Dec 06 '18 at 20:05
  • Ah hah! I can see NSLog message in Console.app. When launching lldb I tried `process attach --pid 123`, `-waitfor my_app` and then specifying `LLDB_SDK=ios lldb....` and `settings set target.env-vars DEBUG=1` – rustyMagnet Dec 07 '18 at 09:04
  • Since you are attaching, this is the same question as: https://stackoverflow.com/questions/29106019/xcode-attach-to-process-doesnt-display-nslog – Jim Ingham Dec 07 '18 at 18:25
  • @JimIngham is there a way to launch lldb to receive stdout ? Otherwise I have to open console.app on macOS to check whether my expression statements have worked. – rustyMagnet Dec 12 '18 at 15:16
  • lldb has options to control where stdout goes when it is the one that launches the process. But when you attach, stdout is already hooked up somewhere else. There isn't a really good way to divert stdout mid-run. So if you can use Xcode to launch the process this should just work. If you have to attach to an already running process, there isn't a good way to do this. – Jim Ingham Dec 12 '18 at 20:43

0 Answers0