Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 367788

Summary: maint set python print-stack has been removed from GDB 7.4
Product: [Tools] CDT Reporter: Marc Khouzam <marc.khouzam>
Component: cdt-debug-dsf-gdbAssignee: Marc Khouzam <marc.khouzam>
Status: RESOLVED FIXED QA Contact: Marc Khouzam <marc.khouzam>
Severity: normal    
Priority: P3 CC: ccyu0, cdtdoug, cyril.jaquier, jens.elmenthaler, joshchia, maneeshsingh02, pawel.1.piech, rkfg, rmestep
Version: 8.0   
Target Milestone: 8.0.2   
Hardware: PC   
OS: Linux   
Whiteboard:
Attachments:
Description Flags
Fix for master
marc.khouzam: iplog-
Fix for cdt_8_0
marc.khouzam: iplog-
Improved fix for master marc.khouzam: iplog-

Description Marc Khouzam CLA 2012-01-03 14:42:32 EST
Created attachment 208957 [details]
Fix for master

My launch fails when using the GDB 7.4 branch with:

maintenance set python print-stack off
Error message from debugger back end:
Undefined maintenance set command: "python print-stack off". 

From the NEWS file of GDB:

  ** The "maint set python print-stack on|off" command has been
     removed.  A new command: "set python print-stack
     none|full|message" has replaced it.  Additionally, the default
     for "print-stack" is now "message", which just prints the error
     message without the stack trace.

Since the new default value is to only print the message and not the entire stack trace, I suggest we simply don't use that command.

Refer to bug 302121 for details on why we added the call to maintenance set python print-stack off.
Comment 1 Marc Khouzam CLA 2012-01-03 16:03:33 EST
Created attachment 208963 [details]
Fix for cdt_8_0

This patch is for the cdt_8_0 branch and avoids adding new APIs.  It is using a hack to check the GDB version directly, but I think it is worth to support the soon to be release GDB 7.4
Comment 2 Marc Khouzam CLA 2012-01-03 16:33:27 EST
I've committed the patches to master and cdt_8_0 respectively.

