Bug 509737 - GDB 7.12 freezes at 62% on Mac using new console
Summary: GDB 7.12 freezes at 62% on Mac using new console
Status: RESOLVED FIXED
Alias: None
Product: CDT
Classification: Tools
Component: cdt-debug (show other bugs)
Version: 9.2.0   Edit
Hardware: Macintosh Mac OS X
: P3 normal (vote)
Target Milestone: 9.2.1   Edit
Assignee: Marc Khouzam CLA
QA Contact: Doug Schaefer CLA
URL:
Whiteboard:
Keywords:
: 509702 (view as bug list)
Depends on:
Blocks:
 
Reported: 2016-12-28 05:25 EST by Constantin Wiesener CLA
Modified: 2017-07-17 12:08 EDT (History)
8 users (show)

See Also:


Attachments
Error (63.29 KB, image/png)
2017-03-19 21:25 EDT, Victor Catão CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Constantin Wiesener CLA 2016-12-28 05:25:42 EST
Hi,

I managed to install gdb via home brew on sierra 10.12.2 and I codesigned it. Now I can run via command line the build executable from eclipse inside the debug folder.

But when I try to run it directly inside eclispe it hangs at 62% saying:

Launching: Initializing debugger services.

When I check the processes with top I can see that gdb is running so it has been called and it is the correct one. But then it does not continue.
Comment 1 Constantin Wiesener CLA 2016-12-28 05:26:29 EST
Ah my eclipse cdt version is NEON.2
Comment 2 Constantin Wiesener CLA 2016-12-28 05:27:14 EST
Stopping the debug process fails and the gdb process remains in the top list.
Comment 3 Marc Khouzam CLA 2016-12-28 17:02:06 EST
What are the arguments passed to the GDB executable when it was started?
Comment 4 Constantin Wiesener CLA 2016-12-29 02:48:10 EST
The gdb at the shell is called just with the program name and afterwards run to start the program. Inside eclipse the gdb is called just with ".gdbinit" which is empty.
Comment 5 Marc Khouzam CLA 2016-12-29 10:56:28 EST
You mentioned you can see the GDB started by eclipse when using top.  I'd like to know the command line options for that GDB.  On Linux you can do 
  ps -ef | grep gdb

Maybe it also works on Mac.
Comment 6 Constantin Wiesener CLA 2016-12-29 11:27:47 EST
ok, the output is the follwing:

  501  1005     1   0 Tue09PM ??         0:00.05 /usr/local/Cellar/gdb/7.12_1/bin/gdb armadillaTest
  501  3615  3385   0  5:26PM ttyp2      0:00.04 /usr/local/Cellar/gdb/7.12_1/bin/gdb --interpreter mi2 --nx -q --interpreter console -ex new-ui mi /dev/ttyp1 -ex set pagination off -ex show version
  501  3634  3618   0  5:26PM ttys000    0:00.00 grep gdb
Comment 7 Constantin Wiesener CLA 2017-01-04 07:07:13 EST
The same project with the same debugger is running under eclispe mars with the following command output:


  501  1005     1   0 27Dec16 ??         0:00.05 /usr/local/Cellar/gdb/7.12_1/bin/gdb armadillaTest
  501 24936 24924   0  1:05PM ??         0:00.09 /usr/local/Cellar/gdb/7.12_1/bin/gdb --interpreter mi2 --nx
  501 24961 24611   0  1:06PM ttys000    0:00.00 grep gdb


