Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does the LLDB Debugger constantly fail to attach?

I have seen a lot of answers for this question:

error: failed to attach to process ID

as switch to GDB. But no one addresses the reason of why it happens?

Attaching works fine with the GDB debugger but the default and recommended project setting is LLDB.

Can anybody explain why LLDB fails? Is it a common bug or am I doing something wrong?

Alternatively, how can I set GDB as my default debugger without changing it manually when creating the new projects?

System Info:

OS: Lion
RAM: 5GB
XCode: Version 4.6 (4H127)
Device: Mac mini

My localhost setting: enter image description here

like image 216
Lithu T.V Avatar asked Mar 02 '13 12:03

Lithu T.V


People also ask

What does LLDB mean in Xcode?

What is LLDB? A low-level debugger (LLDB) is the default debugger used in Xcode and is part of the LLVM project. LLDB replaced GDB in XCode 5 and has several advantages, such as performance and scriptability.

How do you set a breakpoint in LLDB?

In lldb you can set breakpoints by typing either break or b followed by information on where you want the program to pause. After the b command, you can put either: a function name (e.g., b my_subroutine ) a line number (e.g., b 12 )

How do I stop LLDB?

Type quit to exit the lldb session.

Does LLDB work on Linux?

LLDB is improving on Linux. Linux is nearing feature completeness with Darwin to debug x86_64, i386, ARM, AArch64, IBM POWER (ppc64), IBM Z (s390x), and MIPS64 programs. For more details, see the Features by OS section below.


2 Answers

Make sure you have localhost mapped to 127.0.0.1 in your /etc/hosts file:

$ grep localhost /etc/hosts

If grep doesn't show 127.0.0.1 then add it:

$ sudo -i
# echo "127.0.0.1 localhost" >> /etc/hosts

^ That '#' is root's command prompt; don't type it otherwise you will comment-out the statement and nothing will happen

NOTE Use >> and not >! (better is to edit it using vi or mate or whatever).

My /etc/hosts file shows (ignoring comments):

127.0.0.1       localhost
255.255.255.255 broadcasthost
::1             localhost
fe80::1%lo0     localhost
like image 186
trojanfoe Avatar answered Oct 27 '22 20:10

trojanfoe


Apple likes to move forward. So setting gdb as the debugger for all new projects is not an option.

Sometimes, you have to reset the iOS Simulator to clean up the debugger.

like image 35
Black Frog Avatar answered Oct 27 '22 19:10

Black Frog