Mikhail, can you review?
Comment 3 Jens Elmenthaler CLA 2012-01-04 04:25:46 EST
(In reply to comment #2)
> I've committed the patches to master and cdt_8_0 respectively.
> Mikhail, can you review?
Marc, I'm not completely "happy" with the approach on MASTER: IGDBControl#setPrintPythonErrors is API, and it also allows clients to turn the full error messages on again (e.g. debugging your pretty printers or DSF GDB). Would it be much effort to really call the "set python" command?

For compatibility with the old behavior, off would be mapped to "set python print-stack message", and on to "set python print-stack full". I could even think of using "set python print-stack none" in case setPrintPythonErrors  is called with off. This would fit more exactly to the name of this method. It just wasn't possible with earlier gdb versions.
Comment 4 Marc Khouzam CLA 2012-01-05 22:27:30 EST
Created attachment 209117 [details]
Improved fix for master

(In reply to comment #3)

> Marc, I'm not completely "happy" with the approach on MASTER:
> IGDBControl#setPrintPythonErrors is API, and it also allows clients to turn the
> full error messages on again (e.g. debugging your pretty printers or DSF GDB).
> Would it be much effort to really call the "set python" command?

You are absolutely right about that.  I was being lazy.
Here is patch that uses the new command.

> For compatibility with the old behavior, off would be mapped to "set python
> print-stack message", and on to "set python print-stack full". I could even
> think of using "set python print-stack none" in case setPrintPythonErrors  is
> called with off. This would fit more exactly to the name of this method. It
> just wasn't possible with earlier gdb versions.

As you suggest, I used off => none.  I haven't actually seen what the output of the 'message' option looks like, but I gather you feel it is not necessary.

Let me know if you agree and I'll commit it.

Thanks for the comment.
Comment 5 Marc Khouzam CLA 2012-01-05 22:33:48 EST
Actually, I have committed the patch to master.  I'll update it if Jens or someone else has other comments.

Mikhail, you are still welcome to review, but since Jens had a look and the change is small, I think it is ok.
Comment 6 Jens Elmenthaler CLA 2012-01-09 02:54:36 EST
(In reply to comment #5)
> Actually, I have committed the patch to master.  I'll update it if Jens or
> someone else has other comments.
Thanks Marc, no further comment.
Comment 7 CDT Genie CLA 2012-02-29 11:35:08 EST
*** cdt git genie on behalf of Marc Khouzam ***

    Bug 367788: Use the new 'set python print-stack' command.

[*] http://git.eclipse.org/c/cdt/org.eclipse.cdt.git/commit/?id=f6d3c6295b2d02f772f2674fe4338c22f32f2151
Comment 8 Joshua Chia CLA 2012-04-05 23:08:52 EDT
I'm using Juno with CDT 8.1.0. My gdb is 7.3.50.

I'm getting this error message when I try to launch the debugger:
Error in final launch sequence
Failed to execute MI command:
-gdb-set python print-stack none
Error message from debugger back end:
"on" or "off" expected.
"on" or "off" expected.

Perhaps the fix is not backward-compatible with older versions of gdb?
Comment 9 Marc Khouzam CLA 2012-04-10 09:37:52 EDT
(In reply to comment #8)
> I'm using Juno with CDT 8.1.0. My gdb is 7.3.50.
> 
> I'm getting this error message when I try to launch the debugger:
> Error in final launch sequence
> Failed to execute MI command:
> -gdb-set python print-stack none
> Error message from debugger back end:
> "on" or "off" expected.
> "on" or "off" expected.
> 
> Perhaps the fix is not backward-compatible with older versions of gdb?

Thank you for reporting this.
We were still using the string "7.3.50" detect GDB 7.4, although that version was released.

What was happening in your case is that your 7.3.50 version didn't have the change that was put in GDB 7.4.

When you use *.*.50 releases of GDB, you find yourself in between two releases and things may not behave properly with Eclipse.

I've fixed things it in bug 376397, which should help your case, although I suggest you use 7.3.1 or 7.4.
Comment 10 Chung Yu CLA 2012-11-05 11:55:51 EST
Hi Marc,

This is not a comment but more of symptom I run into on Debug Configuration in Eclipse. I cannot get any answer for the regular Eclipse community forum
I am using GDB 7.4 on Fedora 17. I have the following error in Eclipse IDE with Run > Debug Configuration. After setting up the debug configuration, I click Debug. A dialog box with title 'Problem occurred' and the content is
'Launch test Debug has encountered a problem.
Error in final launching sequence.

Error in final launch sequence
Failed to execute MI command:
maintenance set python print-stack off
Error message from debugger back end:
Undefined maintenance set command: "python print-stack off".  Try "help maintenance set".
Undefined maintenance set command: "python print-stack off".  Try "help maintenance set".

How does one install his fix in Eclipse? What file do I install and how? Please specify in more details.

Thanks,
Chung
Comment 11 Marc Khouzam CLA 2012-11-05 16:28:32 EST
(In reply to comment #10)
> Hi Marc,
> 
> This is not a comment but more of symptom I run into on Debug Configuration
> in Eclipse. I cannot get any answer for the regular Eclipse community forum
> I am using GDB 7.4 on Fedora 17. I have the following error in Eclipse IDE
> with Run > Debug Configuration. After setting up the debug configuration, I
> click Debug. A dialog box with title 'Problem occurred' and the content is
> 'Launch test Debug has encountered a problem.
> Error in final launching sequence.
> 
> Error in final launch sequence
> Failed to execute MI command:
> maintenance set python print-stack off
> Error message from debugger back end:
> Undefined maintenance set command: "python print-stack off".  Try "help
> maintenance set".
> Undefined maintenance set command: "python print-stack off".  Try "help
> maintenance set".

GDB 7.4 and 7.4.1 still support "maintenance set python print-stack off" as far as I can see.  Maybe you are running GDB 7.5?

> How does one install his fix in Eclipse? What file do I install and how?
> Please specify in more details.

Eclipse Juno 3.7 (CDT 8.1) has the fix, as well as Eclipse Indigo 3.6.2 (CDT 8.0.2).  If you are running an older Eclipse you will need to upgrade, or not use GDB 7.5.
Comment 12 Maneesh Singh CLA 2012-11-16 12:57:44 EST
Hi,

I had Indigo SR1 and CDT 8.0.0
As per the following reply:
> How does one install his fix in Eclipse? What file do I install and how?
> Please specify in more details.

Eclipse Juno 3.7 (CDT 8.1) has the fix, as well as Eclipse Indigo 3.6.2 (CDT 8.0.2).  If you are running an older Eclipse you will need to upgrade, or not use GDB 7.5

I upgraded to Juno SR1 and CDT 8.1.1. Though the issue related set python print stack got resolved, i started facing another issue.

In the Debug configuration, while debugging remote processes, the icon "connect to a process" does not display any dialog for selection of the processes on the remote machine.

Any thoughts on this.

Regards
Maneesh
Comment 13 Marc Khouzam CLA 2012-11-16 14:04:48 EST
(In reply to comment #12)

> In the Debug configuration, while debugging remote processes, the icon
> "connect to a process" does not display any dialog for selection of the
> processes on the remote machine.

Look for exceptions in <workspace>/.metadata/.log
Comment 14 Maneesh Singh CLA 2012-11-17 10:17:12 EST
I could see the following exceptions in the log

!ENTRY org.eclipse.ui 4 0 2012-11-17 20:45:07.331
!MESSAGE Unhandled event loop exception
!STACK 0
org.eclipse.swt.SWTException: Failed to execute runnable (java.lang.NullPointerException)
	at org.eclipse.swt.SWT.error(SWT.java:4361)
	at org.eclipse.swt.SWT.error(SWT.java:4276)
	at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:138)
	at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:4144)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3761)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$9.run(PartRenderingEngine.java:1029)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:923)
	at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:86)
	at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:588)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
	at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:543)
	at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
	at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:124)
	at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:353)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:180)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at java.lang.reflect.Method.invoke(Unknown Source)
	at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:629)
	at org.eclipse.equinox.launcher.Main.basicRun(Main.java:584)
	at org.eclipse.equinox.launcher.Main.run(Main.java:1438)
