iOS : Determine code based on console log - ios

I'm getting a console log 'Pin's dont match' (in this case). I've searched throughout project but didn't find any.
This may be generated by use of third party framework. By reading console how can I recoginse where the print() statment is?
There is pattern AppName[1234:1234334] printed on console. So, here the what does first and second value in square bracket mean?

Go to your Breakpoint navigator in XCode (⌘7)
Add a symbolic breakpoint (little plus down in the bottom left of the navigator)
Type in the symbol: "NSLog" (other fields can be left empty)
Run your application
If it doesn't work you can try for Swift.print and print commands that might also log to your console.

Related

Setting debugger breakpoints across all methods in an Xcode project

How do you trace all the methods invoked across different files in a particular user flow ?
Putting breakpoints at different points and observing the backtrace does not seem like the most efficient way.
Instead I would like to -
1) Put a breakpoint across all methods in the interested project.
2) Make all the breakpoints run a debugger command which prints out the file name and method name.
3) Edit the breakpoints such that the program continues to execute after a breakpoint is hit. (This option is available when you edit a particular
breakpoint.) So we don't stop at any breakpoint.
4) Disable all the breakpoints until I reach the flow I need to work on.
5) Enable all the breakpoints right before starting the flow.
With this approach, we don't have to manually put breakpoints at different places to understand the execution flow. Once the flow is complete, I can just look at the debugger console and figure out the execution flow.
Now, the question -
How can we do this using lldb commands?
Would appreciate any input/suggestions.
You can't do this with the Xcode breakpoint interface, but in the lldb console you can do:
(lldb) break set -r . -s AppName
Breakpoint 1: 478 locations.
(lldb) br com add
Enter your debugger command(s). Type 'DONE' to end.
> bt
> continue
> DONE
(lldb)
That sets a "symbol name match regular expression breakpoint" on all names ("." matches everything) in the binary/shared library called AppName. If you leave off the -s option, it will match all symbols everywhere. That will work but quite slowly...
The command prints a backtrace and continues.
This makes just ONE breakpoint, so you can do:
(lldb) break disable 1
Till you need it, and then enable it with:
(lldb) break enable 1
If you only want to catch some methods, you can adjust the regular expression, and if you find you aren't interested in some of the places you are hitting, you can individually disable locations within the breakpoint you've made this way.
(lldb) break list 1
Will show you all the locations, and:
(lldb) break disable 1.2-1.10 1.15
etc. will disable the locations.
This might get a little slow, because your app will be starting & stopping all the time. But it will do what you are asking.
You can put breakpoints on all methods in different files, and to trace how execution happens within that method click on Stepover.
Step over - shortcut - f6, it stops execution at next loc.
Also alternatively you can check value of particular variable or array by typing "po VariableName" in output window.
you can add related methods name through adding the symbol exception breakpoints.

Difference Between Debugger and Target Output in Xcode

When I run my app in Xcode, the output area often becomes cluttered by warnings, in my case especially from iAds. Since I'm only interested in my own debug statements, is there a way to specifically output what I want to see?
I notice there's an option to show either "Debugger Output" or "Target Output." What is the difference between these and can they help with what I'm trying to do?
Another solution would be to block warnings from iAds, autolayout, etc., if that is possible. Is there a way to suppress specific warnings?
What hv88 is saying is that "Debugger output" is the text that comes from the lldb commands you've typed into the console, and "Target Output" is everything that your program writes to stdout. The debugger has no way to tell the difference between "text YOUR code writes to stdout" and "text other libraries write to stdout." It is just one output stream. So that set of choices won't help you with what you want to do.
Note that the console window does have a Find entry, though you won't see it till you type Cmd-F when focused on the console window. So if you mark your output entries with some string that is unique and not to hard to type, you can use the Console Find to navigate to them quickly.
'Debugger output' contains values that we check while debugging i.e. while debugging we check the value of variable. This value can be printed on console by clicking 'i' button on pop-up shown.
'Target output' contains values printed from NSLog, cout, println etc.
'All output' contains values from Debugger and Target.
The console displays program output and lets you enter commands to the debugger. You specify the type of output the console displays with the pop-up menu at the top of the pane:
All Output: Include target and debugger output.
Debugger Output: Include debugger output only.
Target Output: Include target output only. (e.g NSLog, printf)
https://developer.apple.com/library/mac/recipes/xcode_help-debugger/articles/about_debug_area.html

class EVariantTypeCastError with message 'Could not convert variant of type (String) into type (Double)

