Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [patch/testsuite] revert return-type of gdb_file_cmd, gdb_load
@ 2004-09-10  1:03 Michael Chastain
  2004-09-10 18:11 ` Andrew Cagney
  0 siblings, 1 reply; 3+ messages in thread
From: Michael Chastain @ 2004-09-10  1:03 UTC (permalink / raw)
  To: gdb-patches; +Cc: manjo, jimb, cagney

I hope this is the end of the mess, but if it's not, just let me know!

This patch reverts the recent change to the return value of gdb_file_cmd.
Instead of using a structured return value, I just stick the secondary
information into a global variable.

Global variable.  Bleagh.  But "bleagh" beats "oh shit, I broke eight
other implementations of gdb_load in config/*.exp and I can't test all
of them".

Tested on native i686-pc-linux-gnu, gcc 2.95.3 3.3.4 3.4.1,
dwarf-2 and stabs+, with tcl 8.4.6, expect 5.41, dejagnu 1.4.4.

I also tested gdb.gdb/*.exp with a stripped gdb to check for
the proper "untested" results.

I am committing this now.

===

2004-09-09  Michael Chastain  <mec.gnu@mindspring.com>

	* lib/gdb.exp (gdb_file_cmd): Revert the return value to
	previous simple convention.  Use a global variable to store
	information about what was found.
	(gdb_run_cmd) Adapt to reverted return value.
	* gdb.base/remote.exp: Adapt to reverted return value.
	* gdb.gdb/complaints.exp: Likewise.
	* gdb.gdb/observer.exp: Likewise.
	* gdb.gdb/selftest.exp: Likewise.
	* gdb.gdb/xfullpath.exp: Likewise.

Index: gdb.base/remote.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.base/remote.exp,v
retrieving revision 1.4
diff -c -3 -p -r1.4 remote.exp
*** gdb.base/remote.exp	28 Aug 2004 23:55:48 -0000	1.4
--- gdb.base/remote.exp	9 Sep 2004 21:25:13 -0000
*************** proc gdb_load_timed {executable download
*** 119,125 ****
      set load_begin_time [clock clicks]
      set result [gdb_load $executable]
      set load_end_time [clock clicks]
!     if { [lindex $result 0] != "" } then {
  	fail "$test - loading executable"
  	return
      }
--- 119,125 ----
      set load_begin_time [clock clicks]
      set result [gdb_load $executable]
      set load_end_time [clock clicks]
!     if { $result != 0 } then {
  	fail "$test - loading executable"
  	return
      }
Index: gdb.gdb/complaints.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.gdb/complaints.exp,v
retrieving revision 1.4
diff -c -3 -p -r1.4 complaints.exp
*** gdb.gdb/complaints.exp	1 Sep 2004 19:55:00 -0000	1.4
--- gdb.gdb/complaints.exp	9 Sep 2004 21:25:13 -0000
*************** proc setup_test { executable } {
*** 49,65 ****
      set timeout 600
      verbose "Timeout is now $timeout seconds" 2
  
      set result [gdb_load $executable]
      set timeout $oldtimeout
      verbose "Timeout is now $timeout seconds" 2
  
!     if { [lindex $result 0] != "" } then {
  	return -1
-     } else {
-         if { [lsearch -exact [lrange $result 1 end] "nodebug"] >= 0 } then {
-             untested "No debug information, skipping testcase."
-             return -1
-         }
      }
  
      # Set a breakpoint at main
--- 49,68 ----
      set timeout 600
      verbose "Timeout is now $timeout seconds" 2
  
+     global gdb_file_cmd_debug_info
+     set gdb_file_cmd_debug_info "unset"
+ 
      set result [gdb_load $executable]
      set timeout $oldtimeout
      verbose "Timeout is now $timeout seconds" 2
  
!     if { $result != 0 } then {
! 	return -1
!     }
! 
!     if { gdb_file_cmd_debug_info != "debug" } then {
! 	untested "No debug information, skipping testcase."
  	return -1
      }
  
      # Set a breakpoint at main
Index: gdb.gdb/observer.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.gdb/observer.exp,v
retrieving revision 1.6
diff -c -3 -p -r1.6 observer.exp
*** gdb.gdb/observer.exp	1 Sep 2004 19:55:00 -0000	1.6
--- gdb.gdb/observer.exp	9 Sep 2004 21:25:13 -0000
*************** proc setup_test { executable } {
*** 47,63 ****
      set timeout 600
      verbose "Timeout is now $timeout seconds" 2
  
      set result [gdb_load $executable]
      set timeout $oldtimeout
      verbose "Timeout is now $timeout seconds" 2
  
!     if { [lindex $result 0] != "" } then {
  	return -1
-     } else {
-         if { [lsearch -exact [lrange $result 1 end] "nodebug"] >= 0 } then {
-             untested "No debug information, skipping testcase."
-             return -1
-         }
      }
  
      # Set a breakpoint at main
--- 47,66 ----
      set timeout 600
      verbose "Timeout is now $timeout seconds" 2
  
+     global gdb_file_cmd_debug_info
+     set gdb_file_cmd_debug_info "unset"
+ 
      set result [gdb_load $executable]
      set timeout $oldtimeout
      verbose "Timeout is now $timeout seconds" 2
  
!     if { $result != 0 } then {
! 	return -1
!     }
! 
!     if { gdb_file_cmd_debug_info != "debug" } then {
! 	untested "No debug information, skipping testcase."
  	return -1
      }
  
      # Set a breakpoint at main
Index: gdb.gdb/selftest.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.gdb/selftest.exp,v
retrieving revision 1.5
diff -c -3 -p -r1.5 selftest.exp
*** gdb.gdb/selftest.exp	1 Sep 2004 19:55:00 -0000	1.5
--- gdb.gdb/selftest.exp	9 Sep 2004 21:25:13 -0000
*************** proc test_with_self { executable } {
*** 241,257 ****
      set timeout 600
      verbose "Timeout is now $timeout seconds" 2
  
      set result [gdb_load $executable]
      set timeout $oldtimeout
      verbose "Timeout is now $timeout seconds" 2
  
!     if { [lindex $result 0] != "" } then {
  	return -1
-     } else {
-         if { [lsearch -exact [lrange $result 1 end] "nodebug"] >= 0 } then {
-             untested "No debug information, skipping testcase."
-             return -1
-         }
      }
  
      # disassemble yourself
--- 241,260 ----
      set timeout 600
      verbose "Timeout is now $timeout seconds" 2
  
+     global gdb_file_cmd_debug_info
+     set gdb_file_cmd_debug_info "unset"
+ 
      set result [gdb_load $executable]
      set timeout $oldtimeout
      verbose "Timeout is now $timeout seconds" 2
  
!     if { $result != 0 } then {
! 	return -1
!     }
! 
!     if { gdb_file_cmd_debug_info != "debug" } then {
! 	untested "No debug information, skipping testcase."
  	return -1
      }
  
      # disassemble yourself
Index: gdb.gdb/xfullpath.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.gdb/xfullpath.exp,v
retrieving revision 1.4
diff -c -3 -p -r1.4 xfullpath.exp
*** gdb.gdb/xfullpath.exp	1 Sep 2004 19:55:00 -0000	1.4
--- gdb.gdb/xfullpath.exp	9 Sep 2004 21:25:13 -0000
*************** proc setup_test { executable } {
*** 48,64 ****
      set timeout 600
      verbose "Timeout is now $timeout seconds" 2
  
      set result [gdb_load $executable]
      set timeout $oldtimeout
      verbose "Timeout is now $timeout seconds" 2
  
!     if { [lindex $result 0] != "" } then {
  	return -1
-     } else {
-         if { [lsearch -exact [lrange $result 1 end] "nodebug"] >= 0 } then {
-             untested "No debug information, skipping testcase."
-             return -1
-         }
      }
  
      # Set a breakpoint at main
--- 48,67 ----
      set timeout 600
      verbose "Timeout is now $timeout seconds" 2
  
+     global gdb_file_cmd_debug_info
+     set gdb_file_cmd_debug_info "unset"
+ 
      set result [gdb_load $executable]
      set timeout $oldtimeout
      verbose "Timeout is now $timeout seconds" 2
  
!     if { $result != 0 } then {
! 	return -1
!     }
! 
!     if { gdb_file_cmd_debug_info != "debug" } then {
! 	untested "No debug information, skipping testcase."
  	return -1
      }
  
      # Set a breakpoint at main
Index: lib/gdb.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/lib/gdb.exp,v
retrieving revision 1.57
diff -c -3 -p -r1.57 gdb.exp
*** lib/gdb.exp	28 Aug 2004 23:55:48 -0000	1.57
--- lib/gdb.exp	9 Sep 2004 21:25:14 -0000
*************** proc gdb_run_cmd {args} {
*** 180,187 ****
  	if [target_info exists gdb,do_reload_on_run] {
  	    # Specifying no file, defaults to the executable
  	    # currently being debugged.
! 	    set status [gdb_load ""]
! 	    if { [lindex $status 0] != "" } {
  		return;
  	    }
  	    send_gdb "continue\n";
--- 180,186 ----
  	if [target_info exists gdb,do_reload_on_run] {
  	    # Specifying no file, defaults to the executable
  	    # currently being debugged.
! 	    if { [gdb_load ""] != 0 } {
  		return;
  	    }
  	    send_gdb "continue\n";
*************** proc gdb_run_cmd {args} {
*** 226,233 ****
  		    send_gdb "y\n"
  		}
  		-re "The program is not being run.*$gdb_prompt $" {
! 		    set status [gdb_load ""]
! 		    if { [lindex $status 0] != ""] } {
  			return;
  		    }
  		    send_gdb "jump *$start\n";
--- 225,231 ----
  		    send_gdb "y\n"
  		}
  		-re "The program is not being run.*$gdb_prompt $" {
! 		    if { [gdb_load ""] != 0 } {
  			return;
  		    }
  		    send_gdb "jump *$start\n";
*************** proc gdb_run_cmd {args} {
*** 249,256 ****
      }
  
      if [target_info exists gdb,do_reload_on_run] {
! 	set status [gdb_load ""]
! 	if { [lindex $status 0] != "" } {
  	    return;
  	}
      }
--- 247,253 ----
      }
  
      if [target_info exists gdb,do_reload_on_run] {
! 	if { [gdb_load ""] != 0 } {
  	    return;
  	}
      }
*************** proc default_gdb_exit {} {
*** 957,992 ****
  }
  
  # Load a file into the debugger.
! # The return value is a list with the following information:
  #
! #  { message word ... }
! # 
! # MESSAGE has the following values:
! #
! #   ""     file was loaded successfully
! #   "..."  file was not loaded successfully.
! #          A perror has been generated with MESSAGE.
  #
! # If the MESSAGE is "", then there is an optional set of words.
! # The words may be:
  #
! #  nodebug  this file does not contain debug information
  #
! # TODO: gdb.base/sepdebug.exp and gdb.stabs/weird.exp might
! # be able to use this if they can get more information
! # in the return value.
  
  proc gdb_file_cmd { arg } {
      global gdb_prompt
      global verbose
      global GDB
  
      if [is_remote host] {
  	set arg [remote_download host $arg]
  	if { $arg == "" } {
! 	    set message "download failed"
! 	    perror $message
! 	    return { $message }
  	}
      }
  
--- 954,990 ----
  }
  
  # Load a file into the debugger.
! # The return value is 0 for success, -1 for failure.
  #
! # This procedure also set the global variable GDB_FILE_CMD_DEBUG_INFO
! # to one of these values:
  #
! #   debug    file was loaded successfully and has debug information
! #   nodebug  file was loaded successfully and has no debug information
! #   fail     file was not loaded
  #
! # I tried returning this information as part of the return value,
! # but ran into a mess because of the many re-implementations of
! # gdb_load in config/*.exp.
  #
! # TODO: gdb.base/sepdebug.exp and gdb.stabs/weird.exp might be able to use
! # this if they can get more information set.
  
  proc gdb_file_cmd { arg } {
      global gdb_prompt
      global verbose
      global GDB
  
+     # Set whether debug info was found.
+     # Default to "fail".
+     global gdb_file_cmd_debug_info
+     set gdb_file_cmd_debug_info "fail"
+ 
      if [is_remote host] {
  	set arg [remote_download host $arg]
  	if { $arg == "" } {
! 	    perror "download failed"
! 	    return -1
  	}
      }
  
*************** proc gdb_file_cmd { arg } {
*** 994,1008 ****
      gdb_expect 120 {
  	-re "Reading symbols from.*no debugging symbols found.*done.*$gdb_prompt $" {
  	    verbose "\t\tLoaded $arg into the $GDB with no debugging symbols"
! 	    return { "" nodebug }
  	}
          -re "Reading symbols from.*done.*$gdb_prompt $" {
              verbose "\t\tLoaded $arg into the $GDB"
! 	    return { "" }
          }
          -re "A program is being debugged already.*Kill it.*y or n. $" {
              send_gdb "y\n"
!                 verbose "\t\tKilling previous program being debugged"
              exp_continue
          }
          -re "Load new symbol table from \".*\".*y or n. $" {
--- 992,1008 ----
      gdb_expect 120 {
  	-re "Reading symbols from.*no debugging symbols found.*done.*$gdb_prompt $" {
  	    verbose "\t\tLoaded $arg into the $GDB with no debugging symbols"
! 	    set gdb_file_cmd_debug_info "nodebug"
! 	    return 0
  	}
          -re "Reading symbols from.*done.*$gdb_prompt $" {
              verbose "\t\tLoaded $arg into the $GDB"
! 	    set gdb_file_cmd_debug_info "debug"
! 	    return 0
          }
          -re "A program is being debugged already.*Kill it.*y or n. $" {
              send_gdb "y\n"
! 	    verbose "\t\tKilling previous program being debugged"
              exp_continue
          }
          -re "Load new symbol table from \".*\".*y or n. $" {
*************** proc gdb_file_cmd { arg } {
*** 1010,1046 ****
              gdb_expect 120 {
                  -re "Reading symbols from.*done.*$gdb_prompt $" {
                      verbose "\t\tLoaded $arg with new symbol table into $GDB"
! 		    return { "" }
                  }
                  timeout {
!                     set message "(timeout) Couldn't load $arg, other program already loaded."
! 		    perror $message
! 		    return { $message }
                  }
              }
  	}
          -re "No such file or directory.*$gdb_prompt $" {
!             set message "($arg) No such file or directory"
!             perror $message
! 	    return { $message }
          }
          -re "$gdb_prompt $" {
!             set message "couldn't load $arg into $GDB."
!             perror $message
! 	    return { $message }
              }
          timeout {
!             set message "couldn't load $arg into $GDB (timed out)."
! 	    perror $message
! 	    return { $message }
          }
          eof {
              # This is an attempt to detect a core dump, but seems not to
              # work.  Perhaps we need to match .* followed by eof, in which
              # gdb_expect does not seem to have a way to do that.
!             set message "couldn't load $arg into $GDB (end of file)."
! 	    perror $message
! 	    return { $message }
          }
      }
  }
--- 1010,1042 ----
              gdb_expect 120 {
                  -re "Reading symbols from.*done.*$gdb_prompt $" {
                      verbose "\t\tLoaded $arg with new symbol table into $GDB"
! 		    set gdb_file_cmd_debug_info "debug"
! 		    return 0
                  }
                  timeout {
!                     perror "(timeout) Couldn't load $arg, other program already loaded."
! 		    return -1
                  }
              }
  	}
          -re "No such file or directory.*$gdb_prompt $" {
!             perror "($arg) No such file or directory"
! 	    return -1
          }
          -re "$gdb_prompt $" {
!             perror "couldn't load $arg into $GDB."
! 	    return -1
              }
          timeout {
!             perror "couldn't load $arg into $GDB (timed out)."
! 	    return -1
          }
          eof {
              # This is an attempt to detect a core dump, but seems not to
              # work.  Perhaps we need to match .* followed by eof, in which
              # gdb_expect does not seem to have a way to do that.
!             perror "couldn't load $arg into $GDB (end of file)."
! 	    return -1
          }
      }
  }
*************** proc gdb_exit { } {
*** 1655,1660 ****
--- 1651,1657 ----
  
  #
  # gdb_load -- load a file into the debugger.
+ # Many files in config/*.exp override this procedure.
  #
  proc gdb_load { arg } {
      return [gdb_file_cmd $arg]


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [patch/testsuite] revert return-type of gdb_file_cmd, gdb_load
  2004-09-10  1:03 [patch/testsuite] revert return-type of gdb_file_cmd, gdb_load Michael Chastain
@ 2004-09-10 18:11 ` Andrew Cagney
  2004-09-10 18:30   ` Michael Chastain
  0 siblings, 1 reply; 3+ messages in thread
From: Andrew Cagney @ 2004-09-10 18:11 UTC (permalink / raw)
  To: Michael Chastain; +Cc: gdb-patches

> I hope this is the end of the mess, but if it's not, just let me know!

Thanks!  (Joel, my mips patches will no longer be flying blind ;-)

> This patch reverts the recent change to the return value of gdb_file_cmd.
> Instead of using a structured return value, I just stick the secondary
> information into a global variable.

What of two interfaces -> an existing one with preserved behavior and a 
new one with extended behavior?

> Global variable.  Bleagh.  But "bleagh" beats "oh shit, I broke eight
> other implementations of gdb_load in config/*.exp and I can't test all
> of them".
> 
> Tested on native i686-pc-linux-gnu, gcc 2.95.3 3.3.4 3.4.1,
> dwarf-2 and stabs+, with tcl 8.4.6, expect 5.41, dejagnu 1.4.4.
> 
> I also tested gdb.gdb/*.exp with a stripped gdb to check for
> the proper "untested" results.
> 
> I am committing this now.

Andrew



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [patch/testsuite] revert return-type of gdb_file_cmd, gdb_load
  2004-09-10 18:11 ` Andrew Cagney