Caused by: java.lang.NullPointerException
	at java.lang.StringBuffer.<init>(Unknown Source)
	at org.eclipse.cdt.dsf.gdb.internal.ui.launching.ProcessPrompter$1.getText(ProcessPrompter.java:109)
	at org.eclipse.ui.dialogs.FilteredList.setElements(FilteredList.java:278)
	at org.eclipse.ui.dialogs.AbstractElementListSelectionDialog.setListElements(AbstractElementListSelectionDialog.java:178)
	at org.eclipse.ui.dialogs.TwoPaneElementSelector.createDialogArea(TwoPaneElementSelector.java:141)
	at org.eclipse.jface.dialogs.Dialog.createContents(Dialog.java:760)
	at org.eclipse.jface.window.Window.create(Window.java:431)
	at org.eclipse.jface.dialogs.Dialog.create(Dialog.java:1089)
	at org.eclipse.ui.dialogs.SelectionStatusDialog.create(SelectionStatusDialog.java:153)
	at org.eclipse.ui.dialogs.AbstractElementListSelectionDialog.access$superCreate(AbstractElementListSelectionDialog.java:446)
	at org.eclipse.ui.dialogs.AbstractElementListSelectionDialog.access$2(AbstractElementListSelectionDialog.java:445)
	at org.eclipse.ui.dialogs.AbstractElementListSelectionDialog$4.run(AbstractElementListSelectionDialog.java:457)
	at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:70)
	at org.eclipse.ui.dialogs.AbstractElementListSelectionDialog.create(AbstractElementListSelectionDialog.java:455)
	at org.eclipse.jface.window.Window.open(Window.java:790)
	at org.eclipse.ui.dialogs.AbstractElementListSelectionDialog.open(AbstractElementListSelectionDialog.java:441)
	at org.eclipse.cdt.dsf.gdb.internal.ui.launching.ProcessPrompter.handleStatus(ProcessPrompter.java:173)
	at org.eclipse.debug.internal.ui.sourcelookup.Prompter$1.run(Prompter.java:70)
	at org.eclipse.ui.internal.UILockListener.doPendingWork(UILockListener.java:164)
	at org.eclipse.ui.internal.UISynchronizer$3.run(UISynchronizer.java:158)
	at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:35)
	at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:135)
	... 23 more
Comment 15 Marc Khouzam CLA 2012-11-19 14:03:04 EST
(In reply to comment #14)
> I could see the following exceptions in the log
>
> Caused by: java.lang.NullPointerException
> 	at java.lang.StringBuffer.<init>(Unknown Source)
> 	at
> org.eclipse.cdt.dsf.gdb.internal.ui.launching.ProcessPrompter$1.
> getText(ProcessPrompter.java:109)

This looks like a different instance of Bug 374823.
Can you open a new bug and post the result of the command 
--list-thread-groups --available
from the 'gdb traces'?
http://wiki.eclipse.org/CDT/User/FAQ#I.27ve_been_asked_for_.27gdb_traces.27.2C_where_can_I_find_them.3F
Comment 16 Marc Khouzam CLA 2013-03-12 13:05:47 EDT
*** Bug 402988 has been marked as a duplicate of this bug. ***
Comment 17 Marc Khouzam CLA 2013-03-13 15:13:22 EDT
*** Bug 403213 has been marked as a duplicate of this bug. ***
Comment 18 Serge Shpikin CLA 2016-08-03 07:47:19 EDT
The bug still stands. I can use GDB 7.7.1 without problems but there's 7.11.1 out already and it's in Debian Testing. This error appears when I try to debug using it because (I presume) the proposed patch compares versions as plain strings and 7.1* is less than 7.7*.

I successfully used DefaultArtifactVersion from Maven to symantically compare versions (https://maven.apache.org/ref/3.2.1/maven-artifact/apidocs/org/apache/maven/artifact/versioning/DefaultArtifactVersion.html).