The behavior you’re seeing is the result of not knowing the function declaration for the symbol printf, which results in the LLDB _expression_ evaluator trying to guess and getting it wrong. Specifically, the inferred calling convention for the case you cite is that of function that takes two parameters (a string followed by an unsigned int) whereas the reality is that printf is a variadic function that takes an arbitrary number of parameters. This isn’t a problem on x86 where the calling conventions happen to be identical for these two cases, but on arm64 the distinction matters.
You can add definitions for functions like printf that you intend to use as follows:
1. Edit ~/.lldbinit to add the following line:
settings set target.expr-prefix ~/.lldb-expr-prefix
2. Create the file ~/.lldb-expr-prefix with the following content:
extern “C” { int printf(const char * __restrict, …); }
3. Restart the debug session
This results in every _expression_ implicitly including the appropriate function declaration for printf(), which has the pleasant side effect of eliminating the need to cast the results of the call. The same technique can be extended to any declaration that you find yourself needing on a regular basis. The only downside to doing so is the potential for getting two conflicting definitions, one derived from debug information and the other from your _expression_ prefix.
Xcode Runtime Analysis Tools
On Nov 17, 2014, at 12:04 PM, Beinan Li < email@hidden> wrote:
Hello Xcode,
I used to use breakpoint action: """ expr (int) printf("X is: %u\n", x)
"""
to print out local variables.
Now with Xcode 6.1 on an ARM64, I just get all sorts of wrong values.
For example:
code:
unsigned int x = 10800;
The above debug action gives me:
What am I missing here?
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden
|