When stepping through a loop, NSLog(#"%d",intvar) shows the intvar is increasing, but hovering over it still shows 0. Here, the intvar is 8 and the breakpoint has been triggered, but the debugger displays 0.
Is there some debug flag to set somewhere in the project or target? When I debug, I want to be able to see the current value of any variable or object. But XCode doesn't have an easily settable "debug mode compile" or watches, like standard IDEs do.
Sometimes it doesn't even show a value for an integer, but just the name.
The Local pane is also still at 0, and sometimes it doesn't show a value at all.
All the variables' scope is method-wide, and I'm only debugging inside this method.
Is there a setting to make debugging work in Xcode or is it a bug?
Even I have XCode 4.6, and it worked fine for me, Check the screenshot.
You must have changed some setting,
**Wait for a while, trying to resolve*
Related
I am a beginner C programmer. Currently, I have Visual Studio version 1.61 September 2021 installed
on my windows 64-bit system. I also installed MingW64 and set up the environment variables to compile and debug with the purpose of writing, debugging and running my c programs.
I have been able to write and run my programs without any issues. I did notice that whenever I wish to debug my program, the debug toolbar that hovers on top has the buttons disabled and no line is pointed by the "yellow arrow".
I modified the "launch.json" file where I set the following:
"stopAtEntry": true,
This set the yellow arrow to point at the beginning of the program instead of the breakpoint and the debug toolbar buttons were activated. Though whenever I step-over on to the next line of code, the yellow arrow disappears and the debug toolbar buttons are deactivated once again.
This happens often on lines where I assign values to variables.
I am a beginner and I find VS Code quite frustrating, I would appreciate your input and suggestions. Thanks
UPDATE: I solved it.
So it turns out that there is nothing wrong with my debugger and it was behaving as it should. I noticed that it would always fall into that behavior whenever the gcc compiler was to execute the line including scanf(). The registers and variables in the watchlist would suddenly become "unavailable" this is because the compiler was waiting for user input.
Since VS Code did not show the running program on PowerShell, I modified the "launch.json" certain configurations to the following:
"externalConsole": true,
This allows for Command Prompt to open up, display the running program and allows for user input.
Once the user input is received the debug toolbar buttons are activated again and I could continue debugging. The watchlist variable also become available to analysis.
"stopAtEntry": false,
I set this configuration to false because I did not wish for the debugger to begin at the beginning of the program.
This was certainly frustrating but after finding the solution to this "issue", I bet that my endorphin and oxytocin levels are off the charts.
Very thrilling, this is what I love the most about problem solving.
I don't know what has changed on my setup, but it used to be that when my (Swift) code crashed, the debugger would show the offending line of source code.
Now no matter what the problem is, the debugger only highlights the line in AppDelegate.swift where UIApplicationMain is defined.
I can tell by putting in print statements more or less where in the code the problem arose, however... what's the point of having a debugger if it never conveys any information and I just have to do everything "old school" with print statements -- especially if there are asynchronous processes going on in which the print statement isn't necessary a reliable indicator of where the crash occured?
I've seen threads from years ago that talk about going into "Preferences -> Behaviors" and modifying what gets shown when the code exits unexpectedly. But (a) I never needed this in the past, and more importantly (b) this seems to have no effect, i.e. the debugger is still just quitting on main.
Is there a good way to get the old, specific, debugging behavior back?
I'm currently running Xcode 7.0, but this behavior occurs with 7-GM Seed, and even now when I go back to try 7 beta 5 and beta 6, which used to work.
Go to the Debug Navigator (cmd-7), click the plus button in the bottom and select Add Exception Breakpoint. This will break at the actual line where the problem happened.
In the exception breakpoints detail editor create debugger command action and in the text box enter po $arg1. This will show the error message in the debug console.
The previous answer was on the right track, but this answer is more relevant today:
On Xcode 9.2 with Swift 4, do this:
Use Command-8 to bring up the Debug Navigator.
Click the + in the lower left
Select Swift Error Breakpoint
That's it! :)
I am developing a Mac application in Xcode 6.2 with Swift.
All my global variables and enumerations are in a separate swift file Globals.swift. The program so far works as expected.
But I am unable to see this global variables in the debug window. On the lower left of the debug window I selected All. I see outlets, local variables, but no global variables!
What do I have to change to see them?
This seems to be an issue with Xcode since some versions.
One way is to see the global variables by issuing the below command in the right hand debugger window
(lldb) target variable variableName
OR
(lldb) ta v variableName
Environment: Xcode Version 5.0.1 (5A2034a)
Scenario:
1) I've create a simple Apple-supplied iOS project template.
2) I create a local string value with an initial value; plus a local integer variable with value.
3) I did a debug 'po' & 'p' for the object and integer.
Xcode's debugger apparently doesn't see these values.
The following are a couple of snippets of the debugger's environment:
As you can see, the debugger's symbol-generator is ON and the optimization is set to NO (zero).
1) Here's another example.
Note: NSLog() does work.
Notice the 'Turkey' for 'testString' value. Why this value?
'Turkey' was used in ANOTHER project and has no relevance to this one sample project.
It appears that I'm getting variable bleed from some xcode environment peculiar to Xcode 5;
...not found/experienced in Xcode 4.
Okay, this is weird. I've tried the NSLog() and got the values displayed. Then just for kicks I did a 'po' again and got the correct value.
However I still have the 'Turkey' value:
2) Here's a second example.
Starting with a new application from the Apple-supplied view template:
This time, the NSLog() works but again, can't get the 'po' value.
I still haven't figured out the pattern here.
What else can I do?
How can I get my debugger 'po' & 'p' commands to show data?
Or... why am I'm getting inconsistent debugger behavior (Xcode5 appears to work okay; re 'NSLog()')?
I had this recurrent problem so I tried logging via a different account to find the problem disappeared.
So there's something wrong with my Xcode account; specifically:
So I emptied the Xcode folder found under ~/Library/Developer and restarted Xcode.
Apparently the problem(s) is/are solved.
In Visual Studio 2010 (Ultimate), is it possible to step through some code, and, if a variable is not correct (e.g. you want to get all records beginning with 'A' but there is none, so you want to try 'B' instead), is it possible to change the code while in debug mode, to do this (change variables while in debug mode)?
It is quite annoying to have to stop debugging, change a value, then debug again and see the result. It'd be much easier to do it all in debug mode, anyway.
Thanks
In the watch window just enter the statement you want executed. For example if you want to set the variable prefix to "B" then just type prefix = "B" and hit enter.
You may also change code while running, however there are a number of limitations to this feature. See Microsoft's Edit and Continue documentation for details: http://msdn.microsoft.com/en-us/library/bcew296c(v=vs.80).aspx.
In the Solution Explorer view, right-click on each reference of References, choose Properties. In the Properties view, sign False to the field of Embed Interop Types. This works for me.
c