Using Delphi and FastReport I get this error message while debugging inside Delphi immediately after this line:
<FastReport_Component>.ShowReport(true);
Then this error appear:
Project myapp.exe raised exception class EVariantTypeCastError with message 'Could not convert variant of type
(String) into type (Double)'.
It appears twice before displaying the report. but if I run myapp without debugging no error message appear.
How I can find which memo cause this error ? the report has so many memos. some has also expressions inside using IIF and the error message does not display any more info.
This is just the debugger. It's probably just getting an expected error (one handled by a try..except in the FR code) and properly dealing with it, but the debugger has no way of knowing that and tells you the exception happened. (It's a common issue when working with Indy, which raises exceptions as part of normal program flow.)
There are three ways to deal with this situation when debugging:
Just hit Continue on the exception dialog when it appears. (You can tell it's a debugger exception because you get the Break or Continue option, and because it only happens when debugging.)
You can disable a specific exception class (or all exceptions) when debugging, using the Tools->Options->Debugger Options. In this case, you can add EVariantTypeCastError to the list of exceptions to ignore.
(My preferred method) Use the Advanced Breakpoint Properties dialog to skip the debugger's exception handling around the specific line of code you know will raise the exception you want to ignore.
Set a breakpoint on the line immediately before the problem code line.
Right-click the breakpoint on the line before, and choose Breakpoint Properties from the context menu.
Click the Advanced button on the Breakpoint Properties dialog, and in the Actions groupbox, uncheck Break and check Ignore subsequent exceptions.
Repeat the previous steps on the line after the problem code, except check Break and uncheck Ignore subsequent exceptions on this second breakpoint.
Run your code as usual. The debugger will skip it's exception handling on the code between the two breakpoints.
The advantage of option #3 is that it ignores all exception handling, but only on the code block between the two breakpoints, so you still get exceptions in all other areas of your code that may be valid exceptions in the debugger.
I got this exact same error but not with FastReport. I'll leave the context of my error, as it may help someone else. I got this error on:
RESTRequest.Execute();
I was using the TClientDataSet with TRESTResponseDataSetAdapter so that after a request to my web service the adapter would load a data set with the JSON string returned by the web service. This data set was being used to automatically check/uncheck checkboxes and load textedits and comboboxes. Since TJSONObject does not parse booleans correctly in json, I changed some checkboxes to check/uncheck based on an integer value instead of a boolean. I was then changing my webservice so that it looks for boolean columns in the datatable to an integer value 1 or 0. For some reason (my fault entirely), I was outputting a json with "" in that field instead of the integer ("1" or "0"). And this yielded that exact error. After correcting this, the error disappeared.
I had a similar issue in FastReport. In my case, it was a wrong Format applied to a MemoView. I could find the name of the offending component this way:
Use Break to stop the execution
In the Call Stack panel, find the latest call from a fastreport class (in my case: frxClass.TfrxCustomMemoView.FormatData(...) and double click it.
if you don't have the source code od Fast Report, a dialog appears - just hit Cancel
in Local Variables panel, you will probably see name of the offending component / value / format.

Debugging variables dynamically in xCode?

What do I need to do to have variables display their values in XCode?
I don't have it in Auto pane, and it also does not show when I hover over it. Why is that?
I can go Add Expression and sometimes it will display it correctly, and I can also do NSLog and log it, but this seems really ridiculous in the year of 2013.
I am using XCode 4.6. Am I doing something wrong, or this basic functionality just does not exist?
You can use the local variables section in the content pane to view variable values while debugging:
You can use shift + command + Y to toggle the above pane.
For more information regarding debugging in xCode, check out the following link.
In the console use the command 'po' (stands for print object)
e.g. po [self myVariable]
This will give you more information than this semi-useless variable tree in the content pane.
hints:
1) Make sure your build configuration is set to Debug, or you can't debug local variables.
2) Sometimes you need to debug structs and primitives, in this case use 'p' instead of 'po'
3) you can use dot notation (po self.myVariable), but for some data types this doesn't seem to work. I believe it depends on your xcode version

Delphi: How to debug run until you get back to your source file?

If I run a program and an exception is raised I am asked if I want to continue or break.
If I choose break I can see where the exception is coming from but if the break is in a library or system file not one of my source files (Say the exception is in System.pas or Controls.pas) I need to manually step the execution forward using F8 until it returns to one of my files, so I can see what part of my code caused the exception.
This can take a long time.
I know I should be catching lower level exceptions in my code but in this instance it's not hitting one of my exception handlers.
Is there a way to say
run forward with execution until you get to file X or
until you get back into a project specific file.
I'm also interested out of general curiosity on how other compilers / IDEs handle this.
Apologies if I haven't made this as clear as a I should.
You can resolve this by using the Stack View window.
Open the Stack View window (CTRL+ALT+S).
Double click on the method in the stack view where you wish to insert a breakpoint.
The unit, containing the caller method opens and the cursor is positioned on the caller method.
Set your breakpoint.
There's an even simpler way than Lieven's suggestion. Follow the first 3 steps as he laid them out, but don't place a breakpoint.
The problem with placing a breakpoint is that you have to clear it afterwards or you'll end up getting dropped into the debugger every time you pass that line. If you only want to run to a certain line and then drop to the debugger once, put the cursor on that line (the insertion point, not the mouse cursor) and press F4 (Run to Cursor). It's like a one-time breakpoint.
There are several ways:
Use the "Next source line" function (Shift+F7)
Use the call stack and double-click on the function you need, add a breakpoint there and hit "Run" (F9).
Use the "Step out" (Shift+F8) function until you are back into your own code.

Resources