DerekSelander/LLDB

CFStringCreateWithBytes needed!

cclamb opened this issue · 4 comments

sbt-script-output.txt
Keep getting this when I run a variety of commands:

Error [IRForTarget]: Rewriting an Objective-C constant string requires CFStringCreateWithBytes

(this particular one comes from using sbt)

Wouldn't expect it to be a python 3-ism.

Sorry, was on a browser that didn't allow me to attach the text file. The file attached contains the obj-c code that's trying to run and the context of the sbt use.

When you use an NSString literal in an expression like @"test string", the expression parser creates a call to CFStringCreateWithBytes() to create that object in memory before it can run the expression, a function from CoreFoundation. lldb has not found the symbols to CF/CF itself in your process for some reason -- that's the issue here. image list will show the list of libraries loaded in your process, is CoreFoundation missing? Shouldn't be possible with any GUI app type program.

from lldb's perspective, you're asking to create a CFString/NSString in the expression before the library that is needed to create that is loaded. The error message is a little inside baseball, but I think failing is the correct response here. The fact that you're using a python command makes the failure a little less obvious - if you had typed the @"" string yourself, there's a better chance you'd be cognizant of what was happening.

Thank you @jasonmolenda for the explanation. Please do pass my regards on to the lldb team for such a great tool.

@cclamb, it sounds like for this situation, the sbt command would not be a good tool for your situation. The sbt command uses the Obj-C runtime to re-symbolicate stripped method names. It will not do anything to symbolicate stripped C/C++ code. If you are tracing code at module loading that doesn't have CoreFoundation loaded yet, this implies that the function was called via a __attribute__((constructor)) type of declaration (implying C/C++ code) and not a +[NSObject load]

You can quickly monitor these functions via the DYLD_PRINT_INITIALIZERS environment variable (see man dyld(1))

DYLD_PRINT_INITIALIZERS=1 /Applications/Safari.app/Contents/MacOS/Safari

From there, you can use LLDB to see if there's a name for the function using lldb. Use LLDB's image lookup -a 0xaddress_here or my info command (found in this repo)