Thread dump in Objective C - xcode

I am new into objective c and I want to analyse my current thread.In java we using Using Thread Dumps. What is equivalent in objective C?

[NSThread callStackSymbols] will give you the call stack backtrace. Not sure if this is what you are looking for.
The reference is at https://developer.apple.com/library/mac/documentation/Cocoa/Reference/Foundation/Classes/NSThread_Class/Reference/Reference.html

You can look at the stack in Xcode. The stack trace is always related to one point in time of execution. So you have to set a break point to the location you want to see the stack trace.
Xcode automatically switches to the debug navigator, if lldb stopped execution because of a break point. To switch manually click on the 6th symbol from the right at the top of the navigators.
To learn more about debugging refer this document.

Related

Debugging with ReactiveSwift causes $__lldb_injected_self

So, I have been using ReactiveSwift for a long time. Most of the time, when I am using po I am able to see the value of a instance/local/global variable. But there are times when the call stack is so deep, that calling po would fail.
Attached screenshot of said failing scenario.

Mac Instruments Time profiling shows wrong heaviest back trace?

I am using the Instruments to profile a very simple program. Here is the result:
result
My question is: why the heaviest back trace are annotated on a very simple line of code? I think that line only needs some ALU instructions to implement. Is this a bug or I missed something?
I see nothing unusual in the screenshot you linked to. The 99x line in your screenshot has nothing to do with the heaviness of the backtrace. It is the line of code where Instruments recorded the most samples. The 99x line is inside a loop. Code inside loops is going to execute more often and have more samples.

how to do 'run to cursor' in gdb command line

Most debuggers with GUI have a useful function run to cursor. Is there any similar way of doing this in gdb?
I'm talking about assembly mode debugging (without source code).
For example, it currently break at: 0x400000, I'd like to run to 0x400100, there're lots of instructions between them. To do this, I have to:
set breakpoint at 0x400100 with b *0x400100,
continue with c
delete breakpoint with d ...
It is lots of typing, and I need to do this frequently. Any simpler way of doing this?
You are looking for either "until" or "advance" command.
Details in GDB manual chapter Continuing and Stepping.
If stopping on frame exit is problematic, you can still use tbreak, which sets temporary breakpoint, which is automatically deleted once it is hit.

GNAT Ada runtime Exception = message EXCEPTION_STACK_OVERFLOW

I'am trying to run my application after compiling it with AdaCores GPS (Gnat Programming Studio).
I get the run time error
Exception name: STORAGE_ERROR
Message: EXCEPTION_STACK_OVERFLOW
I get these run time errors despite setting the stack size in the binder options using
-d65535 (task stack size) and
-D65535 (secondary stack size)
(I also have tried 65535k on both as well as 655m).
The application runs well when compiling it with the Aonix Object Ada compiler. In the Aonix compiler I set the
- stack size to 65535,
- the secondary stack size to 65535
- and the Task stack size to 46345.
My main aim is to port the application to the GNAT Ada compiler.
I notice -d sets the task stack size and -D the secondary stack size but I can't see where to set the main stack size, and I am assuming that this is the issue with the application, but please correct me if I am looking in the wrong direction.
Any pointers would be greatly appreciated appreciated.
Bearslumber
If the problem is indeed the main task, a workaround is to move the main procedure to the body of a helper task.
First, compile for debug (-g) (there may be other relevant options; posting wrong information is the fastest way to find them ;-) and you should get more information : the source line and file that raised the exception. Or a stack trace which you can analyze via addr2line.
That should help understand why it is raising...
Are you allocating hundreds of MB on the stack? I've got away with about 200MB in the past...
Is the raise within one of the container classes or part of the RTS?
Is the message actually misleading and a new() heap allocation failed? Other things than the stack can raise Storage_Error, and I'm not clear how or if the default handler distinguishes the cause...
We can't proceed further down this path without further information : edit it into the question and I'll take another look.
Setting stack size for the environment task is not directly possible within Gnat. It's part of gcc's interaction with the OS, and supposed to use the system's ulimit settings for the resulting executable (on Linux; other OS may vary)...
Unfortunately, around the gcc/gnat 4.5 timeframe I found evidence these were being ignored, though that may have been corrected, and I haven't revisited that problem.
I have seen Alex's answer posted elsewhere as a viable workround if the debug trace and ulimit settings don't provide the answer, or if you need to press on instead of spending time debugging. To keep the codebase clean, I would suggest a wrapper, simply creating the necessary task and calling your current main procedure. For Aonix you simply don't need to include the wrapper file in your build.

Increase stack size in ECLiPSe/prolog/fd

We have to solve the liars problem in prolog, in several environments with constraints (ECLiPSe ic, ECLiPSe fd, SWI-prolog, GNU-prolog, NaxosSolver, etc.). I have used tail recursion (I think) and as many cuts as I could think of(that way I guess the resolution tree is not getting as big as it could be. If requested, I can post my code.
When the data number becomes 10000-50000, I receive a stack overflow in fd and ic in ECLiPSe and in SWI-prolog the program runs forever. So I would like to increase the size of the stack in ECLiPSe, but I can not see how.
I tried to write in the 1st line of my code this:
:-set_flag(local_stack_allocated, 512).
, but it says out of range.
See what eclipse says, which might be helpful:
* Overflow of the global/trail stack in spite of garbage collection!
You can use the "-g kBytes" (GLOBALSIZE) option to have a larger stack.
Peak sizes were: global stack 128832 kbytes, trail stack 5312 kbytes
First, from error message text I'm assuming that you mean ECLiPSe constraint logic programming system, not Eclipse IDE.
Second, how do you start ECLiPSe? How do you load your code into ECLiPSe?
Try this (you said you are on Windows):
Open command line from the folder where your ECLiPSe source file (say, 'myprogram.ecl') exists. For instructions look at this page: http://www.techsupportalert.com/content/how-open-windows-command-prompt-any-folder.htm
In the command line put eclipse -g 512000 and press ENTER.
Load your program using [myprogram]. (put name of your ECLiPSe source file instead of 'myprogram').
Execute queries as usual.
But I suspect that your program just runs forever and eats all memory, so all this probably won't help in the end.
EDIT. Updated instructions for TkECLiPSe:
In TkECLiPSe in menu choose Tools -> TkECLiPSe Preference Editor.
In preference window find option "Global/trail stack size (in megabytes)" and set it to 512.
Save preferences and close TkECLiPSe.
Next time you run TkECLiPSe stack size will be set to 512 Mb.

Resources