Debugging - Finding where Error statement in log is coming from [duplicate] - objective-c

I'm not sure if this is possible. Here is an example situation:
Something is printing to my console and I don't know where it is coming from in the code. I did a quick search using the Finder in Xcode on terms such as 'NSLog' and 'print'. Nothing relevant came up.
Is there any quick way that Xcode has of finding where the source of the output is coming from ?
Kind of like when you right click on a method and you have all the options of exploring different parts of the code associated with that method.
Also: are there other functions that print besides NSLog and print?
Thanks so much!

Try running in the debugger, with breakpoints set on printf, NSLog, etc. When you hit a breakpoint do a backtrace (bt) to see where it's being called from

There's a plugin LinkedLog for that. You replace all NSLogs with LLogs and then will be able to just tap on link in Xcode's console to get to the line caused it to appear.
Didn't try it myself, but definitely will.

Related

Tips for debugging a Global.mpt

Short Question:
How do you debug a large Global.MPT file?
Currently my script crashes when I try to open it from the toolbar. It appears the usual, not very helpful, error message regarding the automation error. When this happens I start the individual components by pressing F5 in the VBA window and at the latest then I find the erroneous line.
Now my code runs as it should but I can't find the error that the compiler* has.
How do you deal with this problem?
*Is it a compiler error?
Found a Solution here.
I didn't know that you can compile the code manually.
It showed that i missed to remove a call for a deleted Sub.

Why the Console of Xcode10.1 can't display my input?

This bug was found after I updated to macOS Majove.
When I tried to do a small test on my Xcode, I found the console couldn't display the numbers that I typed but the numbers were truly read into memory.
And it still could work!
The amazing thing was when I changed the theme of the Xcode, it showed up!
My images will show the detail.
I think it's a bug of Xcode.
Is there any way to solve the problem?
I will be appreciated!
Thanks :)
=========================18/12/19UPDATED=================================
There's an another detail that the console will display my input the first time I run the program and it won't display later.
I found a temporary method to solve this issue. Just “printf” something before the “scanf” and the console will display the input. But it’s only a makeshift!

The code flow jumps without getting into any of the if-block

I edited this question, as now it seems it's not a coding issue. Might be something with IDE or something else.
I am using Flash Develop 4.5.2 right now.
I added a small check in the class, to test equality. But it's showing strange result.
A 1 min video on Youtube about the problem => http://youtu.be/wHXs7nwyhow
![The flow jumps without getting any of the if-block][1]
[1]: http://i.stack.imgur.com/aD3YM.png
Might be some special characters issue. So, pasted it on notepad, and saved it back as ".as", but still that part is skipped by debugger. No matter, whatever i write there. ( See video )
Vishwas
Seems like a bug. I checked OFF "Omit trace actions" in Flash IDE ( So as to receive the trace statements in the trace window now ). And it's working fine now. ( It seems like Flash Develop debugger, tries ignoring those pieces of code, that are related with trace() in such case.

Xcode debugger vs NSLog - dictionary keys and values

I'm trying to get better at using the debugger rather than just always printing my debugging message out via NSLog. This morning I thought I had a great use for it - to find how the changed values of a KVO dictionary. But when I set a breakpoint just after the appropriate code and ran with debugging on, all I saw in the debugger was this in the summary:
{(int)[$VAR count]} key/value pairs
and expanding the item never gets to any key or value.
But when I print out the "change" dictionary via NSLog I get the key and the value:
[timestamp] appName[3643:707] observeValueForKeyPath new filePath change: {
kind = 1;
new = foo;
I guess I have two questions:
Is there a way to get dictionary keys and values with the Xcode debugger?
Is there a set of rules of thumb for using the debugger vs printing log messages?
I'm (still) using Xcode 3.2.6.
Thanks!
EDIT: I realize that "foo" is not a valid file path. At this point I'm still testing sending a value around via KVO.
Set a breakpoint on the spot you want to check the value of the variable and run your application. When the breakpoint gets tripped put your mouse over the variable in the debugger. A little popup should come up, move your mouse over the arrows on the left side and another menu should popup. Click on "Print Description" and it should display something similar to a log in the console.
It is just a case by case method but a lot of it is just personal preference. You will just have to find what works for you.
If I am going to check a variable a lot at a one specific point, I will go with a log. It is usually the quickest way to see if something is working right
If I am checking how a part of the code affects a variable I will use the debugger and step through the code. It is also useful for checking the values of lots of variables in a section of code.
You can using a future set, which defenetely working in Xcode4
When u setup breakpoint, where is a option to don't stop execution of program and write to log anything what u want.
I'm not sure if it working well in Xcode 3 bcs I familiar with 4 but here is work.

Error connecting to SQLite from iPhone

My application shows this error
asm CPSqliteConnectionStatementForSQL 0x30897lb3:10
and it stopped at this breakpoint in debugger
0x308971cb <+0024> mov 0x8(%edi),%eax
Does someone know about it?
The assembly code won't tell most of us anything at all, and your question is pretty light on detail about the context in which the problem occurs, such as what your app is trying to do when it crashes, whether this is always reproducible, etc. If you post more information we'll be able to help you more.
If you're debugging in Xcode, trace back up the call stack until you reach your code, then set a breakpoint there and debug your program again. When it stops at that point, try examining the related variables and see if they have the values you expect.
Edit: At the request of the asker, here is a slight clarification. When it stops at a breakpoint, the Xcode debugger window will look something like this: (from this section of Apple's Xcode Debugging Guide)
http://developer.apple.com/documentation/DeveloperTools/Conceptual/XcodeDebugging/art/debugger_disassembly.jpg
The stack frames are shown in the upper-left rectangle, and you can click on a row in the table to jump to that point in the code. Grayed-out lines are those that do not have viewable source code available. Scroll down until you see a line with black text and click on it. This will show you the point at which execution left your code and entered third-party code, and you can then examine variables to get a better idea about what the problem may be. If you have further questions, I highly recommend reading through the debugging guide linked above.