Subject: bug#4519: 23.1.50; GDB MI problems: mi_cmd_stack_info_frame: No arguments required

From: [email-masked] (Nick Roberts)
Date: Wed, 23 Sep 2009 22:54:27 +1200

Michael Welsh Duggan writes:
 > Please describe exactly what actions triggered the bug
 > and the precise symptoms of the bug:
 > 
 > When running gdb via M-x gdb on some code of mine, I end up in a state
 > where it becomes no longer responsive to 'C-c C-s' or 'C-c C-n'
 > commands.
 > 
 > More specifically, I started running gdb by typing M-x gdb.  Arguments
 > were:
 > gdb -i=mi /home/mwd/bin/rwcut 
 > 
 > >From here I typed "start --python-file /tmp/foo.py --help", and then
 > stepped through my code using 'C-c C-s' and 'C-c C-n'.  At one point,
 > after 'C-c C-n', where a library was being dynamically loaded, I get the
 > following output in my *gdb-rwcut* buffer:
 > 
 > [Thread debugging using libthread_db enabled]
 > [New Thread 0xb7f786c0 (LWP 5633)]
 > (gdb) mi_cmd_stack_info_frame: No arguments required

Does the patch below fix the immediate problem?

You appear to be debugging a multi-threaded program with GDB 6.8.  The thread
buffer won't work in this case as it uses the MI -thread-info command which is
part of GDB 7.0.  This is due to be released in the next week or so.  Emacs
23.1 probably works better with GDB 6.8, at least for multi-threaded
applications.

-- 
Nick                                           http://users.snap.net.nz/~nickrob

*** gdb-mi.el.~1.49~	2009-09-18 15:10:58.000000000 +1200
--- gdb-mi.el	2009-09-23 22:53:36.000000000 +1200
*************** Emacs can't find.")
*** 218,223 ****
--- 218,224 ----
  (defvar gdb-source-window nil)
  (defvar gdb-inferior-status nil)
  (defvar gdb-continuation nil)
+ (defvar gdb-version nil)
  (defvar gdb-filter-output nil
    "Message to be shown in GUD console.
  
*************** If NOALL is t, always add --thread optio
*** 571,579 ****
  When `gdb-non-stop' is nil, return COMMAND unchanged."
    (if gdb-non-stop
        (if (and gdb-gud-control-all-threads
!                (not noall))
            (concat command " --all ")
!         (gdb-current-context-command command t))
      command))
  
  (defmacro gdb-gud-context-call (cmd1 &optional cmd2 noall noarg)
--- 572,581 ----
  When `gdb-non-stop' is nil, return COMMAND unchanged."
    (if gdb-non-stop
        (if (and gdb-gud-control-all-threads
!                (not noall)
! 	       (string-equal gdb-version "7.0+"))
            (concat command " --all ")
!         (gdb-current-context-command command))
      command))
  
  (defmacro gdb-gud-context-call (cmd1 &optional cmd2 noall noarg)
*************** detailed description of this mode.
*** 820,826 ****
    (if (re-search-forward "No symbol" nil t)
        (progn
  	(message "This version of GDB doesn't support non-stop mode.  Turning it off.")
! 	(setq gdb-non-stop nil))
      (gdb-input (list "-gdb-set target-async 1" 'ignore))
      (gdb-input (list "-enable-pretty-printing" 'ignore))))
  
--- 822,830 ----
    (if (re-search-forward "No symbol" nil t)
        (progn
  	(message "This version of GDB doesn't support non-stop mode.  Turning it off.")
! 	(setq gdb-non-stop nil)
! 	(setq gdb-version "pre-7.0"))
!     (setq gdb-version "7.0+")
      (gdb-input (list "-gdb-set target-async 1" 'ignore))
      (gdb-input (list "-enable-pretty-printing" 'ignore))))
  
*************** static char *magick[] = {
*** 1629,1644 ****
  		       (concat (car item) "\n")))
  
  ;; NOFRAME is used for gud execution control commands
! (defun gdb-current-context-command (command &optional noframe)
!   "Add --thread and --frame options to gdb COMMAND.
! 
! Option values are taken from `gdb-thread-number' and
! `gdb-frame-number'. If `gdb-thread-number' is nil, COMMAND is
! returned unchanged. If `gdb-frame-number' is nil of NOFRAME is t,
! then no --frame option is added."
!   ;; gdb-frame-number may be nil while gdb-thread-number is non-nil
!   ;; (when current thread is running)
!   (if gdb-thread-number
        (concat command " --thread " gdb-thread-number)
      command))
  
--- 1633,1642 ----
  		       (concat (car item) "\n")))
  
  ;; NOFRAME is used for gud execution control commands
! (defun gdb-current-context-command (command)
!   "Add --thread to gdb COMMAND when needed."
!   (if (and gdb-thread-number
! 	   (string-equal gdb-version "7.0+"))
        (concat command " --thread " gdb-thread-number)
      command))
  
*************** current thread and update GDB buffers."
*** 1920,1926 ****
      ;; thread
      (when (not gdb-register-names)
        (gdb-input
!        (list (concat "-data-list-register-names --thread " thread-id)
               'gdb-register-names-handler)))
  
  ;;; Don't set gud-last-frame here as it's currently done in gdb-frame-handler
--- 1918,1926 ----
      ;; thread
      (when (not gdb-register-names)
        (gdb-input
!        (list (concat "-data-list-register-names" 
! 		     (if (string-equal gdb-version "7.0+")
! 			 (concat" --thread " thread-id)))
               'gdb-register-names-handler)))
  
  ;;; Don't set gud-last-frame here as it's currently done in gdb-frame-handler
*************** corresponding to the mode line clicked."
*** 2565,2571 ****
   "Display GDB threads in a new frame.")
  
  (def-gdb-trigger-and-handler
!   gdb-invalidate-threads (gdb-current-context-command "-thread-info" gud-running)
    gdb-thread-list-handler gdb-thread-list-handler-custom
    '(start update update-threads))
  
--- 2565,2571 ----
   "Display GDB threads in a new frame.")
  
  (def-gdb-trigger-and-handler
!   gdb-invalidate-threads (gdb-current-context-command "-thread-info")
    gdb-thread-list-handler gdb-thread-list-handler-custom
    '(start update update-threads))