iPhone GDB Segmentation fault when attaching to running process - iphone

I have a jailbroken iPhone 5 running iOS 6.0.1. I installed gdb using pod2g's tutorial here: www.pod2g.org/2012/02/working-gnu-debugger-on-ios-43.html
All of the steps worked, and I copied gdb over to my jailbroken iPhone so I could use it there. gdb starts just fine, but when i try to attach to SpringBoard (or any other running process like Twitter) using
(gdb) attach SpringBoard
this happens:
Attaching to process 7366.
Segmentation fault:11
and I'm returned to the MobileTerminal or ssh prompt (not the gdb prompt). It looks like gdb has crashed, not SpringBoard, because my iPhone does not respring (as it normally does when SpringBoard crashes or is killed). I have tried attaching to SpringBoard using the gdb from the cydia.radare.org source as well, and the exact same thing happens each time. About a week ago, the gdb from the cydia.radare.org source worked just fine, but now both the gdb from pod2g's tutorial and the one from the Cydia source produce the above output. I've tried running gdb as root and the same thing happens. I've googled, and I can't seem to find anything like this. What's wrong and how do I fix it?

Apple has added a PTrace option to prevent debuggers (like GDB) from attaching to processes. Fortunately, you can use GDB to circumvent this as well.
Here is an excellent description:
http://iphonedevwiki.net/index.php/Crack_prevention#PT_DENY_ATTACH

Related

GDB input redirection not working on Mac OS High Sierra 10.13.3

I'm using GDB 8.0.1 on Mac OS High Sierra 10.13.3. Basically, doing:
(gdb) r < some_input_file.in
ignores the input file. It acts as if the command ran was simply
(gdb) r
The closest thread I found about this problem was Input redirection from file gdb but no solution was posted.
Any clues?
Thanks!
You are probably running into an interaction between gdb and macOS SIP ("System Integrity Protection").
gdb implements run redirections by passing the command line to the shell; then it waits for the shell to invoke your program before starting to "really debug". The shell is actually still controlled by gdb using ptrace -- gdb uses this to observe the eventual exec and to ensure that your process is also traced.
However, SIP prevents certain programs from being traced, and in particular programs in /usr/bin, like most shells. This causes run to stop working entirely, because the shell can't be started.
So, to make gdb continue to work, users often set startup-with-shell off. Perhaps whatever gdb build you are using does this by default (or maybe, like me, you put this in your .gdbinit and forgot about it). This setting lets run work -- but at the cost of disabling redirections.
There's a gdb bug for this which you can follow.

Gdb debug "terminated exit value: 0" error eclipse on mac

I've been trying to install gdb to debug using eclipse on my mac with no luck, I followed both of those guides with no success:
https://www.youtube.com/watch?v=JdcpDOf5Sog
[second guide in other comment - can't add more than two links due to new user limitations]
I'm attaching a screenshot to demonstrate:
Gdb "terminated exit value: 0" eclipse on mac
Each time I hit the Debug button I get the same "treminated exit value: 0" error (the code runs perfectly when I hit the run button). Gdb does respond to terminal command "gdb"
I've been researching for quite long and it seems that no one has experienced the same problem I do. (Macbook pro 2016 10.12 Sierra)
I've heard from a friend that I might need to configure my Mac to "developer" mode, I have xcode up and running, but I have no idea what else should I do. Anyway I'm my friend could not guarantee that it is the cause of the problem.
I had issue with terminated exit value: 0 while using older gdb 7.11 because my 7.12.1 does not work on Sierra 10.12.4. There was no solution for my case.
Easy WA is to use LLDB as a debugger for now. Sample instructions here
Another LLDB instruction here

Debuggers don't kick in when application crashes

I am trying to debug an application with Immunity debugger. I also tried WinDbg. I have set them as default JIT debugger through the Registry but it doesn`t work.
I tried in Windows XP SP3 and in Windows 7 but it doesn't work.
This might help someone whose immunity debugger does not kick in when the application really crashes like mine.
In regedit, edit the key HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\AeDebug
Default: (value not set)
Auto: 1
Debugger: "C:\Program Files\Immunity Inc\Immunity Debugger\ImmunityDebugger.exe" -p %ld
UserDebuggerHotKey: 0
You can install Windbg as the default postmortem debugger by running this from the command line:
windbg -IS
From then on, the next time an application crashes Windbg will appear, attached to the process.
To undo this, see this answer.
If this doesn't work, you'll need to add more details to your question.
If you are using Immunity Debugger, you may want to try to install python 2.7 on your PC.
If it is already installed try reinstalling it

Couldn't register com.XXXXX.deviceapp with the bootstrap server

I am getting this error while running in device please do need full help to solve this;
Couldn't register com.XXXXX.deviceapp with the bootstrap server. Error: unknown error code. This generally means that another instance of this process was already running or is hung in the debugger.Program received signal: “SIGABRT”.
I have had this happen where I needed to restart the phone before error would go away.
Deleteing the app, restarting Xcode, clean build, didn't do anything. I shut the phone down and bought it back up and the error went away.
Most annoying bug.
Only solution at this point:
If you're trying to run on a device: Shut off and restart device
If you're trying to run in simulator on Mac: restart your Mac
You can also do a Force Quit on the process via the Activity Monitor.
I've run into that with the simulator and the only solution I've found is to reboot the computer running Xcode.
kill all Simulator processes, that can cause this error as well.
using following terminal command
kill -9 `ps ax | grep Simulator | grep -v grep | awk '{print $1}'`
Reference
This seems to happen with the LLDB debugger when an app is paused at a breakpoint and the app is run again from xcode. The result is a zombie process on either the device or the development machine (when debugging in the simulator).
Only way to resolve seems to be a restart of the iDevice or the machine running the simulator.
Stopping the app completely before running it again in the debugger appears to prevent the problem from happening.
I managed to solve the issue by deleting my device form the Xcode 4.4 Organizer:
disconnect your device from your computer.
in Xcode: Window => Organizer
Choose the first tab ("Devices") from the top panel
Right click your device from the list at the left side of the Organizer, and choose "remove from organizer"

Eclipse CDT, Can't use debugger (Always stuck on 89% process)

If I run debugger then it gets stuck on 89% process...
It shows
Launching : Configuring GDB Aborting configuring GDB
I just wanted to see the debugger is working so all I have is
printf("debug test");
in main function..
Do you guys know what the problem is?
I have spent quite some time on this. It's really annoying and the solution is stupid to me:
Environment:
Mac + Eclipse + gdb (ggdb downloaded from macports).
Symptom:
Debugging hangs at 100% at startup. launching gdb aborting configuring gdb.
Solution: run as root
sudo /Applications/Eclipse.app/Contents/MacOS/eclipse
I believe the answer lies in codesigning, and the problem originates with the system security changes introduced by Apple. Please see this Stack Overflow answer, which fixed the same issue for me. Launching Eclipse with sudo (as recommended above) should probably be discouraged due to potential risks with your IDE going haywire with root permissions.
hello
after experiencing the same, it appeared gdb was missing access to some dll (libexpat-1.dll).
putting it in the current path corrected the problem.
in order to check this, try invoking gdb from the command prompt
all the best
olivier
I also encountered this error on Mac Mavericks. After which gdb I figured out that the path set in Eclipse Debug Configuration is not correct. Somehow I mistakenly set it to /usr/local/bin/gdb which actually should be /usr/bin/gdb