Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Xcode project won't display std::string in debugger anymore

I have an Xcode project that will not display C++ std::strings when I am debugging. It's incredibly frustrating because I am having to resort to print statements or outputting each character one at a time in the LLDB console window, which is time consuming and hard to read.

Every other person using this same project is having the same problem, and other projects are not seeing this problem, so I would think that this is a project setting of some kind. I'm in debug and there are no optimizations turned on, so I've eliminated that as the issue. I've also compared project settings between working projects and the one with this problem and they appear identical in every way that they can be.

Here's a sample of the output I get, *_M_p in this example is correct, the first character of the string is a question mark:

enter image description here

And here's what I get in the debug console if I inspect the string one character at a time:

enter image description here

I've heard that switching back to GDB from LLVM might solve the problem, but GDB gave me other issues with debugging certain data types, so I'll just have new problems in that case.

like image 461
Nic Foster Avatar asked Aug 22 '13 18:08

Nic Foster


1 Answers

My co-worker figured out the fix for this: Turn off the Guard Malloc option in the scheme settings.

  • Click the scheme that is exhibiting the problem
  • Click on Edit Scheme
  • Click on Diagnostics
  • Uncheck the 'Enable Guard Malloc' option.

Now std::strings should be showing up. We don't know why this is the case, it may be a bug in Xcode, but I would think it would've been spotted awhile ago. Also, this was tested on multiple projects and enabling Guard Malloc always causes std::strings to not show up properly in debugger.

like image 137
Nic Foster Avatar answered Oct 08 '22 17:10

Nic Foster