Xcode project no longer displays std :: string in debugger

I have an Xcode project that will not display std :: string in C ++ when debugging. This is incredibly complicated because I have to resort to print statements or display each character one at a time in the LLDB console window, which is time consuming and difficult to read.

Every other person using the same project has the same problem, and other projects do not see this problem, so I think this is some kind of project. I am debugging and optimization is not enabled, so I fixed it as a problem. I also compared project settings between working projects and those who have this problem, and they seem to be the same in every way that they can be.

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

enter image description here

And this is what I get in the debug console if I check the string one character at a time:

enter image description here

I heard that switching back to GDB from LLVM may solve the problem, but GDB gave me other problems with debugging certain data types, so in this case I will have new problems.

+4
source share
4 answers

My employee found out how to fix this: turn off the Guard Malloc option in the scheme settings.

  • Click on the diagram that shows the problem.
  • Click "Edit Schema"
  • Click Diagnostics
  • Uncheck the Enable Guard Malloc box.

Now std :: string should appear. We donโ€™t know why this is so, it may be a bug in Xcode, but I think it would have been noticed some time ago. In addition, it was tested on several projects and allowed Guard Malloc to always cause std :: strings to not display properly in the debugger.

+4
source

Try this lldb command

 exp -fs -- myString 

You tell lldb to show the expression of your string in c String format

0
source

It may not have caused a problem with the original poster, but it caused mine: I used Xcode 6.4, while most of the code was built with 6.2. Switching to 6.2 made the values โ€‹โ€‹visible in the debugger.

0
source

Try this command

po string_name

0
source

Source: https://habr.com/ru/post/1498463/


All Articles