Why has the call changed?
Comment 8 Marc Khouzam CLA 2017-01-05 21:30:11 EST
(In reply to Constantin Wiesener from comment #6)
> ok, the output is the follwing:
> 
> /usr/local/Cellar/gdb/7.12_1/bin/gdb --interpreter mi2 --nx -q --interpreter
> console -ex new-ui mi /dev/ttyp1 -ex set pagination off -ex show version

These new arguments are used to trigger the new full GDB console
(https://wiki.eclipse.org/CDT/User/NewIn92#Full_GDB_Console)

We are now able to reproduce the hanging issue on Mac.

The problem seems to be that GDB 7.12 does not accept commands until the console is created in CDT, but that CDT needs to send an MI command before creating the console.  This does not happen on Linux. We're looking into how to get this fixed properly.

Sadly, this means GDB 7.12 cannot be used with CDT 9.3 on Mac.
I recommend using GDB 7.11 until a fix is available.
Comment 9 Marc Khouzam CLA 2017-01-05 21:46:44 EST
*** Bug 509702 has been marked as a duplicate of this bug. ***
Comment 10 Marc Khouzam CLA 2017-01-05 21:49:26 EST
(In reply to Marc Khouzam from comment #8)

> Sadly, this means GDB 7.12 cannot be used with CDT 9.3 on Mac.
> I recommend using GDB 7.11 until a fix is available.

Another way to workaround this is to pretend GDB 7.12 is actually version 7.11 as suggested by Norbert Lange in
https://bugs.eclipse.org/bugs/show_bug.cgi?id=509812#c0
Comment 11 Constantin Wiesener CLA 2017-01-06 04:44:07 EST
Hi,

I definitely do not think that this is the issue because when I use the same gdb 7.12 under mac osx with eclipse mars I can debug without a problem. This what I was commenting before.

So could you please check if you could run the test with eclipse mars and gdb 7.12 on a MAC.

Best regards,

Constantin
Comment 12 Marc-André Laperle CLA 2017-01-06 10:29:15 EST
(In reply to Constantin Wiesener from comment #11)
> So could you please check if you could run the test with eclipse mars and
> gdb 7.12 on a MAC.

It worked with the version of CDT that came with Mars because this version did not have support for the full GDB console yet.

In fact, you could run Eclipse *Platform* 4.6.2 (Neon.2) and CDT 9.1 (slightly older than latest) and it would work. If you want to do that, you can download the Eclipse Platform here:
https://www.eclipse.org/downloads/download.php?file=/eclipse/downloads/drops4/R-4.6.2-201611241400/eclipse-platform-4.6.2-macosx-cocoa-x86_64.tar.gz
then install CDT 9.1 (Install new software) using this update site: http://download.eclipse.org/tools/cdt/releases/9.1/
Comment 13 Constantin Wiesener CLA 2017-01-06 11:09:17 EST
Funny story running gdb7.11 under sierra 10.12.2 does not work because the gdb throws:

During startup program terminated with signal SIG113, Real-time event 113.

Even at the console the same problem happens. That's why I moved to 7.12_2
Did you already opened up a bug at gdb.
Comment 14 Eclipse Genie CLA 2017-01-06 11:26:46 EST
New Gerrit change created: https://git.eclipse.org/r/88189
Comment 15 Marc Khouzam CLA 2017-01-06 14:15:30 EST
(In reply to Constantin Wiesener from comment #13)
> Funny story running gdb7.11 under sierra 10.12.2 does not work because the
> gdb throws:
> 
> During startup program terminated with signal SIG113, Real-time event 113.
> 
> Even at the console the same problem happens. That's why I moved to 7.12_2
> Did you already opened up a bug at gdb.

You will then either need to use GDB 7.10 or use the version spoofing trick:
https://bugs.eclipse.org/bugs/show_bug.cgi?id=509812#c0

There will be a release of CDT 9.2.1 which will fix this problem, but it will only be available in March.
Comment 17 Eclipse Genie CLA 2017-01-06 15:02:18 EST
New Gerrit change created: https://git.eclipse.org/r/88203
Comment 19 Marc-André Laperle CLA 2017-01-06 16:45:03 EST
The full console is disabled for Mac on the cdt_9_2 and master branches for now. At least the next releases won't freeze (9.2.1 in March). But we'll try to re-enable it by then.
Comment 20 Marc Khouzam CLA 2017-01-27 09:16:52 EST
After further investigation, GDB on Mac does not support MI asynchronous communication, which is necessary for the full GDB console; without it, it is not possible to interrupt the inferior.

Therefore, until MI async support is added to GDB for Mac, we will need to keep the full console disable for Mac.
Comment 21 Doug Schaefer CLA 2017-01-27 11:24:50 EST
(In reply to Marc Khouzam from comment #20)
> After further investigation, GDB on Mac does not support MI asynchronous
> communication, which is necessary for the full GDB console; without it, it
> is not possible to interrupt the inferior.
> 
> Therefore, until MI async support is added to GDB for Mac, we will need to
> keep the full console disable for Mac.

Mac as a host or Mac as a target? Let me check if our cross debugger for QNX on Mac sees the same issue.
Comment 22 Doug Schaefer CLA 2017-01-27 11:31:19 EST
(In reply to Doug Schaefer from comment #21)
> (In reply to Marc Khouzam from comment #20)
> > After further investigation, GDB on Mac does not support MI asynchronous
> > communication, which is necessary for the full GDB console; without it, it
> > is not possible to interrupt the inferior.
> > 
> > Therefore, until MI async support is added to GDB for Mac, we will need to
> > keep the full console disable for Mac.
> 
> Mac as a host or Mac as a target? Let me check if our cross debugger for QNX
> on Mac sees the same issue.

I do not see any issue on the Mac with our 7.12 qnx gdb cross debugger. Actually works pretty good :).

So please be careful how you turn this off. Thank!
Comment 23 Doug Schaefer CLA 2017-01-27 11:35:17 EST
Oh, it's already turned off, never mind. :) And we override the backend anyway. Carry on.
Comment 24 Marc Khouzam CLA 2017-01-27 13:29:58 EST
(In reply to Doug Schaefer from comment #21)

> Mac as a host or Mac as a target? Let me check if our cross debugger for QNX
> on Mac sees the same issue.

MI asynchronous communication is on the host only, from CDT to GDB.  The communication from GDB to gdbserver seems independent of that.
Comment 25 Mordechay Sternlicht CLA 2017-03-17 07:38:28 EDT
(In reply to Marc Khouzam from comment #8)
> (In reply to Constantin Wiesener from comment #6)
> > ok, the output is the follwing:
> > 
> > /usr/local/Cellar/gdb/7.12_1/bin/gdb --interpreter mi2 --nx -q --interpreter
> > console -ex new-ui mi /dev/ttyp1 -ex set pagination off -ex show version
> 
> These new arguments are used to trigger the new full GDB console
> (https://wiki.eclipse.org/CDT/User/NewIn92#Full_GDB_Console)
> 
> We are now able to reproduce the hanging issue on Mac.
> 
> The problem seems to be that GDB 7.12 does not accept commands until the
> console is created in CDT, but that CDT needs to send an MI command before
> creating the console.  This does not happen on Linux. We're looking into how
> to get this fixed properly.
> 
> Sadly, this means GDB 7.12 cannot be used with CDT 9.3 on Mac.
> I recommend using GDB 7.11 until a fix is available.

How do I change it?
Comment 26 Marc Khouzam CLA 2017-03-17 07:56:31 EDT
(In reply to Mordechay Sternlicht from comment #25)

> How do I change it?

I personally don't know much about Macs, so I can't help on that point.

However, you can install a newer CDT instead, where we fixed the issue.
The 9.2.1 release will be available officially March 23rd, but if you want it right now you can upgrade your installation using the following update site:

http://download.eclipse.org/tools/cdt/builds/neon/milestones/ur3-rc4 

or download the zip file and install from there

zipfile: http://download.eclipse.org/tools/cdt/builds/neon/milestones/ur3-rc4/cdt-9.2.1rc4.zip
Comment 27 Victor Catão CLA 2017-03-19 21:25:53 EDT
Created attachment 267344 [details]
Error

(In reply to Marc Khouzam from comment #26)
> (In reply to Mordechay Sternlicht from comment #25)
> 
> > How do I change it?
> 
> I personally don't know much about Macs, so I can't help on that point.
> 
> However, you can install a newer CDT instead, where we fixed the issue.
> The 9.2.1 release will be available officially March 23rd, but if you want
> it right now you can upgrade your installation using the following update
> site:
> 
> http://download.eclipse.org/tools/cdt/builds/neon/milestones/ur3-rc4 
> 
> or download the zip file and install from there
> 
> zipfile:
> http://download.eclipse.org/tools/cdt/builds/neon/milestones/ur3-rc4/cdt-9.2.
> 1rc4.zip


I am still with problems. I installed cdt-9.2.1 and now I get "Error in final launch sequence".
 
I did it:
1- brew install gdb (7.12.1)
2- create gdb-cert on keychain Access
3- echo "set startup-with-shell off" >> ~/.gdbinit
4- codesign -s gdb-cert /usr/local/Cellar/gdb/7.12.1/bin/gdb 
5- eclipse installer > eclipse IDE for C/C++
6- debugger config -> Debugger -> GDB Debugger: /usr/local/Cellar/gdb/7.12.1/bin/gdb
7- Run debug: Crash on 62%
8- Help -> Install new software -> http://download.eclipse.org/tools/cdt/builds/neon/milestones/ur3-rc4 
9- Download and install CDT 9.2.1. Then, Restart eclipse
10- Run debugger again
11- Error: "Error in final launch sequence
Failed to execute MI command:
-exec-run"
Comment 28 Marc-André Laperle CLA 2017-03-19 22:34:12 EDT
(In reply to Victor Catão from comment #27)
> I am still with problems. I installed cdt-9.2.1 and now I get "Error in
> final launch sequence".

Hi Victor. Are you using Sierra (10.12) ? If so, you're probably seeing https://sourceware.org/bugzilla/show_bug.cgi?id=20266
You can try to do "set startup-with-shell off" in a .gdbinit but for me it hasn't helped that much.
Comment 29 Victor Catão CLA 2017-03-19 23:26:17 EDT
(In reply to Marc-André Laperle from comment #28)
> (In reply to Victor Catão from comment #27)
> > I am still with problems. I installed cdt-9.2.1 and now I get "Error in
> > final launch sequence".
> 
> Hi Victor. Are you using Sierra (10.12) ? If so, you're probably seeing
> https://sourceware.org/bugzilla/show_bug.cgi?id=20266
> You can try to do "set startup-with-shell off" in a .gdbinit but for me it
> hasn't helped that much.

Yes. More specifacally Sierra 10.12.3
I made a .gdbinit on ~/ with "set startup-with-shell off". But it also doesn't works :/
Comment 30 Bartosz Alksnin CLA 2017-07-17 12:08:26 EDT
i've had similar problem, it was because eclipse wasn't using .gdbinit from my home folder, i've change gdbinit path in debug config to ~/.gdbinit from .gdbinit and it worked fine. (on CDT 9.2.1 and sierra)
Comment 31 Bartosz Alksnin CLA 2017-07-17 12:08:52 EDT
i've had similar problem, it was because eclipse wasn't using .gdbinit from my home folder, i've change gdbinit path in debug config to ~/.gdbinit from .gdbinit and it worked fine. (on CDT 9.2.1 and sierra)