bug-ddd
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[bug #42370] Machine Code Window does not work with newer GDBs


From: anonymous
Subject: [bug #42370] Machine Code Window does not work with newer GDBs
Date: Thu, 15 May 2014 13:25:18 +0000
User-agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:29.0) Gecko/20100101 Firefox/29.0

URL:
  <http://savannah.gnu.org/bugs/?42370>

                 Summary: Machine Code Window does not work with newer GDBs
                 Project: DDD
            Submitted by: None
            Submitted on: Thu 15 May 2014 01:25:17 PM UTC
                Category: Gdb integration
                Severity: 3 - Normal
              Item Group: None
                  Status: None
                 Privacy: Public
             Assigned to: None
             Open/Closed: Open
         Discussion Lock: Any
                 Release: 3.3.12-rc2

    _______________________________________________________

Details:

Hello,

Back in 2010, Paolo Canceda reported a Machine Code Window DDD bug
(https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=597328). The GDB
‘disassemble’ command had changed to use a comma instead of a space as
separator for its two arguments, causing the message “A syntax error in
expression, near ‘<hex_address>’” to appear in the Machine Code Window.

Paolo also supplied a patch. His fix, however, only made new GDBs work with
DDD.

Below is a more complete patch that auto-detects whether GDB expects the comma
in the ‘disassemble’ command and inserts it whenever needed.

BR,
René Schipp von Branitz Nielsen

diff -ur ddd-3.3.12.old/ddd/GDBAgent.C ddd-3.3.12.new/ddd/GDBAgent.C
--- ddd-3.3.12.old/ddd/GDBAgent.C       2009-02-11 18:25:06.000000000 +0100
+++ ddd-3.3.12.new/ddd/GDBAgent.C       2014-05-14 17:23:14.000000000 +0200
@@ -223,6 +223,7 @@
       _has_addproc_command(false),
       _has_debug_command(true),
       _is_windriver_gdb(false),
+      _wants_disassemble_comma(false),
       _program_language((tp == BASH) ? LANGUAGE_BASH : 
                        (tp == DBG)  ? LANGUAGE_PHP  :
                        (tp == JDB)  ? LANGUAGE_JAVA :
@@ -317,6 +318,7 @@
       _has_addproc_command(gdb.has_addproc_command()),
       _has_debug_command(gdb.has_debug_command()),
       _is_windriver_gdb(gdb.is_windriver_gdb()),
+      _wants_disassemble_comma(gdb.wants_disassemble_comma()),
       _program_language(gdb.program_language()),
       _verbatim(gdb.verbatim()),
       _recording(gdb.recording()),
@@ -3200,8 +3202,12 @@
     {
         string end_( end );
        normalize_address(end_);
-       cmd += ' ';
-       cmd += end_;
+        if (start != "" && start.lastchar() != ',') {
+            // No comma if only an end address or if #start
+            // already ends with a comma.
+            cmd += wants_disassemble_comma() ? ',' : ' ';
+        }
+        cmd += end_;
     }
     return cmd;
 }
diff -ur ddd-3.3.12.old/ddd/GDBAgent.h ddd-3.3.12.new/ddd/GDBAgent.h
--- ddd-3.3.12.old/ddd/GDBAgent.h       2009-02-11 18:25:06.000000000 +0100
+++ ddd-3.3.12.new/ddd/GDBAgent.h       2014-05-14 14:44:09.000000000 +0200
@@ -191,6 +191,7 @@
     bool _has_addproc_command;
     bool _has_debug_command;
     bool _is_windriver_gdb;
+    bool _wants_disassemble_comma;
 
     ProgramLanguage _program_language; // Current program language
 
@@ -427,6 +428,10 @@
     bool has_debug_command() const   { return _has_debug_command; }
     bool has_debug_command(bool val) { return _has_debug_command = val; }
 
+    // True if debugger wants 'disassemble' arguments separated by `,'
+    bool wants_disassemble_comma() const  { return
_wants_disassemble_comma; }
+    bool wants_disassemble_comma(bool val){ return 
+ _wants_disassemble_comma = val; }
+
     // True if debugger is the Windriver variant of GDB
     bool is_windriver_gdb() const   { return _is_windriver_gdb; }
     bool is_windriver_gdb(bool val) { return _is_windriver_gdb = val; } diff
-ur ddd-3.3.12.old/ddd/comm-manag.C ddd-3.3.12.new/ddd/comm-manag.C
--- ddd-3.3.12.old/ddd/comm-manag.C     2009-02-11 18:25:07.000000000 +0100
+++ ddd-3.3.12.new/ddd/comm-manag.C     2014-05-14 17:24:10.000000000 +0200
@@ -273,7 +273,7 @@
     bool     config_regs;             // try 'help regs'
     bool     config_named_values;      // try 'print "ddd"'
     bool     config_when_semicolon;    // try 'help when'
-    bool     config_delete_comma;      // try 'delete 4711 4712'
+    bool     config_delete_comma;      // try 'delete 4711 4711'
     bool     config_err_redirection;   // try 'help run'
     bool     config_givenfile;         // try 'help givenfile'
     bool     config_cont_sig;          // try 'help cont'
@@ -283,6 +283,7 @@
     bool     config_output;            // try 'output'
     bool     config_program_language;  // try 'show language'
     bool     config_gdb_version;       // try 'show version'
+    bool     config_disassemble_comma; // try 'disassemble 4711 4711'
(Newer GDBs (2009+) use ',' as separator. Old GDBs use ' ')
 
     OACProc  user_callback;           // callback
     void     *user_data;              // user data
@@ -344,6 +345,7 @@
          config_output(false),
          config_program_language(false),
          config_gdb_version(false),
+         config_disassemble_comma(false),
 
          user_callback(0),
          user_data(0)
@@ -458,6 +460,7 @@
     // Fetch initialization commands
     string init;
     string settings;
+
     switch (gdb->type())
     {
     case BASH:
@@ -542,6 +545,11 @@
        extra_data->config_program_language = true;
        cmds += "show version";
        extra_data->config_gdb_version = true;
+        if (config)
+        {
+           cmds += "disassemble " + print_cookie + " " + print_cookie;
+           extra_data->config_disassemble_comma = true;
+        }
        cmds += "pwd";
        extra_data->refresh_pwd = true;
        cmds += "info breakpoints";
@@ -694,7 +702,6 @@
                     extra_completed,
                     (void *)extra_data,
                     extra_registered);
-
     if (!extra_registered)
       delete extra_data;
 
@@ -1627,6 +1634,7 @@
     assert(!extra_data->config_output);
     assert(!extra_data->config_program_language);
     assert(!extra_data->config_gdb_version);
+    assert(!extra_data->config_disassemble_comma);
 
     // Annotate state
     if (extra_data->refresh_breakpoints) @@ -2885,6 +2893,10 @@
     }
 }
 
+static void process_config_disassemble_comma(const string& answer) {
+    gdb->wants_disassemble_comma(!is_known_command(answer));
+}
 
 
 
//--------------------------------------------------------------------------
---
@@ -3117,6 +3129,9 @@
     if (extra_data->config_gdb_version)
        process_config_gdb_version(answers[qu_count++]);
 
+    if (extra_data->config_disassemble_comma)
+       process_config_disassemble_comma(answers[qu_count++]);
+
     if (extra_data->refresh_pwd)
        source_view->process_pwd(answers[qu_count++]);







    _______________________________________________________

Reply to this item at:

  <http://savannah.gnu.org/bugs/?42370>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.gnu.org/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]