3

Let us say that I have a function in a C program test.c like this:

#include <stdio.h>
char* foo = "test";
void print_foo(void)
{
    printf("%s", foo);
}
main() {  }

I compile and run test.c like this:

gcc -g -o test test.c
chmod 755 test && lldb -s <(echo "b main\nr") test

However, if I then run expr print_foo() no string output occurs:

(lldb) expr print_foo()
(lldb)
Lenar Hoyt
  • 5,971
  • 6
  • 49
  • 59

1 Answers1

3

STDOUT is line buffered. You haven't emitted a newline yet. Try calling (lldb) expr (void) fflush(0)

and you should see the output. Or have foo be "test\n".

Jim Ingham
  • 25,260
  • 2
  • 55
  • 63