@ 2004-09-10 18:30   ` Michael Chastain
  0 siblings, 0 replies; 3+ messages in thread
From: Michael Chastain @ 2004-09-10 18:30 UTC (permalink / raw)
  To: cagney; +Cc: gdb-patches

Andrew Cagney <cagney@gnu.org> wrote:
> What of two interfaces -> an existing one with preserved behavior and a 
> new one with extended behavior?

In a way, that's what we have now.  The "extended behavior" is to set
the global variable gdb_file_cmd_debug_info.

The problem with "two interfaces" is that there really are nine
different procedures named gdb_load, and the caller does not know
which of the nine procedures is active.  So the new interface has
to be compatible with the old, or I have to change nine implementations
of "gdb_load" simultaneously.

Also, if gdb.gdb/*.exp runs in an environment where the implementation of
gdb_load does not provide this extended behavior, then it will
see that gdb_file_cmd_debug_info is still set to "unset" and it can
react appropriately.  From inspection, I believe the only gdb_load
that will *not* get the extended behavior is the stubby
"not implemented yet" implementation in config/nind.exp.

Michael


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2004-09-10 18:30 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-09-10  1:03 [patch/testsuite] revert return-type of gdb_file_cmd, gdb_load Michael Chastain
2004-09-10 18:11 ` Andrew Cagney
2004-09-10 18:30   ` Michael Chastain

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox