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

Bug 424996

Summary: [launch] Poor error reporting when determining GDB version
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: cdtdoug, malaperle, marc.dumais, pawel.1.piech
Version: 8.2   
Target Milestone: 8.3.0   
Hardware: PC   
OS: Linux   
Whiteboard:

Description Marc Khouzam CLA 2014-01-07 06:35:11 EST
When starting a debug session we run
 <user-specified gdb> --version'
first.  If that command fails or does not return what is expected, we don't show the proper information to the user.  This has caused a back and forth in bug reports.

Showing a more detailed error message would improve user-experience and troubleshooting.
Comment 1 Marc Khouzam CLA 2014-01-07 07:10:16 EST
I've pushed a patch to gerrit:
  https://git.eclipse.org/r/20326

The solution does three things:
- instead of passing e.getCause() when throwing the DebugException, we pass 'e' directly.  e.getCause() was returning null, and no message was being printed originally.  This fixes case #1 below

- it creates a 'detailedException' with the output read when parsing of the version fails.  See #2 below.  This will allow to more easily deal with version parsing issue reported by users.

- if no output is read from 'gdb --version' we try to read the error stream to report any errors.  See #3 below. 

The solution allows for the following error reporting:
1- if gdb is not found we get:
       "Error while launching command: wronggdb --version"
   and now, when pressing "Details >>", we see:
       "Cannot run program "wronggdb": Unknown reason"
   The Details part is whatever the exception message is when trying to run gdb

2- if the output of gdb --version cannot be parsed as expected, we now show that output:
    Could not determine GDB version after sending: badversiongdb --version
"Details >>"

Unexpected output format: 

GNU gdb (GDB) NOVERSION
Copyright (C) 2013 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-unknown-linux-gnu".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.

3- if an error occurs when trying to run gdb like when doing 'sudo gdb':
      "Could not determine GDB version after sending: sudo gdb --version"
   and now, when pressing "Details >>", we see:
      "sudo: no tty present and no askpass program specified"

4- if gdb does not return quickly enough (timeout from bug 376203) (this is not changed from before)
      "Could not determine GDB version after sending gdblooping --version"
Comment 2 Marc Khouzam CLA 2014-01-07 09:49:05 EST
Marc-Andre, since you dealt with GDB version issues before, can you review this change?
Comment 3 Marc Khouzam CLA 2014-01-10 05:55:15 EST
Committed to master.
Thanks Marc-Andre.