2020-01-01 07:20:01 +01:00
|
|
|
|
# Copyright 1992-2020 Free Software Foundation, Inc.
|
1999-04-16 03:35:26 +02:00
|
|
|
|
|
|
|
|
|
# This program is free software; you can redistribute it and/or modify
|
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
2007-08-23 20:14:19 +02:00
|
|
|
|
# the Free Software Foundation; either version 3 of the License, or
|
1999-04-16 03:35:26 +02:00
|
|
|
|
# (at your option) any later version.
|
2007-08-23 20:14:19 +02:00
|
|
|
|
#
|
1999-04-16 03:35:26 +02:00
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
# GNU General Public License for more details.
|
2007-08-23 20:14:19 +02:00
|
|
|
|
#
|
1999-04-16 03:35:26 +02:00
|
|
|
|
# You should have received a copy of the GNU General Public License
|
2007-08-23 20:14:19 +02:00
|
|
|
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
1999-04-16 03:35:26 +02:00
|
|
|
|
|
|
|
|
|
# This file was written by Fred Fish. (fnf@cygnus.com)
|
|
|
|
|
|
|
|
|
|
# Generic gdb subroutines that should work for any target. If these
|
|
|
|
|
# need to be modified for any target, it can be done with a variable
|
|
|
|
|
# or by passing arguments.
|
|
|
|
|
|
2007-01-21 23:25:34 +01:00
|
|
|
|
if {$tool == ""} {
|
|
|
|
|
# Tests would fail, logs on get_compiler_info() would be missing.
|
|
|
|
|
send_error "`site.exp' not found, run `make site.exp'!\n"
|
|
|
|
|
exit 2
|
|
|
|
|
}
|
|
|
|
|
|
1999-04-16 03:35:26 +02:00
|
|
|
|
load_lib libgloss.exp
|
2013-08-13 17:55:52 +02:00
|
|
|
|
load_lib cache.exp
|
2014-07-12 02:22:25 +02:00
|
|
|
|
load_lib gdb-utils.exp
|
2017-01-26 20:51:09 +01:00
|
|
|
|
load_lib memory.exp
|
1999-04-16 03:35:26 +02:00
|
|
|
|
|
|
|
|
|
global GDB
|
|
|
|
|
|
testsuite: Introduce $inferior_spawn_id
Some important tests, like gdb.base/interrupt.exp end up skipped
against gdbserver, because they depend on inferior I/O, which
gdbserver doesn't do.
This patch adds a mechanism that makes it possible to make them work.
It adds a new "inferior_spawn_id" global that is the spawn ID used for
I/O interaction with the inferior. By default, for native targets, or
remote targets that can do I/O through GDB (semi-hosting) this will be
the same as the gdb/host spawn ID. Otherwise, the board may set this
to some other spawn ID. When debugging with GDBserver, this will be
set to GDBserver's spawn ID.
Then tests can use send_inferior instead of send_gdb to send input to
the inferior, and use expect's "-i" switch to select which spawn ID to
use for matching input/output. That is, something like this will now
work:
send_inferior "echo me\n"
gdb_test_multiple "continue" "test msg" {
-i "$inferior_spawn_id" -re "echo me\r\necho\r\n" {
...
}
}
Or even:
gdb_test_multiple "continue" "test msg" {
-i "$inferior_spawn_id" -re "hello world" {
...
}
-i "$gdb_spawn_id" -re "error.*$gdb_prompt $" {
...
}
}
Of course, by default, gdb_test_multiple still matches with
$gdb_spawn_id.
gdb/testsuite/ChangeLog:
2015-04-07 Pedro Alves <palves@redhat.com>
* lib/gdb.exp (inferior_spawn_id): New global.
(gdb_test_multiple): Handle "-i". Reset the spawn id to GDB's
spawn id after processing the user code.
(default_gdb_start): Set inferior_spawn_id.
(send_inferior): New procedure.
* lib/gdbserver-support.exp (gdbserver_start): Set
inferior_spawn_id.
(close_gdbserver, gdb_exit): Unset inferior_spawn_id.
2015-04-07 19:19:30 +02:00
|
|
|
|
# The spawn ID used for I/O interaction with the inferior. For native
|
|
|
|
|
# targets, or remote targets that can do I/O through GDB
|
|
|
|
|
# (semi-hosting) this will be the same as the host/GDB's spawn ID.
|
|
|
|
|
# Otherwise, the board may set this to some other spawn ID. E.g.,
|
|
|
|
|
# when debugging with GDBserver, this is set to GDBserver's spawn ID,
|
|
|
|
|
# so input/output is done on gdbserver's tty.
|
|
|
|
|
global inferior_spawn_id
|
|
|
|
|
|
1999-04-16 03:35:26 +02:00
|
|
|
|
if [info exists TOOL_EXECUTABLE] {
|
2013-06-07 19:31:09 +02:00
|
|
|
|
set GDB $TOOL_EXECUTABLE
|
1999-04-16 03:35:26 +02:00
|
|
|
|
}
|
|
|
|
|
if ![info exists GDB] {
|
|
|
|
|
if ![is_remote host] {
|
|
|
|
|
set GDB [findfile $base_dir/../../gdb/gdb "$base_dir/../../gdb/gdb" [transform gdb]]
|
|
|
|
|
} else {
|
2013-06-07 19:31:09 +02:00
|
|
|
|
set GDB [transform gdb]
|
1999-04-16 03:35:26 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
verbose "using GDB = $GDB" 2
|
|
|
|
|
|
2008-11-11 02:23:34 +01:00
|
|
|
|
# GDBFLAGS is available for the user to set on the command line.
|
|
|
|
|
# E.g. make check RUNTESTFLAGS=GDBFLAGS=mumble
|
|
|
|
|
# Testcases may use it to add additional flags, but they must:
|
|
|
|
|
# - append new flags, not overwrite
|
|
|
|
|
# - restore the original value when done
|
1999-04-16 03:35:26 +02:00
|
|
|
|
global GDBFLAGS
|
|
|
|
|
if ![info exists GDBFLAGS] {
|
2008-11-11 02:23:34 +01:00
|
|
|
|
set GDBFLAGS ""
|
1999-04-16 03:35:26 +02:00
|
|
|
|
}
|
|
|
|
|
verbose "using GDBFLAGS = $GDBFLAGS" 2
|
|
|
|
|
|
2012-03-23 23:28:35 +01:00
|
|
|
|
# Make the build data directory available to tests.
|
|
|
|
|
set BUILD_DATA_DIRECTORY "[pwd]/../data-directory"
|
|
|
|
|
|
2008-11-11 02:23:34 +01:00
|
|
|
|
# INTERNAL_GDBFLAGS contains flags that the testsuite requires.
|
2010-02-05 22:51:38 +01:00
|
|
|
|
global INTERNAL_GDBFLAGS
|
|
|
|
|
if ![info exists INTERNAL_GDBFLAGS] {
|
2012-03-23 23:28:35 +01:00
|
|
|
|
set INTERNAL_GDBFLAGS "-nw -nx -data-directory $BUILD_DATA_DIRECTORY"
|
2010-02-05 22:51:38 +01:00
|
|
|
|
}
|
2008-11-11 02:23:34 +01:00
|
|
|
|
|
1999-06-21 15:27:42 +02:00
|
|
|
|
# The variable gdb_prompt is a regexp which matches the gdb prompt.
|
2014-09-14 00:52:15 +02:00
|
|
|
|
# Set it if it is not already set. This is also set by default_gdb_init
|
|
|
|
|
# but it's not clear what removing one of them will break.
|
|
|
|
|
# See with_gdb_prompt for more details on prompt handling.
|
1999-04-16 03:35:26 +02:00
|
|
|
|
global gdb_prompt
|
1999-06-21 15:27:42 +02:00
|
|
|
|
if ![info exists gdb_prompt] then {
|
2014-09-14 00:52:15 +02:00
|
|
|
|
set gdb_prompt "\\(gdb\\)"
|
1999-04-16 03:35:26 +02:00
|
|
|
|
}
|
|
|
|
|
|
Canceling pagination caused by execution command from command line aborts readline/gdb
This fixes:
$ ./gdb program -ex "set height 2" -ex "start"
...
Reading symbols from /home/pedro/gdb/tests/threads...done.
---Type <return> to continue, or q <return> to quit---^CQuit << ctrl-c triggers a Quit
*type something*
readline: readline_callback_read_char() called with no handler!
Aborted
$
Usually, if an error propagates all the way to the top level, we'll
re-enable stdin, in case the command that was running was a
synchronous command. That's done in the event loop's actual loop
(event-loop.c:start_event_loop). However, if a foreground execution
command is run before the event loop starts and throws, nothing is
presently reenabling stdin, which leaves sync_execution set.
When we do start the event loop, because sync_execution is still
(mistakenly) set, display_gdb_prompt removes the readline input
callback, even though stdin is registered in the event loop. Any
input from here on results in readline aborting.
Such commands are run through catch_command_errors,
catch_command_errors_const, so add the tweak there.
gdb/
2014-07-14 Pedro Alves <palves@redhat.com>
PR gdb/17072
* main.c: Include event-top.h.
(handle_command_errors): New function.
(catch_command_errors, catch_command_errors_const): Use it.
gdb/testsuite/
2014-07-14 Pedro Alves <palves@redhat.com>
PR gdb/17072
* gdb.base/paginate-execution-startup.c: New file.
* gdb.base/paginate-execution-startup.exp: New file.
* lib/gdb.exp (pagination_prompt): New global.
(default_gdb_spawn): New procedure, factored out from
default_gdb_spawn.
(default_gdb_start): Adjust to call default_gdb_spawn.
(gdb_spawn): New procedure.
2014-07-14 20:55:31 +02:00
|
|
|
|
# A regexp that matches the pagination prompt.
|
2018-04-25 16:52:00 +02:00
|
|
|
|
set pagination_prompt \
|
|
|
|
|
"--Type <RET> for more, q to quit, c to continue without paging--"
|
Canceling pagination caused by execution command from command line aborts readline/gdb
This fixes:
$ ./gdb program -ex "set height 2" -ex "start"
...
Reading symbols from /home/pedro/gdb/tests/threads...done.
---Type <return> to continue, or q <return> to quit---^CQuit << ctrl-c triggers a Quit
*type something*
readline: readline_callback_read_char() called with no handler!
Aborted
$
Usually, if an error propagates all the way to the top level, we'll
re-enable stdin, in case the command that was running was a
synchronous command. That's done in the event loop's actual loop
(event-loop.c:start_event_loop). However, if a foreground execution
command is run before the event loop starts and throws, nothing is
presently reenabling stdin, which leaves sync_execution set.
When we do start the event loop, because sync_execution is still
(mistakenly) set, display_gdb_prompt removes the readline input
callback, even though stdin is registered in the event loop. Any
input from here on results in readline aborting.
Such commands are run through catch_command_errors,
catch_command_errors_const, so add the tweak there.
gdb/
2014-07-14 Pedro Alves <palves@redhat.com>
PR gdb/17072
* main.c: Include event-top.h.
(handle_command_errors): New function.
(catch_command_errors, catch_command_errors_const): Use it.
gdb/testsuite/
2014-07-14 Pedro Alves <palves@redhat.com>
PR gdb/17072
* gdb.base/paginate-execution-startup.c: New file.
* gdb.base/paginate-execution-startup.exp: New file.
* lib/gdb.exp (pagination_prompt): New global.
(default_gdb_spawn): New procedure, factored out from
default_gdb_spawn.
(default_gdb_start): Adjust to call default_gdb_spawn.
(gdb_spawn): New procedure.
2014-07-14 20:55:31 +02:00
|
|
|
|
|
2005-05-08 15:42:04 +02:00
|
|
|
|
# The variable fullname_syntax_POSIX is a regexp which matches a POSIX
|
|
|
|
|
# absolute path ie. /foo/
|
2008-09-13 19:54:06 +02:00
|
|
|
|
set fullname_syntax_POSIX {/[^\n]*/}
|
2005-05-08 15:42:04 +02:00
|
|
|
|
# The variable fullname_syntax_UNC is a regexp which matches a Windows
|
|
|
|
|
# UNC path ie. \\D\foo\
|
2008-09-13 19:54:06 +02:00
|
|
|
|
set fullname_syntax_UNC {\\\\[^\\]+\\[^\n]+\\}
|
2005-05-08 15:42:04 +02:00
|
|
|
|
# The variable fullname_syntax_DOS_CASE is a regexp which matches a
|
|
|
|
|
# particular DOS case that GDB most likely will output
|
|
|
|
|
# ie. \foo\, but don't match \\.*\
|
2008-09-13 19:54:06 +02:00
|
|
|
|
set fullname_syntax_DOS_CASE {\\[^\\][^\n]*\\}
|
2005-05-08 15:42:04 +02:00
|
|
|
|
# The variable fullname_syntax_DOS is a regexp which matches a DOS path
|
|
|
|
|
# ie. a:\foo\ && a:foo\
|
2008-09-13 19:54:06 +02:00
|
|
|
|
set fullname_syntax_DOS {[a-zA-Z]:[^\n]*\\}
|
2005-05-08 15:42:04 +02:00
|
|
|
|
# The variable fullname_syntax is a regexp which matches what GDB considers
|
|
|
|
|
# an absolute path. It is currently debatable if the Windows style paths
|
|
|
|
|
# d:foo and \abc should be considered valid as an absolute path.
|
|
|
|
|
# Also, the purpse of this regexp is not to recognize a well formed
|
|
|
|
|
# absolute path, but to say with certainty that a path is absolute.
|
|
|
|
|
set fullname_syntax "($fullname_syntax_POSIX|$fullname_syntax_UNC|$fullname_syntax_DOS_CASE|$fullname_syntax_DOS)"
|
|
|
|
|
|
2000-11-17 17:37:48 +01:00
|
|
|
|
# Needed for some tests under Cygwin.
|
|
|
|
|
global EXEEXT
|
|
|
|
|
global env
|
|
|
|
|
|
|
|
|
|
if ![info exists env(EXEEXT)] {
|
|
|
|
|
set EXEEXT ""
|
|
|
|
|
} else {
|
|
|
|
|
set EXEEXT $env(EXEEXT)
|
|
|
|
|
}
|
|
|
|
|
|
2008-01-23 07:20:34 +01:00
|
|
|
|
set octal "\[0-7\]+"
|
|
|
|
|
|
2011-03-09 15:17:05 +01:00
|
|
|
|
set inferior_exited_re "(\\\[Inferior \[0-9\]+ \\(.*\\) exited)"
|
2011-03-07 17:03:04 +01:00
|
|
|
|
|
Further cleanup/modernization of gdb.base/commands.exp
- Use multi_line for matching multi-line GDB output.
- Add a multi_line_input variant of multi_line to build GDB input and
use it throughout.
(The two changes above make the tests much more readable, IMO.)
- Add a new valnum_re global to get rid of the multiple "\\\$\[0-9\]*".
- Remove gdb_stop_suppressing_tests uses.
- tighten a few regexps.
- Replace send_gdb/gdb_expect with gdb_test_multiple and simplify,
making pass/fail messages the same.
gdb/ChangeLog:
2016-11-09 Pedro Alves <palves@redhat.com>
* gdb.base/commands.exp (runto_or_return): New procedure.
(gdbvar_simple_if_test, gdbvar_simple_while_test)
(gdbvar_complex_if_while_test, progvar_simple_if_test)
(progvar_simple_while_test, progvar_complex_if_while_test)
(if_while_breakpoint_command_test)
(infrun_breakpoint_command_test, breakpoint_command_test)
(user_defined_command_test, watchpoint_command_test)
(test_command_prompt_position, redefine_hook_test)
(stray_arg0_test, error_clears_commands_left, redefine_hook_test)
(redefine_backtrace_test): Use runto_or_return, $valnum_re,
multi_line_input and multi_line. Remove gdb_expect and
gdb_stop_suppressing_tests uses.
* lib/gdb.exp (valnum_re): New global.
* lib/gdb.exp (valnum_re): New global.
(multi_line_input): New procedure.
2016-11-09 19:48:25 +01:00
|
|
|
|
# A regular expression that matches a value history number.
|
|
|
|
|
# E.g., $1, $2, etc.
|
|
|
|
|
set valnum_re "\\\$$decimal"
|
|
|
|
|
|
1999-06-28 18:06:02 +02:00
|
|
|
|
### Only procedures should come after this point.
|
|
|
|
|
|
1999-04-16 03:35:26 +02:00
|
|
|
|
#
|
|
|
|
|
# gdb_version -- extract and print the version number of GDB
|
|
|
|
|
#
|
|
|
|
|
proc default_gdb_version {} {
|
|
|
|
|
global GDB
|
2008-11-11 02:23:34 +01:00
|
|
|
|
global INTERNAL_GDBFLAGS GDBFLAGS
|
1999-04-16 03:35:26 +02:00
|
|
|
|
global gdb_prompt
|
introduce parallel mode
This introduces parallel mode for the test suite.
It doesn't fully work yet in the sense that if you do a fully parallel
run, you will encounter some file-name clashes, but this has to start
somewhere, and it seemed best to add some infrastructure now, so that
you can follow along and test subsequent patches if you care to.
This patch has two parts.
First, it checks for the GDB_PARALLEL variable. If this is set (say,
on the runtest command line), then the test suite assumes "parallel
mode". In this mode, files are put into a subdirectory named after
the test. That is, for DIR/TEST.exp, the outputs are put into
./outputs/DIR/TEST/.
This first part has various follow-on changes coming in subsequent
patches. This is why the code in this patch also makes "temp" and
"cache" directories.
Second, this adds an "inotify" mode. If you have the inotifywait
command (part of inotify-tools), you can set the GDB_INOTIFY variable.
This will tell the test suite to watch for changes outside of the
allowed output directories.
This mode is useful for debugging the test suite, as it issues a
report whenever a possibly parallel-unsafe file open is done.
2013-08-13 Tom Tromey <tromey@redhat.com>
Yao Qi <yao@codesourcery.com>
* lib/cache.exp (gdb_do_cache): Handle GDB_PARALLEL.
* lib/gdb.exp: Handle GDB_PARALLEL.
(default_gdb_version): Kill inotify_pid if it exists.
(default_gdb_exit): Emit warning if the inotify log is not
empty.
(standard_output_file): Respect GDB_PARALLEL.
(standard_temp_file): Likewise.
(gdb_init): Start inotifywait if requested.
* gdbint.texinfo (Testsuite): Use @table, not @itemize.
Document GDB_PARALLEL and GDB_INOTIFY.
2013-08-13 18:12:04 +02:00
|
|
|
|
global inotify_pid
|
|
|
|
|
|
|
|
|
|
if {[info exists inotify_pid]} {
|
|
|
|
|
eval exec kill $inotify_pid
|
|
|
|
|
}
|
|
|
|
|
|
2009-11-10 21:54:55 +01:00
|
|
|
|
set output [remote_exec host "$GDB $INTERNAL_GDBFLAGS --version"]
|
2013-06-07 19:31:09 +02:00
|
|
|
|
set tmp [lindex $output 1]
|
1999-04-16 03:35:26 +02:00
|
|
|
|
set version ""
|
|
|
|
|
regexp " \[0-9\]\[^ \t\n\r\]+" "$tmp" version
|
|
|
|
|
if ![is_remote host] {
|
2008-11-11 02:23:34 +01:00
|
|
|
|
clone_output "[which $GDB] version $version $INTERNAL_GDBFLAGS $GDBFLAGS\n"
|
1999-04-16 03:35:26 +02:00
|
|
|
|
} else {
|
2008-11-11 02:23:34 +01:00
|
|
|
|
clone_output "$GDB on remote host version $version $INTERNAL_GDBFLAGS $GDBFLAGS\n"
|
1999-04-16 03:35:26 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
proc gdb_version { } {
|
gdb/testsuite/
* config/monitor.exp (gdb_target_cmd): Remove semicolon after
'return'.
(gdb_target_monitor, gdb_load): Likewise.
* config/sid.exp (gdb_load): Likewise.
* config/slite.exp (gdb_load): Likewise.
* config/vx.exp (gdb_start, spawn_vxgdb): Likewise.
* gdb.ada/arrayidx.exp, gdb.ada/null_array.exp: Likewise.
* gdb.arch/mips-octeon-bbit.exp (single_step): Likewise.
(single_step_until): Likewise.
* gdb.arch/powerpc-d128-regs.exp: Likewise.
* gdb.arch/system-gcore.exp: Likewise.
* gdb.base/bigcore.exp (extract_heap): Likewise.
* gdb.base/break-on-linker-gcd-function.exp: Likewise.
* gdb.base/call-ar-st.exp: Likewise.
* gdb.base/call-rt-st.exp: Likewise.
* gdb.base/call-sc.exp, gdb.base/call-strs.exp: Likewise.
* gdb.base/callfuncs.exp, gdb.base/completion.exp: Likewise.
* gdb.base/condbreak.exp, gdb.base/constvars.exp: Likewise.
* gdb.base/corefile.exp: Likewise.
* gdb.base/dbx.exp (gdb_file_cmd): Likewise.
* gdb.base/exprs.exp, gdb.base/fileio.exp: Likewise.
* gdb.base/fixsection.exp: Likewise.
* gdb.base/funcargs.exp: Likewise.
* gdb.base/gcore-buffer-overflow.exp: Likewise.
* gdb.base/gcore-relro.exp: Likewise.
* gdb.base/gcore.exp, gdb.base/gdb11530.exp: Likewise.
* gdb.base/gdb11531.exp, gdb.base/gnu-ifunc.exp: Likewise.
* gdb.base/info-os.exp, gdb.base/info-proc.exp: Likewise.
* gdb.base/interp.exp, gdb.base/langs.exp:: Likewise.
* gdb.base/list.exp: Likewise.
(set_listsize): Likewise.
* gdb.base/logical.exp, gdb.base/mips_pro.exp: Likewise.
* gdb.base/miscexprs.exp, gdb.base/nodebug.exp: Likewise.
* gdb.base/opaque.exp, gdb.base/pointers.exp: Likewise.
* gdb.base/psymtab.exp, gdb.base/ptype.exp: Likewise.
* gdb.base/relational.exp, gdb.base/scope.exp: Likewise.
* gdb.base/setvar.exp: Likewise.
(test_set): Likewise.
* gdb.base/signals.exp, gdb.base/sizeof.exp: Likewise.
* gdb.base/solib-overlap.exp: Likewise.
* gdb.base/store.exp, gdb.base/structs.exp: Likewise.
* gdb.base/structs2.exp, gdb.base/volatile.exp: Likewise.
* gdb.base/watchpoint.exp (initialize): Likewise.
(test_simple_watchpoint): Likewise.
(test_disabling_watchpoints): Likewise.
(test_watchpoint_triggered_in_syscall): Likewise.
* gdb.base/whatis.exp, gdb.cp/ambiguous.exp: Likewise.
* gdb.cp/casts.exp, gdb.cp/ctti.exp: Likewise.
* gdb.cp/namespace.exp, gdb.cp/nsdecl.exp: Likewise.
* gdb.cp/psmang.exp, gdb.dwarf2/dw2-ranges.exp: Likewise.
* gdb.hp/gdb.aCC/optimize.exp: Likewise.
* gdb.hp/gdb.aCC/watch-cmd.exp: Likewise.
* gdb.hp/gdb.base-hp/callfwmall.exp: Likewise.
* gdb.hp/gdb.base-hp/pxdb.exp: Likewise.
* gdb.hp/gdb.compat/xdb1.exp: Likewise.
* gdb.hp/gdb.compat/xdb2.exp: Likewise.
* gdb.hp/gdb.compat/xdb3.exp: Likewise.
* gdb.hp/gdb.defects/bs14602.exp: Likewise.
* gdb.hp/gdb.defects/solib-d.exp: Likewise.
* gdb.mi/gdb792.exp: Likewise.
* gdb.mi/mi-inheritance-syntax-error.exp: Likewise.
* gdb.mi/mi-logging.exp, gdb.mi/mi-var-cp.exp : Likewise.
* gdb.mi/mi-var-rtti.exp, gdb.python/py-type.exp: Likewise.
* gdb.threads/gcore-thread.exp: Likewise.
(load_core): Likewise.
* gdb.threads/pthreads.exp (all_threads_running): Likewise.
(test_startup, check_control_c): Likewise.
* gdb.threads/sigstep-threads.exp: Likewise.
* gdb.threads/thread_check.exp: Likewise.
* gdb.trace/backtrace.exp, gdb.trace/change-loc.exp: Likewise.
* gdb.trace/circ.exp (run_trace_experiment): Likewise.
(set_a_tracepoint, trace_buffer_normal): Likewise.
(gdb_trace_circular_tests): Likewise.
* gdb.trace/collection.exp: Likewise.
* gdb.trace/disconnected-tracing.exp: Likewise.
* gdb.trace/infotrace.exp: Likewise.
* gdb.trace/mi-traceframe-changed.exp: Likewise.
* gdb.trace/mi-tracepoint-changed.exp: Likewise.
* gdb.trace/mi-tsv-changed.exp (test_create_delete_modify_tsv): Likewise.
* gdb.trace/packetlen.exp, gdb.trace/passc-dyn.exp: Likewise.
* gdb.trace/pending.exp, gdb.trace/report.exp: Likewise.
* gdb.trace/stap-trace.exp: Likewise.
* gdb.trace/status-stop.exp,gdb.trace/strace.exp: Likewise.
* gdb.trace/tfind.exp, gdb.trace/trace-break.exp: Likewise.
* gdb.trace/trace-buffer-size.exp: Likewise.
* gdb.trace/tspeed.exp, gdb.trace/tsv.exp: Likewise.
* gdb.trace/unavailable.exp: Likewise.
* gdb.trace/while-dyn.exp: Likewise.
* lib/fortran.exp (set_lang_fortran): Likewise.
* lib/gdb.exp (default_gdb_version, gdb_start_cmd): Likewise.
(gdb_breakpoint, gdb_reinitialize_dir): Likewise.
(default_gdb_start, get_compiler_info): Likewise.
(gdb_compile, gdb_compile_objc, gdb_reload, gdb_init): Likewise.
(get_debug_format, setup_xfail_format): Likewise.
(rerun_to_main, gdb_skip_float_test): Likewise.
(build_id_debug_filename_get, get_remotetimeout): Likewise.
* lib/java.exp (set_lang_java): Likewise.
* lib/mi-support.exp (default_mi_gdb_start): Likewise.
(mi_gdb_reinitialize_dir, mi_gdb_target_cmd): Likewise.
(mi_gdb_file_cmd, mi_gdb_test): Likewise.
(mi_run_cmd_full, mi_expect_interrupt): Likewise.
* lib/objc.exp (set_lang_objc): Likewise.
* lib/pascal.exp (set_lang_pascal): Likewise.
* lib/prompt.exp (default_prompt_gdb_start): Likewise.
* lib/trace-support.exp (gdb_trace_setactions, gdb_tfind_test): Likewise.
(gdb_readexpr, gdb_gettpnum, gdb_find_recursion_test_baseline): Likewise.
2013-03-14 14:34:06 +01:00
|
|
|
|
return [default_gdb_version]
|
1999-04-16 03:35:26 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#
|
|
|
|
|
# gdb_unload -- unload a file if one is loaded
|
2012-11-26 20:23:56 +01:00
|
|
|
|
# Return 0 on success, -1 on error.
|
1999-04-16 03:35:26 +02:00
|
|
|
|
#
|
|
|
|
|
|
|
|
|
|
proc gdb_unload {} {
|
|
|
|
|
global verbose
|
|
|
|
|
global GDB
|
|
|
|
|
global gdb_prompt
|
|
|
|
|
send_gdb "file\n"
|
|
|
|
|
gdb_expect 60 {
|
|
|
|
|
-re "No executable file now\[^\r\n\]*\[\r\n\]" { exp_continue }
|
|
|
|
|
-re "No symbol file now\[^\r\n\]*\[\r\n\]" { exp_continue }
|
2011-03-15 17:41:42 +01:00
|
|
|
|
-re "A program is being debugged already.*Are you sure you want to change the file.*y or n. $" {
|
2019-05-17 17:30:09 +02:00
|
|
|
|
send_gdb "y\n" answer
|
1999-04-16 03:35:26 +02:00
|
|
|
|
exp_continue
|
|
|
|
|
}
|
|
|
|
|
-re "Discard symbol table from .*y or n.*$" {
|
2019-05-17 17:30:09 +02:00
|
|
|
|
send_gdb "y\n" answer
|
1999-04-16 03:35:26 +02:00
|
|
|
|
exp_continue
|
|
|
|
|
}
|
|
|
|
|
-re "$gdb_prompt $" {}
|
|
|
|
|
timeout {
|
2012-10-02 19:17:45 +02:00
|
|
|
|
perror "couldn't unload file in $GDB (timeout)."
|
1999-04-16 03:35:26 +02:00
|
|
|
|
return -1
|
|
|
|
|
}
|
|
|
|
|
}
|
2012-11-26 20:23:56 +01:00
|
|
|
|
return 0
|
1999-04-16 03:35:26 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# Many of the tests depend on setting breakpoints at various places and
|
|
|
|
|
# running until that breakpoint is reached. At times, we want to start
|
|
|
|
|
# with a clean-slate with respect to breakpoints, so this utility proc
|
|
|
|
|
# lets us do this without duplicating this code everywhere.
|
|
|
|
|
#
|
|
|
|
|
|
|
|
|
|
proc delete_breakpoints {} {
|
|
|
|
|
global gdb_prompt
|
|
|
|
|
|
1999-08-03 01:48:37 +02:00
|
|
|
|
# we need a larger timeout value here or this thing just confuses
|
|
|
|
|
# itself. May need a better implementation if possible. - guo
|
|
|
|
|
#
|
2015-02-23 18:35:09 +01:00
|
|
|
|
set timeout 100
|
|
|
|
|
|
|
|
|
|
set msg "delete all breakpoints in delete_breakpoints"
|
|
|
|
|
set deleted 0
|
|
|
|
|
gdb_test_multiple "delete breakpoints" "$msg" {
|
|
|
|
|
-re "Delete all breakpoints.*y or n.*$" {
|
2019-05-17 17:30:09 +02:00
|
|
|
|
send_gdb "y\n" answer
|
1999-04-16 03:35:26 +02:00
|
|
|
|
exp_continue
|
|
|
|
|
}
|
2015-02-23 18:35:09 +01:00
|
|
|
|
-re "$gdb_prompt $" {
|
|
|
|
|
set deleted 1
|
|
|
|
|
}
|
1999-04-16 03:35:26 +02:00
|
|
|
|
}
|
2015-02-23 18:35:09 +01:00
|
|
|
|
|
|
|
|
|
if {$deleted} {
|
|
|
|
|
# Confirm with "info breakpoints".
|
|
|
|
|
set deleted 0
|
|
|
|
|
set msg "info breakpoints"
|
|
|
|
|
gdb_test_multiple $msg $msg {
|
|
|
|
|
-re "No breakpoints or watchpoints..*$gdb_prompt $" {
|
|
|
|
|
set deleted 1
|
|
|
|
|
}
|
|
|
|
|
-re "$gdb_prompt $" {
|
|
|
|
|
}
|
1999-04-16 03:35:26 +02:00
|
|
|
|
}
|
2015-02-23 18:35:09 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if {!$deleted} {
|
|
|
|
|
perror "breakpoints not deleted"
|
1999-04-16 03:35:26 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-10-12 19:20:25 +02:00
|
|
|
|
# Returns true iff the target supports using the "run" command.
|
|
|
|
|
|
|
|
|
|
proc target_can_use_run_cmd {} {
|
|
|
|
|
if [target_info exists use_gdb_stub] {
|
|
|
|
|
# In this case, when we connect, the inferior is already
|
|
|
|
|
# running.
|
|
|
|
|
return 0
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# Assume yes.
|
|
|
|
|
return 1
|
|
|
|
|
}
|
|
|
|
|
|
1999-04-16 03:35:26 +02:00
|
|
|
|
# Generic run command.
|
|
|
|
|
#
|
|
|
|
|
# The second pattern below matches up to the first newline *only*.
|
|
|
|
|
# Using ``.*$'' could swallow up output that we attempt to match
|
|
|
|
|
# elsewhere.
|
|
|
|
|
#
|
2011-12-03 19:01:50 +01:00
|
|
|
|
# N.B. This function does not wait for gdb to return to the prompt,
|
|
|
|
|
# that is the caller's responsibility.
|
|
|
|
|
|
1999-04-16 03:35:26 +02:00
|
|
|
|
proc gdb_run_cmd {args} {
|
2011-12-03 21:20:29 +01:00
|
|
|
|
global gdb_prompt use_gdb_stub
|
1999-04-16 03:35:26 +02:00
|
|
|
|
|
2014-07-12 02:22:25 +02:00
|
|
|
|
foreach command [gdb_init_commands] {
|
|
|
|
|
send_gdb "$command\n"
|
1999-04-16 03:35:26 +02:00
|
|
|
|
gdb_expect 30 {
|
|
|
|
|
-re "$gdb_prompt $" { }
|
|
|
|
|
default {
|
2013-06-07 19:31:09 +02:00
|
|
|
|
perror "gdb_init_command for target failed"
|
|
|
|
|
return
|
1999-04-16 03:35:26 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2011-12-03 21:20:29 +01:00
|
|
|
|
if $use_gdb_stub {
|
1999-04-16 03:35:26 +02:00
|
|
|
|
if [target_info exists gdb,do_reload_on_run] {
|
2007-03-27 19:59:38 +02:00
|
|
|
|
if { [gdb_reload] != 0 } {
|
2013-06-07 19:31:09 +02:00
|
|
|
|
return
|
1999-10-19 04:47:02 +02:00
|
|
|
|
}
|
2013-06-07 19:31:09 +02:00
|
|
|
|
send_gdb "continue\n"
|
1999-04-16 03:35:26 +02:00
|
|
|
|
gdb_expect 60 {
|
|
|
|
|
-re "Continu\[^\r\n\]*\[\r\n\]" {}
|
|
|
|
|
default {}
|
|
|
|
|
}
|
2013-06-07 19:31:09 +02:00
|
|
|
|
return
|
1999-04-16 03:35:26 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if [target_info exists gdb,start_symbol] {
|
2013-06-07 19:31:09 +02:00
|
|
|
|
set start [target_info gdb,start_symbol]
|
1999-04-16 03:35:26 +02:00
|
|
|
|
} else {
|
2013-06-07 19:31:09 +02:00
|
|
|
|
set start "start"
|
1999-04-16 03:35:26 +02:00
|
|
|
|
}
|
|
|
|
|
send_gdb "jump *$start\n"
|
2013-06-07 19:31:09 +02:00
|
|
|
|
set start_attempt 1
|
1999-10-19 04:47:02 +02:00
|
|
|
|
while { $start_attempt } {
|
|
|
|
|
# Cap (re)start attempts at three to ensure that this loop
|
|
|
|
|
# always eventually fails. Don't worry about trying to be
|
|
|
|
|
# clever and not send a command when it has failed.
|
|
|
|
|
if [expr $start_attempt > 3] {
|
2013-06-07 19:31:09 +02:00
|
|
|
|
perror "Jump to start() failed (retry count exceeded)"
|
|
|
|
|
return
|
1999-04-16 03:35:26 +02:00
|
|
|
|
}
|
2013-06-07 19:31:09 +02:00
|
|
|
|
set start_attempt [expr $start_attempt + 1]
|
1999-10-19 04:47:02 +02:00
|
|
|
|
gdb_expect 30 {
|
|
|
|
|
-re "Continuing at \[^\r\n\]*\[\r\n\]" {
|
2013-06-07 19:31:09 +02:00
|
|
|
|
set start_attempt 0
|
1999-10-19 04:47:02 +02:00
|
|
|
|
}
|
|
|
|
|
-re "No symbol \"_start\" in current.*$gdb_prompt $" {
|
2013-06-07 19:31:09 +02:00
|
|
|
|
perror "Can't find start symbol to run in gdb_run"
|
|
|
|
|
return
|
1999-10-19 04:47:02 +02:00
|
|
|
|
}
|
|
|
|
|
-re "No symbol \"start\" in current.*$gdb_prompt $" {
|
2013-06-07 19:31:09 +02:00
|
|
|
|
send_gdb "jump *_start\n"
|
1999-10-19 04:47:02 +02:00
|
|
|
|
}
|
|
|
|
|
-re "No symbol.*context.*$gdb_prompt $" {
|
2013-06-07 19:31:09 +02:00
|
|
|
|
set start_attempt 0
|
1999-10-19 04:47:02 +02:00
|
|
|
|
}
|
|
|
|
|
-re "Line.* Jump anyway.*y or n. $" {
|
2019-05-17 17:30:09 +02:00
|
|
|
|
send_gdb "y\n" answer
|
1999-10-19 04:47:02 +02:00
|
|
|
|
}
|
|
|
|
|
-re "The program is not being run.*$gdb_prompt $" {
|
2007-03-27 19:59:38 +02:00
|
|
|
|
if { [gdb_reload] != 0 } {
|
2013-06-07 19:31:09 +02:00
|
|
|
|
return
|
1999-10-19 04:47:02 +02:00
|
|
|
|
}
|
2013-06-07 19:31:09 +02:00
|
|
|
|
send_gdb "jump *$start\n"
|
1999-10-19 04:47:02 +02:00
|
|
|
|
}
|
|
|
|
|
timeout {
|
2013-06-07 19:31:09 +02:00
|
|
|
|
perror "Jump to start() failed (timeout)"
|
1999-10-19 04:47:02 +02:00
|
|
|
|
return
|
|
|
|
|
}
|
1999-04-16 03:35:26 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return
|
|
|
|
|
}
|
2004-02-08 04:56:15 +01:00
|
|
|
|
|
|
|
|
|
if [target_info exists gdb,do_reload_on_run] {
|
2007-03-27 19:59:38 +02:00
|
|
|
|
if { [gdb_reload] != 0 } {
|
2013-06-07 19:31:09 +02:00
|
|
|
|
return
|
2004-02-08 04:56:15 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
1999-04-16 03:35:26 +02:00
|
|
|
|
send_gdb "run $args\n"
|
|
|
|
|
# This doesn't work quite right yet.
|
2007-10-09 17:08:02 +02:00
|
|
|
|
# Use -notransfer here so that test cases (like chng-sym.exp)
|
|
|
|
|
# may test for additional start-up messages.
|
|
|
|
|
gdb_expect 60 {
|
1999-04-16 03:35:26 +02:00
|
|
|
|
-re "The program .* has been started already.*y or n. $" {
|
2019-05-17 17:30:09 +02:00
|
|
|
|
send_gdb "y\n" answer
|
1999-04-16 03:35:26 +02:00
|
|
|
|
exp_continue
|
|
|
|
|
}
|
2007-03-16 16:29:00 +01:00
|
|
|
|
-notransfer -re "Starting program: \[^\r\n\]*" {}
|
2010-06-11 23:58:20 +02:00
|
|
|
|
-notransfer -re "$gdb_prompt $" {
|
|
|
|
|
# There is no more input expected.
|
|
|
|
|
}
|
1999-04-16 03:35:26 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2007-03-27 19:59:38 +02:00
|
|
|
|
# Generic start command. Return 0 if we could start the program, -1
|
|
|
|
|
# if we could not.
|
2011-12-03 19:01:50 +01:00
|
|
|
|
#
|
|
|
|
|
# N.B. This function does not wait for gdb to return to the prompt,
|
|
|
|
|
# that is the caller's responsibility.
|
2007-03-27 19:59:38 +02:00
|
|
|
|
|
|
|
|
|
proc gdb_start_cmd {args} {
|
2011-12-03 21:20:29 +01:00
|
|
|
|
global gdb_prompt use_gdb_stub
|
2007-03-27 19:59:38 +02:00
|
|
|
|
|
2014-07-12 02:22:25 +02:00
|
|
|
|
foreach command [gdb_init_commands] {
|
|
|
|
|
send_gdb "$command\n"
|
2007-03-27 19:59:38 +02:00
|
|
|
|
gdb_expect 30 {
|
|
|
|
|
-re "$gdb_prompt $" { }
|
|
|
|
|
default {
|
2013-06-07 19:31:09 +02:00
|
|
|
|
perror "gdb_init_command for target failed"
|
gdb/testsuite/
* config/monitor.exp (gdb_target_cmd): Remove semicolon after
'return'.
(gdb_target_monitor, gdb_load): Likewise.
* config/sid.exp (gdb_load): Likewise.
* config/slite.exp (gdb_load): Likewise.
* config/vx.exp (gdb_start, spawn_vxgdb): Likewise.
* gdb.ada/arrayidx.exp, gdb.ada/null_array.exp: Likewise.
* gdb.arch/mips-octeon-bbit.exp (single_step): Likewise.
(single_step_until): Likewise.
* gdb.arch/powerpc-d128-regs.exp: Likewise.
* gdb.arch/system-gcore.exp: Likewise.
* gdb.base/bigcore.exp (extract_heap): Likewise.
* gdb.base/break-on-linker-gcd-function.exp: Likewise.
* gdb.base/call-ar-st.exp: Likewise.
* gdb.base/call-rt-st.exp: Likewise.
* gdb.base/call-sc.exp, gdb.base/call-strs.exp: Likewise.
* gdb.base/callfuncs.exp, gdb.base/completion.exp: Likewise.
* gdb.base/condbreak.exp, gdb.base/constvars.exp: Likewise.
* gdb.base/corefile.exp: Likewise.
* gdb.base/dbx.exp (gdb_file_cmd): Likewise.
* gdb.base/exprs.exp, gdb.base/fileio.exp: Likewise.
* gdb.base/fixsection.exp: Likewise.
* gdb.base/funcargs.exp: Likewise.
* gdb.base/gcore-buffer-overflow.exp: Likewise.
* gdb.base/gcore-relro.exp: Likewise.
* gdb.base/gcore.exp, gdb.base/gdb11530.exp: Likewise.
* gdb.base/gdb11531.exp, gdb.base/gnu-ifunc.exp: Likewise.
* gdb.base/info-os.exp, gdb.base/info-proc.exp: Likewise.
* gdb.base/interp.exp, gdb.base/langs.exp:: Likewise.
* gdb.base/list.exp: Likewise.
(set_listsize): Likewise.
* gdb.base/logical.exp, gdb.base/mips_pro.exp: Likewise.
* gdb.base/miscexprs.exp, gdb.base/nodebug.exp: Likewise.
* gdb.base/opaque.exp, gdb.base/pointers.exp: Likewise.
* gdb.base/psymtab.exp, gdb.base/ptype.exp: Likewise.
* gdb.base/relational.exp, gdb.base/scope.exp: Likewise.
* gdb.base/setvar.exp: Likewise.
(test_set): Likewise.
* gdb.base/signals.exp, gdb.base/sizeof.exp: Likewise.
* gdb.base/solib-overlap.exp: Likewise.
* gdb.base/store.exp, gdb.base/structs.exp: Likewise.
* gdb.base/structs2.exp, gdb.base/volatile.exp: Likewise.
* gdb.base/watchpoint.exp (initialize): Likewise.
(test_simple_watchpoint): Likewise.
(test_disabling_watchpoints): Likewise.
(test_watchpoint_triggered_in_syscall): Likewise.
* gdb.base/whatis.exp, gdb.cp/ambiguous.exp: Likewise.
* gdb.cp/casts.exp, gdb.cp/ctti.exp: Likewise.
* gdb.cp/namespace.exp, gdb.cp/nsdecl.exp: Likewise.
* gdb.cp/psmang.exp, gdb.dwarf2/dw2-ranges.exp: Likewise.
* gdb.hp/gdb.aCC/optimize.exp: Likewise.
* gdb.hp/gdb.aCC/watch-cmd.exp: Likewise.
* gdb.hp/gdb.base-hp/callfwmall.exp: Likewise.
* gdb.hp/gdb.base-hp/pxdb.exp: Likewise.
* gdb.hp/gdb.compat/xdb1.exp: Likewise.
* gdb.hp/gdb.compat/xdb2.exp: Likewise.
* gdb.hp/gdb.compat/xdb3.exp: Likewise.
* gdb.hp/gdb.defects/bs14602.exp: Likewise.
* gdb.hp/gdb.defects/solib-d.exp: Likewise.
* gdb.mi/gdb792.exp: Likewise.
* gdb.mi/mi-inheritance-syntax-error.exp: Likewise.
* gdb.mi/mi-logging.exp, gdb.mi/mi-var-cp.exp : Likewise.
* gdb.mi/mi-var-rtti.exp, gdb.python/py-type.exp: Likewise.
* gdb.threads/gcore-thread.exp: Likewise.
(load_core): Likewise.
* gdb.threads/pthreads.exp (all_threads_running): Likewise.
(test_startup, check_control_c): Likewise.
* gdb.threads/sigstep-threads.exp: Likewise.
* gdb.threads/thread_check.exp: Likewise.
* gdb.trace/backtrace.exp, gdb.trace/change-loc.exp: Likewise.
* gdb.trace/circ.exp (run_trace_experiment): Likewise.
(set_a_tracepoint, trace_buffer_normal): Likewise.
(gdb_trace_circular_tests): Likewise.
* gdb.trace/collection.exp: Likewise.
* gdb.trace/disconnected-tracing.exp: Likewise.
* gdb.trace/infotrace.exp: Likewise.
* gdb.trace/mi-traceframe-changed.exp: Likewise.
* gdb.trace/mi-tracepoint-changed.exp: Likewise.
* gdb.trace/mi-tsv-changed.exp (test_create_delete_modify_tsv): Likewise.
* gdb.trace/packetlen.exp, gdb.trace/passc-dyn.exp: Likewise.
* gdb.trace/pending.exp, gdb.trace/report.exp: Likewise.
* gdb.trace/stap-trace.exp: Likewise.
* gdb.trace/status-stop.exp,gdb.trace/strace.exp: Likewise.
* gdb.trace/tfind.exp, gdb.trace/trace-break.exp: Likewise.
* gdb.trace/trace-buffer-size.exp: Likewise.
* gdb.trace/tspeed.exp, gdb.trace/tsv.exp: Likewise.
* gdb.trace/unavailable.exp: Likewise.
* gdb.trace/while-dyn.exp: Likewise.
* lib/fortran.exp (set_lang_fortran): Likewise.
* lib/gdb.exp (default_gdb_version, gdb_start_cmd): Likewise.
(gdb_breakpoint, gdb_reinitialize_dir): Likewise.
(default_gdb_start, get_compiler_info): Likewise.
(gdb_compile, gdb_compile_objc, gdb_reload, gdb_init): Likewise.
(get_debug_format, setup_xfail_format): Likewise.
(rerun_to_main, gdb_skip_float_test): Likewise.
(build_id_debug_filename_get, get_remotetimeout): Likewise.
* lib/java.exp (set_lang_java): Likewise.
* lib/mi-support.exp (default_mi_gdb_start): Likewise.
(mi_gdb_reinitialize_dir, mi_gdb_target_cmd): Likewise.
(mi_gdb_file_cmd, mi_gdb_test): Likewise.
(mi_run_cmd_full, mi_expect_interrupt): Likewise.
* lib/objc.exp (set_lang_objc): Likewise.
* lib/pascal.exp (set_lang_pascal): Likewise.
* lib/prompt.exp (default_prompt_gdb_start): Likewise.
* lib/trace-support.exp (gdb_trace_setactions, gdb_tfind_test): Likewise.
(gdb_readexpr, gdb_gettpnum, gdb_find_recursion_test_baseline): Likewise.
2013-03-14 14:34:06 +01:00
|
|
|
|
return -1
|
2007-03-27 19:59:38 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2011-12-03 21:20:29 +01:00
|
|
|
|
if $use_gdb_stub {
|
2007-03-27 19:59:38 +02:00
|
|
|
|
return -1
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
send_gdb "start $args\n"
|
2010-01-08 13:03:36 +01:00
|
|
|
|
# Use -notransfer here so that test cases (like chng-sym.exp)
|
|
|
|
|
# may test for additional start-up messages.
|
2007-03-27 19:59:38 +02:00
|
|
|
|
gdb_expect 60 {
|
|
|
|
|
-re "The program .* has been started already.*y or n. $" {
|
2019-05-17 17:30:09 +02:00
|
|
|
|
send_gdb "y\n" answer
|
2007-03-27 19:59:38 +02:00
|
|
|
|
exp_continue
|
|
|
|
|
}
|
|
|
|
|
-notransfer -re "Starting program: \[^\r\n\]*" {
|
|
|
|
|
return 0
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return -1
|
|
|
|
|
}
|
|
|
|
|
|
2017-09-11 23:57:37 +02:00
|
|
|
|
# Generic starti command. Return 0 if we could start the program, -1
|
|
|
|
|
# if we could not.
|
|
|
|
|
#
|
|
|
|
|
# N.B. This function does not wait for gdb to return to the prompt,
|
|
|
|
|
# that is the caller's responsibility.
|
|
|
|
|
|
|
|
|
|
proc gdb_starti_cmd {args} {
|
|
|
|
|
global gdb_prompt use_gdb_stub
|
|
|
|
|
|
|
|
|
|
foreach command [gdb_init_commands] {
|
|
|
|
|
send_gdb "$command\n"
|
|
|
|
|
gdb_expect 30 {
|
|
|
|
|
-re "$gdb_prompt $" { }
|
|
|
|
|
default {
|
|
|
|
|
perror "gdb_init_command for target failed"
|
|
|
|
|
return -1
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if $use_gdb_stub {
|
|
|
|
|
return -1
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
send_gdb "starti $args\n"
|
|
|
|
|
gdb_expect 60 {
|
|
|
|
|
-re "The program .* has been started already.*y or n. $" {
|
2019-05-17 17:30:09 +02:00
|
|
|
|
send_gdb "y\n" answer
|
2017-09-11 23:57:37 +02:00
|
|
|
|
exp_continue
|
|
|
|
|
}
|
|
|
|
|
-re "Starting program: \[^\r\n\]*" {
|
|
|
|
|
return 0
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return -1
|
|
|
|
|
}
|
|
|
|
|
|
2004-03-24 19:41:50 +01:00
|
|
|
|
# Set a breakpoint at FUNCTION. If there is an additional argument it is
|
2008-05-04 06:04:11 +02:00
|
|
|
|
# a list of options; the supported options are allow-pending, temporary,
|
Make "break foo" find "A::foo", A::B::foo", etc. [C++ and wild matching]
This patch teaches GDB about setting breakpoints in all scopes
(namespaces and classes) by default.
Here's a contrived example:
(gdb) b func<tab>
(anonymous namespace)::A::function() Bn::(anonymous namespace)::B::function() function(int, int)
(anonymous namespace)::B::function() Bn::(anonymous namespace)::function() gdb::(anonymous namespace)::A::function()
(anonymous namespace)::B::function() const Bn::(anonymous namespace)::function(int, int) gdb::(anonymous namespace)::function()
(anonymous namespace)::function() Bn::B::func() gdb::(anonymous namespace)::function(int, int)
(anonymous namespace)::function(int, int) Bn::B::function() gdb::A::func()
A::func() Bn::func() gdb::A::function()
A::function() Bn::function() gdb::func()
B::func() Bn::function(int, int) gdb::function()
B::function() Bn::function(long) gdb::function(int, int)
B::function() const func() gdb::function(long)
B::function_const() const function()
(gdb) b function
Breakpoint 1 at 0x4005ce: function. (26 locations)
(gdb) b B::function<tab>
(anonymous namespace)::B::function() B::function() const Bn::B::function()
(anonymous namespace)::B::function() const B::function_const() const
B::function() Bn::(anonymous namespace)::B::function()
(gdb) b B::function
Breakpoint 1 at 0x40072c: B::function. (6 locations)
To get back the original behavior of interpreting the function name as
a fully-qualified name, you can use the new "-qualified" (or "-q")
option/flag (added by this commit). For example:
(gdb) b B::function
(anonymous namespace)::B::function() B::function() const Bn::B::function()
(anonymous namespace)::B::function() const B::function_const() const
B::function() Bn::(anonymous namespace)::B::function()
vs:
(gdb) b -qualified B::function
B::function() B::function() const B::function_const() const
I've chosen "-qualified" / "-q" because "-f" (for "full" or
"fully-qualified") is already taken for "-function".
Note: the "-qualified" option works with both linespecs and explicit
locations. I.e., these are equivalent:
(gdb) b -q func
(gdb) b -q -f func
and so are these:
(gdb) b -q filename.cc:func
(gdb) b -q -s filename.cc -f func
(gdb) b -s filename.cc -q -f func
(gdb) b -s filename.cc -f func -q
To better understand why I consider wild matching the better default,
consider what happens when we get to the point when _all_ of GDB is
wrapped under "namespace gdb {}". I have a patch series that does
that, and when I started debugging that GDB, I immediately became
frustrated. You'd have to write "b gdb::internal_error", "b
gdb::foo", "b gdb::bar", etc. etc., which gets annoying pretty
quickly. OTOH, consider how this makes it very easy to set
breakpoints in classes wrapped in anonymous namespaces. You just
don't think of them, GDB finds the symbols for you automatically.
(At the Cauldron a couple months ago, several people told me that they
run into a similar issue when debugging other C++ projects. One
example was when debugging LLVM, which puts all its code under the
"llvm" namespace.)
Implementation-wise, what the patch does is:
- makes C++ symbol name hashing only consider the last component of
a symbol name. (so that we can look up symbol names by
last-component name only).
- adds a C++ symbol name matcher for symbol_name_match_type::WILD,
which ignores missing leading specifiers / components.
- adjusts a few preexisting testsuite tests to use "-qualified" when
they mean it.
- adds new testsuite tests.
- adds unit tests.
Grows the gdb.linespec/ tests like this:
-# of expected passes 7823
+# of expected passes 8977
gdb/ChangeLog:
2017-11-29 Pedro Alves <palves@redhat.com>
* NEWS: Mention that breakpoints on C++ functions are now set on
on all namespaces/classes by default, and mention "break
-qualified".
* ax-gdb.c (agent_command_1): Adjust to pass a
symbol_name_match_type to new_linespec_location.
* breakpoint.c (parse_breakpoint_sals): Adjust to
get_linespec_location's return type change.
(strace_marker_create_sals_from_location): Adjust to pass a
symbol_name_match_type to new_linespec_location.
(strace_marker_decode_location): Adjust to get_linespec_location's
return type change.
(strace_command): Adjust to pass a symbol_name_match_type to
new_linespec_location.
(LOCATION_HELP_STRING): Add paragraph about wildmatching, and
mention "-qualified".
* c-lang.c (cplus_language_defn): Install cp_search_name_hash.
* completer.c (explicit_location_match_type::MATCH_QUALIFIED): New
enumerator.
(complete_address_and_linespec_locations): New parameter
'match_type'. Pass it down.
(explicit_options): Add "-qualified".
(collect_explicit_location_matches): Pass the requested match type
to the linespec completers. Handle MATCH_QUALIFIED.
(location_completer): Handle "-qualified" combined with linespecs.
* cp-support.c (cp_search_name_hash): New.
(cp_symbol_name_matches_1): Implement wild matching for C++.
(cp_fq_symbol_name_matches): Reimplement.
(cp_get_symbol_name_matcher): Return different matchers depending
on the lookup name's match type.
(selftests::test_cp_symbol_name_matches): Add wild matching tests.
* cp-support.h (cp_search_name_hash): New declaration.
* dwarf2read.c
(selftests::dw2_expand_symtabs_matching::test_symbols): Add
symbols.
(test_dw2_expand_symtabs_matching_symbol): Add wild matching
tests.
* guile/scm-breakpoint.c (gdbscm_register_breakpoint_x): Adjust to
pass a symbol_name_match_type to new_linespec_location.
* linespec.c (linespec_parse_basic): Lookup function symbols using
the parser's symbol name match type.
(convert_explicit_location_to_linespec): New
symbol_name_match_type parameter. Pass it down to
find_linespec_symbols.
(convert_explicit_location_to_sals): Pass the location's name
match type to convert_explicit_location_to_linespec.
(parse_linespec): New match_type parameter. Save it in the
parser.
(linespec_parser_new): Default to symbol_name_match_type::WILD.
(linespec_complete_function): New symbol_name_match_type
parameter. Use it.
(complete_linespec_component): Pass down the parser's recorded
name match type.
(linespec_complete_label): New symbol_name_match_type parameter.
Use it.
(linespec_complete): New symbol_name_match_type parameter. Save
it in the parser and pass it down. Adjust to
get_linespec_location's prototype change.
(find_function_symbols, find_linespec_symbols): New
symbol_name_match_type parameter. Pass it down instead of
assuming symbol_name_match_type::WILD.
* linespec.h (linespec_complete, linespec_complete_function)
(linespec_complete_label): New symbol_name_match_type parameter.
* location.c (event_location::linespec_location): Now a struct
linespec_location.
(EL_LINESPEC): Adjust.
(initialize_explicit_location): Default to
symbol_name_match_type::WILD.
(new_linespec_location): New symbol_name_match_type parameter.
Record it in the location.
(get_linespec_location): Now returns a struct linespec_location.
(new_explicit_location): Also copy func_name_match_type.
(explicit_to_string_internal)
(string_to_explicit_location): Handle "-qualified".
(copy_event_location): Adjust to LINESPEC_LOCATION type change.
Copy symbol_name_match_type fields.
(event_location_deleter::operator()): Adjust to LINESPEC_LOCATION
type change.
(event_location_to_string): Adjust to LINESPEC_LOCATION type
change. Handle "-qualfied".
(string_to_explicit_location): Handle "-qualified".
(string_to_event_location_basic): New symbol_name_match_type
parameter. Pass it down.
(string_to_event_location): Handle "-qualified".
* location.h (struct linespec_location): New.
(explicit_location::func_name_match_type): New field.
(new_linespec_location): Now returns a const linespec_location *.
(string_to_event_location_basic): New symbol_name_match_type
parameter.
(explicit_completion_info::saw_explicit_location_option): New
field.
* mi/mi-cmd-break.c (mi_cmd_break_insert_1): Adjust to pass a
symbol_name_match_type to new_linespec_location.
* python/py-breakpoint.c (bppy_init): Likewise.
* python/python.c (gdbpy_decode_line): Likewise.
gdb/testsuite/ChangeLog:
2017-11-29 Pedro Alves <palves@redhat.com>
* gdb.base/langs.exp: Use -qualified.
* gdb.cp/meth-typedefs.exp: Use -qualified, and add tests without
it.
* gdb.cp/namespace.exp: Use -qualified.
* gdb.linespec/cpcompletion.exp (overload-2, fqn, fqn-2)
(overload-3, template-overload, template-ret-type, const-overload)
(const-overload-quoted, anon-ns, ambiguous-prefix): New
procedures.
(test_driver): Call them.
* gdb.cp/save-bp-qualified.cc: New.
* gdb.cp/save-bp-qualified.exp: New.
* gdb.linespec/explicit.exp: Test -qualified.
* lib/completion-support.exp (completion::explicit_opts_list): Add
"-qualified".
* lib/gdb.exp (gdb_breakpoint): Handle "qualified".
gdb/doc/ChangeLog:
2017-11-29 Pedro Alves <palves@redhat.com>
* gdb.texinfo (Linespec Locations): Document how "function" is
interpreted in C++ and Ada. Document "-qualified".
(Explicit Locations): Document how "-function" is interpreted in
C++ and Ada. Document "-qualified".
2017-11-29 20:33:23 +01:00
|
|
|
|
# message, no-message, passfail and qualified.
|
2012-10-11 17:59:57 +02:00
|
|
|
|
# The result is 1 for success, 0 for failure.
|
|
|
|
|
#
|
|
|
|
|
# Note: The handling of message vs no-message is messed up, but it's based
|
|
|
|
|
# on historical usage. By default this function does not print passes,
|
|
|
|
|
# only fails.
|
|
|
|
|
# no-message: turns off printing of fails (and passes, but they're already off)
|
|
|
|
|
# message: turns on printing of passes (and fails, but they're already on)
|
2004-03-24 19:41:50 +01:00
|
|
|
|
|
|
|
|
|
proc gdb_breakpoint { function args } {
|
1999-04-16 03:35:26 +02:00
|
|
|
|
global gdb_prompt
|
|
|
|
|
global decimal
|
|
|
|
|
|
2004-03-24 19:41:50 +01:00
|
|
|
|
set pending_response n
|
2012-10-11 17:59:57 +02:00
|
|
|
|
if {[lsearch -exact $args allow-pending] != -1} {
|
2004-03-24 19:41:50 +01:00
|
|
|
|
set pending_response y
|
|
|
|
|
}
|
|
|
|
|
|
2007-07-31 21:58:40 +02:00
|
|
|
|
set break_command "break"
|
2008-04-15 16:33:55 +02:00
|
|
|
|
set break_message "Breakpoint"
|
2012-10-11 17:59:57 +02:00
|
|
|
|
if {[lsearch -exact $args temporary] != -1} {
|
2007-07-31 21:58:40 +02:00
|
|
|
|
set break_command "tbreak"
|
2008-04-15 16:33:55 +02:00
|
|
|
|
set break_message "Temporary breakpoint"
|
2007-07-31 21:58:40 +02:00
|
|
|
|
}
|
|
|
|
|
|
Make "break foo" find "A::foo", A::B::foo", etc. [C++ and wild matching]
This patch teaches GDB about setting breakpoints in all scopes
(namespaces and classes) by default.
Here's a contrived example:
(gdb) b func<tab>
(anonymous namespace)::A::function() Bn::(anonymous namespace)::B::function() function(int, int)
(anonymous namespace)::B::function() Bn::(anonymous namespace)::function() gdb::(anonymous namespace)::A::function()
(anonymous namespace)::B::function() const Bn::(anonymous namespace)::function(int, int) gdb::(anonymous namespace)::function()
(anonymous namespace)::function() Bn::B::func() gdb::(anonymous namespace)::function(int, int)
(anonymous namespace)::function(int, int) Bn::B::function() gdb::A::func()
A::func() Bn::func() gdb::A::function()
A::function() Bn::function() gdb::func()
B::func() Bn::function(int, int) gdb::function()
B::function() Bn::function(long) gdb::function(int, int)
B::function() const func() gdb::function(long)
B::function_const() const function()
(gdb) b function
Breakpoint 1 at 0x4005ce: function. (26 locations)
(gdb) b B::function<tab>
(anonymous namespace)::B::function() B::function() const Bn::B::function()
(anonymous namespace)::B::function() const B::function_const() const
B::function() Bn::(anonymous namespace)::B::function()
(gdb) b B::function
Breakpoint 1 at 0x40072c: B::function. (6 locations)
To get back the original behavior of interpreting the function name as
a fully-qualified name, you can use the new "-qualified" (or "-q")
option/flag (added by this commit). For example:
(gdb) b B::function
(anonymous namespace)::B::function() B::function() const Bn::B::function()
(anonymous namespace)::B::function() const B::function_const() const
B::function() Bn::(anonymous namespace)::B::function()
vs:
(gdb) b -qualified B::function
B::function() B::function() const B::function_const() const
I've chosen "-qualified" / "-q" because "-f" (for "full" or
"fully-qualified") is already taken for "-function".
Note: the "-qualified" option works with both linespecs and explicit
locations. I.e., these are equivalent:
(gdb) b -q func
(gdb) b -q -f func
and so are these:
(gdb) b -q filename.cc:func
(gdb) b -q -s filename.cc -f func
(gdb) b -s filename.cc -q -f func
(gdb) b -s filename.cc -f func -q
To better understand why I consider wild matching the better default,
consider what happens when we get to the point when _all_ of GDB is
wrapped under "namespace gdb {}". I have a patch series that does
that, and when I started debugging that GDB, I immediately became
frustrated. You'd have to write "b gdb::internal_error", "b
gdb::foo", "b gdb::bar", etc. etc., which gets annoying pretty
quickly. OTOH, consider how this makes it very easy to set
breakpoints in classes wrapped in anonymous namespaces. You just
don't think of them, GDB finds the symbols for you automatically.
(At the Cauldron a couple months ago, several people told me that they
run into a similar issue when debugging other C++ projects. One
example was when debugging LLVM, which puts all its code under the
"llvm" namespace.)
Implementation-wise, what the patch does is:
- makes C++ symbol name hashing only consider the last component of
a symbol name. (so that we can look up symbol names by
last-component name only).
- adds a C++ symbol name matcher for symbol_name_match_type::WILD,
which ignores missing leading specifiers / components.
- adjusts a few preexisting testsuite tests to use "-qualified" when
they mean it.
- adds new testsuite tests.
- adds unit tests.
Grows the gdb.linespec/ tests like this:
-# of expected passes 7823
+# of expected passes 8977
gdb/ChangeLog:
2017-11-29 Pedro Alves <palves@redhat.com>
* NEWS: Mention that breakpoints on C++ functions are now set on
on all namespaces/classes by default, and mention "break
-qualified".
* ax-gdb.c (agent_command_1): Adjust to pass a
symbol_name_match_type to new_linespec_location.
* breakpoint.c (parse_breakpoint_sals): Adjust to
get_linespec_location's return type change.
(strace_marker_create_sals_from_location): Adjust to pass a
symbol_name_match_type to new_linespec_location.
(strace_marker_decode_location): Adjust to get_linespec_location's
return type change.
(strace_command): Adjust to pass a symbol_name_match_type to
new_linespec_location.
(LOCATION_HELP_STRING): Add paragraph about wildmatching, and
mention "-qualified".
* c-lang.c (cplus_language_defn): Install cp_search_name_hash.
* completer.c (explicit_location_match_type::MATCH_QUALIFIED): New
enumerator.
(complete_address_and_linespec_locations): New parameter
'match_type'. Pass it down.
(explicit_options): Add "-qualified".
(collect_explicit_location_matches): Pass the requested match type
to the linespec completers. Handle MATCH_QUALIFIED.
(location_completer): Handle "-qualified" combined with linespecs.
* cp-support.c (cp_search_name_hash): New.
(cp_symbol_name_matches_1): Implement wild matching for C++.
(cp_fq_symbol_name_matches): Reimplement.
(cp_get_symbol_name_matcher): Return different matchers depending
on the lookup name's match type.
(selftests::test_cp_symbol_name_matches): Add wild matching tests.
* cp-support.h (cp_search_name_hash): New declaration.
* dwarf2read.c
(selftests::dw2_expand_symtabs_matching::test_symbols): Add
symbols.
(test_dw2_expand_symtabs_matching_symbol): Add wild matching
tests.
* guile/scm-breakpoint.c (gdbscm_register_breakpoint_x): Adjust to
pass a symbol_name_match_type to new_linespec_location.
* linespec.c (linespec_parse_basic): Lookup function symbols using
the parser's symbol name match type.
(convert_explicit_location_to_linespec): New
symbol_name_match_type parameter. Pass it down to
find_linespec_symbols.
(convert_explicit_location_to_sals): Pass the location's name
match type to convert_explicit_location_to_linespec.
(parse_linespec): New match_type parameter. Save it in the
parser.
(linespec_parser_new): Default to symbol_name_match_type::WILD.
(linespec_complete_function): New symbol_name_match_type
parameter. Use it.
(complete_linespec_component): Pass down the parser's recorded
name match type.
(linespec_complete_label): New symbol_name_match_type parameter.
Use it.
(linespec_complete): New symbol_name_match_type parameter. Save
it in the parser and pass it down. Adjust to
get_linespec_location's prototype change.
(find_function_symbols, find_linespec_symbols): New
symbol_name_match_type parameter. Pass it down instead of
assuming symbol_name_match_type::WILD.
* linespec.h (linespec_complete, linespec_complete_function)
(linespec_complete_label): New symbol_name_match_type parameter.
* location.c (event_location::linespec_location): Now a struct
linespec_location.
(EL_LINESPEC): Adjust.
(initialize_explicit_location): Default to
symbol_name_match_type::WILD.
(new_linespec_location): New symbol_name_match_type parameter.
Record it in the location.
(get_linespec_location): Now returns a struct linespec_location.
(new_explicit_location): Also copy func_name_match_type.
(explicit_to_string_internal)
(string_to_explicit_location): Handle "-qualified".
(copy_event_location): Adjust to LINESPEC_LOCATION type change.
Copy symbol_name_match_type fields.
(event_location_deleter::operator()): Adjust to LINESPEC_LOCATION
type change.
(event_location_to_string): Adjust to LINESPEC_LOCATION type
change. Handle "-qualfied".
(string_to_explicit_location): Handle "-qualified".
(string_to_event_location_basic): New symbol_name_match_type
parameter. Pass it down.
(string_to_event_location): Handle "-qualified".
* location.h (struct linespec_location): New.
(explicit_location::func_name_match_type): New field.
(new_linespec_location): Now returns a const linespec_location *.
(string_to_event_location_basic): New symbol_name_match_type
parameter.
(explicit_completion_info::saw_explicit_location_option): New
field.
* mi/mi-cmd-break.c (mi_cmd_break_insert_1): Adjust to pass a
symbol_name_match_type to new_linespec_location.
* python/py-breakpoint.c (bppy_init): Likewise.
* python/python.c (gdbpy_decode_line): Likewise.
gdb/testsuite/ChangeLog:
2017-11-29 Pedro Alves <palves@redhat.com>
* gdb.base/langs.exp: Use -qualified.
* gdb.cp/meth-typedefs.exp: Use -qualified, and add tests without
it.
* gdb.cp/namespace.exp: Use -qualified.
* gdb.linespec/cpcompletion.exp (overload-2, fqn, fqn-2)
(overload-3, template-overload, template-ret-type, const-overload)
(const-overload-quoted, anon-ns, ambiguous-prefix): New
procedures.
(test_driver): Call them.
* gdb.cp/save-bp-qualified.cc: New.
* gdb.cp/save-bp-qualified.exp: New.
* gdb.linespec/explicit.exp: Test -qualified.
* lib/completion-support.exp (completion::explicit_opts_list): Add
"-qualified".
* lib/gdb.exp (gdb_breakpoint): Handle "qualified".
gdb/doc/ChangeLog:
2017-11-29 Pedro Alves <palves@redhat.com>
* gdb.texinfo (Linespec Locations): Document how "function" is
interpreted in C++ and Ada. Document "-qualified".
(Explicit Locations): Document how "-function" is interpreted in
C++ and Ada. Document "-qualified".
2017-11-29 20:33:23 +01:00
|
|
|
|
if {[lsearch -exact $args qualified] != -1} {
|
|
|
|
|
append break_command " -qualified"
|
|
|
|
|
}
|
|
|
|
|
|
2012-10-11 17:59:57 +02:00
|
|
|
|
set print_pass 0
|
|
|
|
|
set print_fail 1
|
|
|
|
|
set no_message_loc [lsearch -exact $args no-message]
|
|
|
|
|
set message_loc [lsearch -exact $args message]
|
|
|
|
|
# The last one to appear in args wins.
|
|
|
|
|
if { $no_message_loc > $message_loc } {
|
|
|
|
|
set print_fail 0
|
|
|
|
|
} elseif { $message_loc > $no_message_loc } {
|
|
|
|
|
set print_pass 1
|
2008-05-04 06:04:11 +02:00
|
|
|
|
}
|
|
|
|
|
|
2012-10-11 17:59:57 +02:00
|
|
|
|
set test_name "setting breakpoint at $function"
|
|
|
|
|
|
2007-07-31 21:58:40 +02:00
|
|
|
|
send_gdb "$break_command $function\n"
|
1999-04-16 03:35:26 +02:00
|
|
|
|
# The first two regexps are what we get with -g, the third is without -g.
|
|
|
|
|
gdb_expect 30 {
|
2008-04-15 16:33:55 +02:00
|
|
|
|
-re "$break_message \[0-9\]* at .*: file .*, line $decimal.\r\n$gdb_prompt $" {}
|
|
|
|
|
-re "$break_message \[0-9\]*: file .*, line $decimal.\r\n$gdb_prompt $" {}
|
|
|
|
|
-re "$break_message \[0-9\]* at .*$gdb_prompt $" {}
|
|
|
|
|
-re "$break_message \[0-9\]* \\(.*\\) pending.*$gdb_prompt $" {
|
2004-03-24 19:41:50 +01:00
|
|
|
|
if {$pending_response == "n"} {
|
2012-10-11 17:59:57 +02:00
|
|
|
|
if { $print_fail } {
|
|
|
|
|
fail $test_name
|
2008-05-04 06:04:11 +02:00
|
|
|
|
}
|
2004-03-24 19:41:50 +01:00
|
|
|
|
return 0
|
|
|
|
|
}
|
|
|
|
|
}
|
2004-02-23 20:27:46 +01:00
|
|
|
|
-re "Make breakpoint pending.*y or \\\[n\\\]. $" {
|
2004-03-24 19:41:50 +01:00
|
|
|
|
send_gdb "$pending_response\n"
|
2004-02-08 23:30:42 +01:00
|
|
|
|
exp_continue
|
2004-02-02 22:14:33 +01:00
|
|
|
|
}
|
2011-04-13 22:31:01 +02:00
|
|
|
|
-re "A problem internal to GDB has been detected" {
|
2012-10-11 17:59:57 +02:00
|
|
|
|
if { $print_fail } {
|
|
|
|
|
fail "$test_name (GDB internal error)"
|
|
|
|
|
}
|
2011-04-13 22:31:01 +02:00
|
|
|
|
gdb_internal_error_resync
|
|
|
|
|
return 0
|
|
|
|
|
}
|
2008-05-04 06:04:11 +02:00
|
|
|
|
-re "$gdb_prompt $" {
|
2012-10-11 17:59:57 +02:00
|
|
|
|
if { $print_fail } {
|
|
|
|
|
fail $test_name
|
|
|
|
|
}
|
|
|
|
|
return 0
|
|
|
|
|
}
|
|
|
|
|
eof {
|
|
|
|
|
if { $print_fail } {
|
|
|
|
|
fail "$test_name (eof)"
|
2008-05-04 06:04:11 +02:00
|
|
|
|
}
|
|
|
|
|
return 0
|
|
|
|
|
}
|
|
|
|
|
timeout {
|
2012-10-11 17:59:57 +02:00
|
|
|
|
if { $print_fail } {
|
|
|
|
|
fail "$test_name (timeout)"
|
2008-05-04 06:04:11 +02:00
|
|
|
|
}
|
|
|
|
|
return 0
|
|
|
|
|
}
|
1999-04-16 03:35:26 +02:00
|
|
|
|
}
|
2012-10-11 17:59:57 +02:00
|
|
|
|
if { $print_pass } {
|
|
|
|
|
pass $test_name
|
|
|
|
|
}
|
gdb/testsuite/
* config/monitor.exp (gdb_target_cmd): Remove semicolon after
'return'.
(gdb_target_monitor, gdb_load): Likewise.
* config/sid.exp (gdb_load): Likewise.
* config/slite.exp (gdb_load): Likewise.
* config/vx.exp (gdb_start, spawn_vxgdb): Likewise.
* gdb.ada/arrayidx.exp, gdb.ada/null_array.exp: Likewise.
* gdb.arch/mips-octeon-bbit.exp (single_step): Likewise.
(single_step_until): Likewise.
* gdb.arch/powerpc-d128-regs.exp: Likewise.
* gdb.arch/system-gcore.exp: Likewise.
* gdb.base/bigcore.exp (extract_heap): Likewise.
* gdb.base/break-on-linker-gcd-function.exp: Likewise.
* gdb.base/call-ar-st.exp: Likewise.
* gdb.base/call-rt-st.exp: Likewise.
* gdb.base/call-sc.exp, gdb.base/call-strs.exp: Likewise.
* gdb.base/callfuncs.exp, gdb.base/completion.exp: Likewise.
* gdb.base/condbreak.exp, gdb.base/constvars.exp: Likewise.
* gdb.base/corefile.exp: Likewise.
* gdb.base/dbx.exp (gdb_file_cmd): Likewise.
* gdb.base/exprs.exp, gdb.base/fileio.exp: Likewise.
* gdb.base/fixsection.exp: Likewise.
* gdb.base/funcargs.exp: Likewise.
* gdb.base/gcore-buffer-overflow.exp: Likewise.
* gdb.base/gcore-relro.exp: Likewise.
* gdb.base/gcore.exp, gdb.base/gdb11530.exp: Likewise.
* gdb.base/gdb11531.exp, gdb.base/gnu-ifunc.exp: Likewise.
* gdb.base/info-os.exp, gdb.base/info-proc.exp: Likewise.
* gdb.base/interp.exp, gdb.base/langs.exp:: Likewise.
* gdb.base/list.exp: Likewise.
(set_listsize): Likewise.
* gdb.base/logical.exp, gdb.base/mips_pro.exp: Likewise.
* gdb.base/miscexprs.exp, gdb.base/nodebug.exp: Likewise.
* gdb.base/opaque.exp, gdb.base/pointers.exp: Likewise.
* gdb.base/psymtab.exp, gdb.base/ptype.exp: Likewise.
* gdb.base/relational.exp, gdb.base/scope.exp: Likewise.
* gdb.base/setvar.exp: Likewise.
(test_set): Likewise.
* gdb.base/signals.exp, gdb.base/sizeof.exp: Likewise.
* gdb.base/solib-overlap.exp: Likewise.
* gdb.base/store.exp, gdb.base/structs.exp: Likewise.
* gdb.base/structs2.exp, gdb.base/volatile.exp: Likewise.
* gdb.base/watchpoint.exp (initialize): Likewise.
(test_simple_watchpoint): Likewise.
(test_disabling_watchpoints): Likewise.
(test_watchpoint_triggered_in_syscall): Likewise.
* gdb.base/whatis.exp, gdb.cp/ambiguous.exp: Likewise.
* gdb.cp/casts.exp, gdb.cp/ctti.exp: Likewise.
* gdb.cp/namespace.exp, gdb.cp/nsdecl.exp: Likewise.
* gdb.cp/psmang.exp, gdb.dwarf2/dw2-ranges.exp: Likewise.
* gdb.hp/gdb.aCC/optimize.exp: Likewise.
* gdb.hp/gdb.aCC/watch-cmd.exp: Likewise.
* gdb.hp/gdb.base-hp/callfwmall.exp: Likewise.
* gdb.hp/gdb.base-hp/pxdb.exp: Likewise.
* gdb.hp/gdb.compat/xdb1.exp: Likewise.
* gdb.hp/gdb.compat/xdb2.exp: Likewise.
* gdb.hp/gdb.compat/xdb3.exp: Likewise.
* gdb.hp/gdb.defects/bs14602.exp: Likewise.
* gdb.hp/gdb.defects/solib-d.exp: Likewise.
* gdb.mi/gdb792.exp: Likewise.
* gdb.mi/mi-inheritance-syntax-error.exp: Likewise.
* gdb.mi/mi-logging.exp, gdb.mi/mi-var-cp.exp : Likewise.
* gdb.mi/mi-var-rtti.exp, gdb.python/py-type.exp: Likewise.
* gdb.threads/gcore-thread.exp: Likewise.
(load_core): Likewise.
* gdb.threads/pthreads.exp (all_threads_running): Likewise.
(test_startup, check_control_c): Likewise.
* gdb.threads/sigstep-threads.exp: Likewise.
* gdb.threads/thread_check.exp: Likewise.
* gdb.trace/backtrace.exp, gdb.trace/change-loc.exp: Likewise.
* gdb.trace/circ.exp (run_trace_experiment): Likewise.
(set_a_tracepoint, trace_buffer_normal): Likewise.
(gdb_trace_circular_tests): Likewise.
* gdb.trace/collection.exp: Likewise.
* gdb.trace/disconnected-tracing.exp: Likewise.
* gdb.trace/infotrace.exp: Likewise.
* gdb.trace/mi-traceframe-changed.exp: Likewise.
* gdb.trace/mi-tracepoint-changed.exp: Likewise.
* gdb.trace/mi-tsv-changed.exp (test_create_delete_modify_tsv): Likewise.
* gdb.trace/packetlen.exp, gdb.trace/passc-dyn.exp: Likewise.
* gdb.trace/pending.exp, gdb.trace/report.exp: Likewise.
* gdb.trace/stap-trace.exp: Likewise.
* gdb.trace/status-stop.exp,gdb.trace/strace.exp: Likewise.
* gdb.trace/tfind.exp, gdb.trace/trace-break.exp: Likewise.
* gdb.trace/trace-buffer-size.exp: Likewise.
* gdb.trace/tspeed.exp, gdb.trace/tsv.exp: Likewise.
* gdb.trace/unavailable.exp: Likewise.
* gdb.trace/while-dyn.exp: Likewise.
* lib/fortran.exp (set_lang_fortran): Likewise.
* lib/gdb.exp (default_gdb_version, gdb_start_cmd): Likewise.
(gdb_breakpoint, gdb_reinitialize_dir): Likewise.
(default_gdb_start, get_compiler_info): Likewise.
(gdb_compile, gdb_compile_objc, gdb_reload, gdb_init): Likewise.
(get_debug_format, setup_xfail_format): Likewise.
(rerun_to_main, gdb_skip_float_test): Likewise.
(build_id_debug_filename_get, get_remotetimeout): Likewise.
* lib/java.exp (set_lang_java): Likewise.
* lib/mi-support.exp (default_mi_gdb_start): Likewise.
(mi_gdb_reinitialize_dir, mi_gdb_target_cmd): Likewise.
(mi_gdb_file_cmd, mi_gdb_test): Likewise.
(mi_run_cmd_full, mi_expect_interrupt): Likewise.
* lib/objc.exp (set_lang_objc): Likewise.
* lib/pascal.exp (set_lang_pascal): Likewise.
* lib/prompt.exp (default_prompt_gdb_start): Likewise.
* lib/trace-support.exp (gdb_trace_setactions, gdb_tfind_test): Likewise.
(gdb_readexpr, gdb_gettpnum, gdb_find_recursion_test_baseline): Likewise.
2013-03-14 14:34:06 +01:00
|
|
|
|
return 1
|
1999-04-16 03:35:26 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# Set breakpoint at function and run gdb until it breaks there.
|
|
|
|
|
# Since this is the only breakpoint that will be set, if it stops
|
|
|
|
|
# at a breakpoint, we will assume it is the one we want. We can't
|
|
|
|
|
# just compare to "function" because it might be a fully qualified,
|
2012-10-11 17:59:57 +02:00
|
|
|
|
# single quoted C++ function specifier.
|
|
|
|
|
#
|
|
|
|
|
# If there are additional arguments, pass them to gdb_breakpoint.
|
|
|
|
|
# We recognize no-message/message ourselves.
|
|
|
|
|
# The default is no-message.
|
|
|
|
|
# no-message is messed up here, like gdb_breakpoint: to preserve
|
|
|
|
|
# historical usage fails are always printed by default.
|
|
|
|
|
# no-message: turns off printing of fails (and passes, but they're already off)
|
|
|
|
|
# message: turns on printing of passes (and fails, but they're already on)
|
1999-04-16 03:35:26 +02:00
|
|
|
|
|
2004-03-24 19:41:50 +01:00
|
|
|
|
proc runto { function args } {
|
1999-04-16 03:35:26 +02:00
|
|
|
|
global gdb_prompt
|
|
|
|
|
global decimal
|
|
|
|
|
|
|
|
|
|
delete_breakpoints
|
|
|
|
|
|
2012-10-11 17:59:57 +02:00
|
|
|
|
# Default to "no-message".
|
|
|
|
|
set args "no-message $args"
|
|
|
|
|
|
|
|
|
|
set print_pass 0
|
|
|
|
|
set print_fail 1
|
|
|
|
|
set no_message_loc [lsearch -exact $args no-message]
|
|
|
|
|
set message_loc [lsearch -exact $args message]
|
|
|
|
|
# The last one to appear in args wins.
|
|
|
|
|
if { $no_message_loc > $message_loc } {
|
|
|
|
|
set print_fail 0
|
|
|
|
|
} elseif { $message_loc > $no_message_loc } {
|
|
|
|
|
set print_pass 1
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
set test_name "running to $function in runto"
|
|
|
|
|
|
|
|
|
|
# We need to use eval here to pass our varargs args to gdb_breakpoint
|
|
|
|
|
# which is also a varargs function.
|
2012-10-15 19:35:54 +02:00
|
|
|
|
# But we also have to be careful because $function may have multiple
|
|
|
|
|
# elements, and we don't want Tcl to move the remaining elements after
|
|
|
|
|
# the first to $args. That is why $function is wrapped in {}.
|
|
|
|
|
if ![eval gdb_breakpoint {$function} $args] {
|
gdb/testsuite/
* config/monitor.exp (gdb_target_cmd): Remove semicolon after
'return'.
(gdb_target_monitor, gdb_load): Likewise.
* config/sid.exp (gdb_load): Likewise.
* config/slite.exp (gdb_load): Likewise.
* config/vx.exp (gdb_start, spawn_vxgdb): Likewise.
* gdb.ada/arrayidx.exp, gdb.ada/null_array.exp: Likewise.
* gdb.arch/mips-octeon-bbit.exp (single_step): Likewise.
(single_step_until): Likewise.
* gdb.arch/powerpc-d128-regs.exp: Likewise.
* gdb.arch/system-gcore.exp: Likewise.
* gdb.base/bigcore.exp (extract_heap): Likewise.
* gdb.base/break-on-linker-gcd-function.exp: Likewise.
* gdb.base/call-ar-st.exp: Likewise.
* gdb.base/call-rt-st.exp: Likewise.
* gdb.base/call-sc.exp, gdb.base/call-strs.exp: Likewise.
* gdb.base/callfuncs.exp, gdb.base/completion.exp: Likewise.
* gdb.base/condbreak.exp, gdb.base/constvars.exp: Likewise.
* gdb.base/corefile.exp: Likewise.
* gdb.base/dbx.exp (gdb_file_cmd): Likewise.
* gdb.base/exprs.exp, gdb.base/fileio.exp: Likewise.
* gdb.base/fixsection.exp: Likewise.
* gdb.base/funcargs.exp: Likewise.
* gdb.base/gcore-buffer-overflow.exp: Likewise.
* gdb.base/gcore-relro.exp: Likewise.
* gdb.base/gcore.exp, gdb.base/gdb11530.exp: Likewise.
* gdb.base/gdb11531.exp, gdb.base/gnu-ifunc.exp: Likewise.
* gdb.base/info-os.exp, gdb.base/info-proc.exp: Likewise.
* gdb.base/interp.exp, gdb.base/langs.exp:: Likewise.
* gdb.base/list.exp: Likewise.
(set_listsize): Likewise.
* gdb.base/logical.exp, gdb.base/mips_pro.exp: Likewise.
* gdb.base/miscexprs.exp, gdb.base/nodebug.exp: Likewise.
* gdb.base/opaque.exp, gdb.base/pointers.exp: Likewise.
* gdb.base/psymtab.exp, gdb.base/ptype.exp: Likewise.
* gdb.base/relational.exp, gdb.base/scope.exp: Likewise.
* gdb.base/setvar.exp: Likewise.
(test_set): Likewise.
* gdb.base/signals.exp, gdb.base/sizeof.exp: Likewise.
* gdb.base/solib-overlap.exp: Likewise.
* gdb.base/store.exp, gdb.base/structs.exp: Likewise.
* gdb.base/structs2.exp, gdb.base/volatile.exp: Likewise.
* gdb.base/watchpoint.exp (initialize): Likewise.
(test_simple_watchpoint): Likewise.
(test_disabling_watchpoints): Likewise.
(test_watchpoint_triggered_in_syscall): Likewise.
* gdb.base/whatis.exp, gdb.cp/ambiguous.exp: Likewise.
* gdb.cp/casts.exp, gdb.cp/ctti.exp: Likewise.
* gdb.cp/namespace.exp, gdb.cp/nsdecl.exp: Likewise.
* gdb.cp/psmang.exp, gdb.dwarf2/dw2-ranges.exp: Likewise.
* gdb.hp/gdb.aCC/optimize.exp: Likewise.
* gdb.hp/gdb.aCC/watch-cmd.exp: Likewise.
* gdb.hp/gdb.base-hp/callfwmall.exp: Likewise.
* gdb.hp/gdb.base-hp/pxdb.exp: Likewise.
* gdb.hp/gdb.compat/xdb1.exp: Likewise.
* gdb.hp/gdb.compat/xdb2.exp: Likewise.
* gdb.hp/gdb.compat/xdb3.exp: Likewise.
* gdb.hp/gdb.defects/bs14602.exp: Likewise.
* gdb.hp/gdb.defects/solib-d.exp: Likewise.
* gdb.mi/gdb792.exp: Likewise.
* gdb.mi/mi-inheritance-syntax-error.exp: Likewise.
* gdb.mi/mi-logging.exp, gdb.mi/mi-var-cp.exp : Likewise.
* gdb.mi/mi-var-rtti.exp, gdb.python/py-type.exp: Likewise.
* gdb.threads/gcore-thread.exp: Likewise.
(load_core): Likewise.
* gdb.threads/pthreads.exp (all_threads_running): Likewise.
(test_startup, check_control_c): Likewise.
* gdb.threads/sigstep-threads.exp: Likewise.
* gdb.threads/thread_check.exp: Likewise.
* gdb.trace/backtrace.exp, gdb.trace/change-loc.exp: Likewise.
* gdb.trace/circ.exp (run_trace_experiment): Likewise.
(set_a_tracepoint, trace_buffer_normal): Likewise.
(gdb_trace_circular_tests): Likewise.
* gdb.trace/collection.exp: Likewise.
* gdb.trace/disconnected-tracing.exp: Likewise.
* gdb.trace/infotrace.exp: Likewise.
* gdb.trace/mi-traceframe-changed.exp: Likewise.
* gdb.trace/mi-tracepoint-changed.exp: Likewise.
* gdb.trace/mi-tsv-changed.exp (test_create_delete_modify_tsv): Likewise.
* gdb.trace/packetlen.exp, gdb.trace/passc-dyn.exp: Likewise.
* gdb.trace/pending.exp, gdb.trace/report.exp: Likewise.
* gdb.trace/stap-trace.exp: Likewise.
* gdb.trace/status-stop.exp,gdb.trace/strace.exp: Likewise.
* gdb.trace/tfind.exp, gdb.trace/trace-break.exp: Likewise.
* gdb.trace/trace-buffer-size.exp: Likewise.
* gdb.trace/tspeed.exp, gdb.trace/tsv.exp: Likewise.
* gdb.trace/unavailable.exp: Likewise.
* gdb.trace/while-dyn.exp: Likewise.
* lib/fortran.exp (set_lang_fortran): Likewise.
* lib/gdb.exp (default_gdb_version, gdb_start_cmd): Likewise.
(gdb_breakpoint, gdb_reinitialize_dir): Likewise.
(default_gdb_start, get_compiler_info): Likewise.
(gdb_compile, gdb_compile_objc, gdb_reload, gdb_init): Likewise.
(get_debug_format, setup_xfail_format): Likewise.
(rerun_to_main, gdb_skip_float_test): Likewise.
(build_id_debug_filename_get, get_remotetimeout): Likewise.
* lib/java.exp (set_lang_java): Likewise.
* lib/mi-support.exp (default_mi_gdb_start): Likewise.
(mi_gdb_reinitialize_dir, mi_gdb_target_cmd): Likewise.
(mi_gdb_file_cmd, mi_gdb_test): Likewise.
(mi_run_cmd_full, mi_expect_interrupt): Likewise.
* lib/objc.exp (set_lang_objc): Likewise.
* lib/pascal.exp (set_lang_pascal): Likewise.
* lib/prompt.exp (default_prompt_gdb_start): Likewise.
* lib/trace-support.exp (gdb_trace_setactions, gdb_tfind_test): Likewise.
(gdb_readexpr, gdb_gettpnum, gdb_find_recursion_test_baseline): Likewise.
2013-03-14 14:34:06 +01:00
|
|
|
|
return 0
|
1999-04-16 03:35:26 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
gdb_run_cmd
|
|
|
|
|
|
|
|
|
|
# the "at foo.c:36" output we get with -g.
|
|
|
|
|
# the "in func" output we get without -g.
|
|
|
|
|
gdb_expect 30 {
|
|
|
|
|
-re "Break.* at .*:$decimal.*$gdb_prompt $" {
|
2012-10-11 17:59:57 +02:00
|
|
|
|
if { $print_pass } {
|
|
|
|
|
pass $test_name
|
|
|
|
|
}
|
1999-04-16 03:35:26 +02:00
|
|
|
|
return 1
|
|
|
|
|
}
|
|
|
|
|
-re "Breakpoint \[0-9\]*, \[0-9xa-f\]* in .*$gdb_prompt $" {
|
2012-10-11 17:59:57 +02:00
|
|
|
|
if { $print_pass } {
|
|
|
|
|
pass $test_name
|
|
|
|
|
}
|
1999-04-16 03:35:26 +02:00
|
|
|
|
return 1
|
|
|
|
|
}
|
2010-06-11 23:58:20 +02:00
|
|
|
|
-re "The target does not support running in non-stop mode.\r\n$gdb_prompt $" {
|
2012-10-11 17:59:57 +02:00
|
|
|
|
if { $print_fail } {
|
2016-12-01 21:40:05 +01:00
|
|
|
|
unsupported "non-stop mode not supported"
|
2012-10-11 17:59:57 +02:00
|
|
|
|
}
|
2010-06-11 23:58:20 +02:00
|
|
|
|
return 0
|
|
|
|
|
}
|
2010-07-21 00:19:07 +02:00
|
|
|
|
-re ".*A problem internal to GDB has been detected" {
|
2012-10-11 17:59:57 +02:00
|
|
|
|
if { $print_fail } {
|
|
|
|
|
fail "$test_name (GDB internal error)"
|
|
|
|
|
}
|
2010-07-21 00:19:07 +02:00
|
|
|
|
gdb_internal_error_resync
|
|
|
|
|
return 0
|
|
|
|
|
}
|
1999-04-16 03:35:26 +02:00
|
|
|
|
-re "$gdb_prompt $" {
|
2012-10-11 17:59:57 +02:00
|
|
|
|
if { $print_fail } {
|
|
|
|
|
fail $test_name
|
|
|
|
|
}
|
1999-04-16 03:35:26 +02:00
|
|
|
|
return 0
|
|
|
|
|
}
|
2009-06-12 23:28:34 +02:00
|
|
|
|
eof {
|
2012-10-11 17:59:57 +02:00
|
|
|
|
if { $print_fail } {
|
|
|
|
|
fail "$test_name (eof)"
|
|
|
|
|
}
|
2009-06-12 23:28:34 +02:00
|
|
|
|
return 0
|
|
|
|
|
}
|
1999-04-16 03:35:26 +02:00
|
|
|
|
timeout {
|
2012-10-11 17:59:57 +02:00
|
|
|
|
if { $print_fail } {
|
|
|
|
|
fail "$test_name (timeout)"
|
|
|
|
|
}
|
1999-04-16 03:35:26 +02:00
|
|
|
|
return 0
|
|
|
|
|
}
|
|
|
|
|
}
|
2012-10-11 17:59:57 +02:00
|
|
|
|
if { $print_pass } {
|
|
|
|
|
pass $test_name
|
|
|
|
|
}
|
1999-04-16 03:35:26 +02:00
|
|
|
|
return 1
|
|
|
|
|
}
|
|
|
|
|
|
2011-12-03 19:01:50 +01:00
|
|
|
|
# Ask gdb to run until we hit a breakpoint at main.
|
1999-04-16 03:35:26 +02:00
|
|
|
|
#
|
2011-12-03 19:01:50 +01:00
|
|
|
|
# N.B. This function deletes all existing breakpoints.
|
|
|
|
|
# If you don't want that, use gdb_start_cmd.
|
|
|
|
|
|
1999-04-16 03:35:26 +02:00
|
|
|
|
proc runto_main { } {
|
2012-10-11 17:59:57 +02:00
|
|
|
|
return [runto main no-message]
|
1999-04-16 03:35:26 +02:00
|
|
|
|
}
|
|
|
|
|
|
1999-11-17 03:31:06 +01:00
|
|
|
|
### Continue, and expect to hit a breakpoint.
|
|
|
|
|
### Report a pass or fail, depending on whether it seems to have
|
|
|
|
|
### worked. Use NAME as part of the test name; each call to
|
|
|
|
|
### continue_to_breakpoint should use a NAME which is unique within
|
|
|
|
|
### that test file.
|
2008-04-24 12:21:45 +02:00
|
|
|
|
proc gdb_continue_to_breakpoint {name {location_pattern .*}} {
|
1999-11-17 03:31:06 +01:00
|
|
|
|
global gdb_prompt
|
|
|
|
|
set full_name "continue to breakpoint: $name"
|
|
|
|
|
|
2019-10-13 02:40:57 +02:00
|
|
|
|
set kfail_pattern "Process record does not support instruction 0xfae64 at.*"
|
2014-04-22 20:15:48 +02:00
|
|
|
|
gdb_test_multiple "continue" $full_name {
|
2012-07-02 14:06:56 +02:00
|
|
|
|
-re "(?:Breakpoint|Temporary breakpoint) .* (at|in) $location_pattern\r\n$gdb_prompt $" {
|
1999-11-17 03:31:06 +01:00
|
|
|
|
pass $full_name
|
|
|
|
|
}
|
2019-10-13 02:40:57 +02:00
|
|
|
|
-re "\[\r\n\]*(?:$kfail_pattern)\[\r\n\]+$gdb_prompt $" {
|
|
|
|
|
kfail "gdb/25038" $full_name
|
|
|
|
|
}
|
1999-11-17 03:31:06 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2003-11-20 16:36:34 +01:00
|
|
|
|
# gdb_internal_error_resync:
|
|
|
|
|
#
|
|
|
|
|
# Answer the questions GDB asks after it reports an internal error
|
|
|
|
|
# until we get back to a GDB prompt. Decline to quit the debugging
|
|
|
|
|
# session, and decline to create a core file. Return non-zero if the
|
|
|
|
|
# resync succeeds.
|
|
|
|
|
#
|
|
|
|
|
# This procedure just answers whatever questions come up until it sees
|
|
|
|
|
# a GDB prompt; it doesn't require you to have matched the input up to
|
|
|
|
|
# any specific point. However, it only answers questions it sees in
|
|
|
|
|
# the output itself, so if you've matched a question, you had better
|
|
|
|
|
# answer it yourself before calling this.
|
|
|
|
|
#
|
|
|
|
|
# You can use this function thus:
|
|
|
|
|
#
|
|
|
|
|
# gdb_expect {
|
|
|
|
|
# ...
|
|
|
|
|
# -re ".*A problem internal to GDB has been detected" {
|
|
|
|
|
# gdb_internal_error_resync
|
|
|
|
|
# }
|
|
|
|
|
# ...
|
|
|
|
|
# }
|
|
|
|
|
#
|
|
|
|
|
proc gdb_internal_error_resync {} {
|
|
|
|
|
global gdb_prompt
|
|
|
|
|
|
2012-10-11 17:59:57 +02:00
|
|
|
|
verbose -log "Resyncing due to internal error."
|
|
|
|
|
|
2003-11-20 16:36:34 +01:00
|
|
|
|
set count 0
|
|
|
|
|
while {$count < 10} {
|
|
|
|
|
gdb_expect {
|
|
|
|
|
-re "Quit this debugging session\\? \\(y or n\\) $" {
|
2019-05-17 17:30:09 +02:00
|
|
|
|
send_gdb "n\n" answer
|
2003-11-20 16:36:34 +01:00
|
|
|
|
incr count
|
|
|
|
|
}
|
|
|
|
|
-re "Create a core file of GDB\\? \\(y or n\\) $" {
|
2019-05-17 17:30:09 +02:00
|
|
|
|
send_gdb "n\n" answer
|
2003-11-20 16:36:34 +01:00
|
|
|
|
incr count
|
|
|
|
|
}
|
|
|
|
|
-re "$gdb_prompt $" {
|
|
|
|
|
# We're resynchronized.
|
|
|
|
|
return 1
|
|
|
|
|
}
|
|
|
|
|
timeout {
|
|
|
|
|
perror "Could not resync from internal error (timeout)"
|
|
|
|
|
return 0
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2003-11-20 16:58:08 +01:00
|
|
|
|
perror "Could not resync from internal error (resync count exceeded)"
|
|
|
|
|
return 0
|
2003-11-20 16:36:34 +01:00
|
|
|
|
}
|
|
|
|
|
|
1999-11-17 03:31:06 +01:00
|
|
|
|
|
2019-07-29 11:24:04 +02:00
|
|
|
|
# gdb_test_multiple COMMAND MESSAGE EXPECT_ARGUMENTS PROMPT_REGEXP
|
2001-06-14 02:12:32 +02:00
|
|
|
|
# Send a command to gdb; test the result.
|
1999-04-16 03:35:26 +02:00
|
|
|
|
#
|
|
|
|
|
# COMMAND is the command to execute, send to GDB with send_gdb. If
|
|
|
|
|
# this is the null string no command is sent.
|
2003-01-23 02:35:21 +01:00
|
|
|
|
# MESSAGE is a message to be printed with the built-in failure patterns
|
|
|
|
|
# if one of them matches. If MESSAGE is empty COMMAND will be used.
|
|
|
|
|
# EXPECT_ARGUMENTS will be fed to expect in addition to the standard
|
|
|
|
|
# patterns. Pattern elements will be evaluated in the caller's
|
|
|
|
|
# context; action elements will be executed in the caller's context.
|
|
|
|
|
# Unlike patterns for gdb_test, these patterns should generally include
|
|
|
|
|
# the final newline and prompt.
|
2019-07-29 11:24:04 +02:00
|
|
|
|
# PROMPT_REGEXP is a regexp matching the expected prompt after the command
|
|
|
|
|
# output. If empty, defaults to "$gdb_prompt $"
|
1999-04-16 03:35:26 +02:00
|
|
|
|
#
|
|
|
|
|
# Returns:
|
2003-01-23 02:35:21 +01:00
|
|
|
|
# 1 if the test failed, according to a built-in failure pattern
|
|
|
|
|
# 0 if only user-supplied patterns matched
|
1999-04-16 03:35:26 +02:00
|
|
|
|
# -1 if there was an internal error.
|
|
|
|
|
#
|
2003-11-23 02:09:19 +01:00
|
|
|
|
# You can use this function thus:
|
|
|
|
|
#
|
|
|
|
|
# gdb_test_multiple "print foo" "test foo" {
|
|
|
|
|
# -re "expected output 1" {
|
gdb/testsuite: Add gdb_test_name variable
This commit adds a new feature to gdb_test_multiple, an automatically
created variable gdb_test_name. The idea is to make it easier to
write tests using gdb_test_multiple, and avoid places where the string
passed to pass/fail within an action element is different to the
message passed to the top level gdb_test_multiple.
As an example, previously you might write this:
gdb_test_multiple "print foo" "test foo" {
-re "expected output 1" {
pass "test foo"
}
-re "expected output 2" {
fail "test foo"
}
}
This is OK, but it's easy for the pass/fail strings to come out of
sync, or contain a typo. A better version would look like this:
set testname "test foo"
gdb_test_multiple "print foo" $testname {
-re "expected output 1" {
pass $testname
}
-re "expected output 2" {
fail $testname
}
}
This is better, but its a bit of a drag having to create a new
variable each time.
After this patch you can now write this:
gdb_test_multiple "print foo" "test foo" {
-re "expected output 1" {
pass $gdb_test_name
}
-re "expected output 2" {
fail $gdb_test_name
}
}
The $gdb_test_name is setup by gdb_test_multiple, and cleaned up once
the test has completed. Nested calls to gdb_test_multiple are
supported, though $gdb_test_name will only ever contain the inner most
test message (which is probably what you want).
My only regret is that '$gdb_test_name' is so long, but I wanted
something that was unlikely to clash with any existing variable name,
or anything that a user is likely to want to use.
I've tested this on x86-64/GNU Linux and see no test regressions, and
I've converted one test script over to make use of this new technique
both as an example, and to ensure that the new facility doesn't get
broken. I have no plans to convert all tests over to this technique,
but I hope others will find this useful for writing tests in the
future.
gdb/testsuite/ChangeLog:
* lib/gdb.exp (gdb_test_multiple): Add gdb_test_name mechanism.
* gdb.base/annota1.exp: Update to use gdb_test_name.
2019-10-01 16:29:20 +02:00
|
|
|
|
# pass "test foo"
|
2003-11-23 02:09:19 +01:00
|
|
|
|
# }
|
|
|
|
|
# -re "expected output 2" {
|
gdb/testsuite: Add gdb_test_name variable
This commit adds a new feature to gdb_test_multiple, an automatically
created variable gdb_test_name. The idea is to make it easier to
write tests using gdb_test_multiple, and avoid places where the string
passed to pass/fail within an action element is different to the
message passed to the top level gdb_test_multiple.
As an example, previously you might write this:
gdb_test_multiple "print foo" "test foo" {
-re "expected output 1" {
pass "test foo"
}
-re "expected output 2" {
fail "test foo"
}
}
This is OK, but it's easy for the pass/fail strings to come out of
sync, or contain a typo. A better version would look like this:
set testname "test foo"
gdb_test_multiple "print foo" $testname {
-re "expected output 1" {
pass $testname
}
-re "expected output 2" {
fail $testname
}
}
This is better, but its a bit of a drag having to create a new
variable each time.
After this patch you can now write this:
gdb_test_multiple "print foo" "test foo" {
-re "expected output 1" {
pass $gdb_test_name
}
-re "expected output 2" {
fail $gdb_test_name
}
}
The $gdb_test_name is setup by gdb_test_multiple, and cleaned up once
the test has completed. Nested calls to gdb_test_multiple are
supported, though $gdb_test_name will only ever contain the inner most
test message (which is probably what you want).
My only regret is that '$gdb_test_name' is so long, but I wanted
something that was unlikely to clash with any existing variable name,
or anything that a user is likely to want to use.
I've tested this on x86-64/GNU Linux and see no test regressions, and
I've converted one test script over to make use of this new technique
both as an example, and to ensure that the new facility doesn't get
broken. I have no plans to convert all tests over to this technique,
but I hope others will find this useful for writing tests in the
future.
gdb/testsuite/ChangeLog:
* lib/gdb.exp (gdb_test_multiple): Add gdb_test_name mechanism.
* gdb.base/annota1.exp: Update to use gdb_test_name.
2019-10-01 16:29:20 +02:00
|
|
|
|
# fail "test foo"
|
|
|
|
|
# }
|
|
|
|
|
# }
|
|
|
|
|
#
|
|
|
|
|
# Within action elements you can also make use of the variable
|
|
|
|
|
# gdb_test_name. This variable is setup automatically by
|
|
|
|
|
# gdb_test_multiple, and contains the value of MESSAGE. You can then
|
|
|
|
|
# write this, which is equivalent to the above:
|
|
|
|
|
#
|
|
|
|
|
# gdb_test_multiple "print foo" "test foo" {
|
|
|
|
|
# -re "expected output 1" {
|
|
|
|
|
# pass $gdb_test_name
|
|
|
|
|
# }
|
|
|
|
|
# -re "expected output 2" {
|
|
|
|
|
# fail $gdb_test_name
|
2003-11-23 02:09:19 +01:00
|
|
|
|
# }
|
|
|
|
|
# }
|
|
|
|
|
#
|
testsuite: Introduce $inferior_spawn_id
Some important tests, like gdb.base/interrupt.exp end up skipped
against gdbserver, because they depend on inferior I/O, which
gdbserver doesn't do.
This patch adds a mechanism that makes it possible to make them work.
It adds a new "inferior_spawn_id" global that is the spawn ID used for
I/O interaction with the inferior. By default, for native targets, or
remote targets that can do I/O through GDB (semi-hosting) this will be
the same as the gdb/host spawn ID. Otherwise, the board may set this
to some other spawn ID. When debugging with GDBserver, this will be
set to GDBserver's spawn ID.
Then tests can use send_inferior instead of send_gdb to send input to
the inferior, and use expect's "-i" switch to select which spawn ID to
use for matching input/output. That is, something like this will now
work:
send_inferior "echo me\n"
gdb_test_multiple "continue" "test msg" {
-i "$inferior_spawn_id" -re "echo me\r\necho\r\n" {
...
}
}
Or even:
gdb_test_multiple "continue" "test msg" {
-i "$inferior_spawn_id" -re "hello world" {
...
}
-i "$gdb_spawn_id" -re "error.*$gdb_prompt $" {
...
}
}
Of course, by default, gdb_test_multiple still matches with
$gdb_spawn_id.
gdb/testsuite/ChangeLog:
2015-04-07 Pedro Alves <palves@redhat.com>
* lib/gdb.exp (inferior_spawn_id): New global.
(gdb_test_multiple): Handle "-i". Reset the spawn id to GDB's
spawn id after processing the user code.
(default_gdb_start): Set inferior_spawn_id.
(send_inferior): New procedure.
* lib/gdbserver-support.exp (gdbserver_start): Set
inferior_spawn_id.
(close_gdbserver, gdb_exit): Unset inferior_spawn_id.
2015-04-07 19:19:30 +02:00
|
|
|
|
# Like with "expect", you can also specify the spawn id to match with
|
|
|
|
|
# -i "$id". Interesting spawn ids are $inferior_spawn_id and
|
|
|
|
|
# $gdb_spawn_id. The former matches inferior I/O, while the latter
|
|
|
|
|
# matches GDB I/O. E.g.:
|
|
|
|
|
#
|
|
|
|
|
# send_inferior "hello\n"
|
|
|
|
|
# gdb_test_multiple "continue" "test echo" {
|
|
|
|
|
# -i "$inferior_spawn_id" -re "^hello\r\nhello\r\n$" {
|
|
|
|
|
# pass "got echo"
|
|
|
|
|
# }
|
|
|
|
|
# -i "$gdb_spawn_id" -re "Breakpoint.*$gdb_prompt $" {
|
|
|
|
|
# fail "hit breakpoint"
|
|
|
|
|
# }
|
|
|
|
|
# }
|
|
|
|
|
#
|
2011-03-07 17:03:04 +01:00
|
|
|
|
# The standard patterns, such as "Inferior exited..." and "A problem
|
testsuite: Introduce $inferior_spawn_id
Some important tests, like gdb.base/interrupt.exp end up skipped
against gdbserver, because they depend on inferior I/O, which
gdbserver doesn't do.
This patch adds a mechanism that makes it possible to make them work.
It adds a new "inferior_spawn_id" global that is the spawn ID used for
I/O interaction with the inferior. By default, for native targets, or
remote targets that can do I/O through GDB (semi-hosting) this will be
the same as the gdb/host spawn ID. Otherwise, the board may set this
to some other spawn ID. When debugging with GDBserver, this will be
set to GDBserver's spawn ID.
Then tests can use send_inferior instead of send_gdb to send input to
the inferior, and use expect's "-i" switch to select which spawn ID to
use for matching input/output. That is, something like this will now
work:
send_inferior "echo me\n"
gdb_test_multiple "continue" "test msg" {
-i "$inferior_spawn_id" -re "echo me\r\necho\r\n" {
...
}
}
Or even:
gdb_test_multiple "continue" "test msg" {
-i "$inferior_spawn_id" -re "hello world" {
...
}
-i "$gdb_spawn_id" -re "error.*$gdb_prompt $" {
...
}
}
Of course, by default, gdb_test_multiple still matches with
$gdb_spawn_id.
gdb/testsuite/ChangeLog:
2015-04-07 Pedro Alves <palves@redhat.com>
* lib/gdb.exp (inferior_spawn_id): New global.
(gdb_test_multiple): Handle "-i". Reset the spawn id to GDB's
spawn id after processing the user code.
(default_gdb_start): Set inferior_spawn_id.
(send_inferior): New procedure.
* lib/gdbserver-support.exp (gdbserver_start): Set
inferior_spawn_id.
(close_gdbserver, gdb_exit): Unset inferior_spawn_id.
2015-04-07 19:19:30 +02:00
|
|
|
|
# ...", all being implicitly appended to that list. These are always
|
|
|
|
|
# expected from $gdb_spawn_id. IOW, callers do not need to worry
|
|
|
|
|
# about resetting "-i" back to $gdb_spawn_id explicitly.
|
2003-11-23 02:09:19 +01:00
|
|
|
|
#
|
2019-10-24 18:43:46 +02:00
|
|
|
|
# In EXPECT_ARGUMENTS we can use a -wrap pattern flag, that wraps the regexp
|
|
|
|
|
# pattern as gdb_test wraps its message argument.
|
|
|
|
|
# This allows us to rewrite:
|
|
|
|
|
# gdb_test <command> <pattern> <message>
|
|
|
|
|
# into:
|
|
|
|
|
# gdb_test_multiple <command> <message> {
|
|
|
|
|
# -re -wrap <pattern> {
|
|
|
|
|
# pass $gdb_test_name
|
|
|
|
|
# }
|
|
|
|
|
# }
|
|
|
|
|
#
|
2019-10-30 17:41:03 +01:00
|
|
|
|
# In EXPECT_ARGUMENTS, a pattern flag -early can be used. It makes sure the
|
|
|
|
|
# pattern is inserted before any implicit pattern added by gdb_test_multiple.
|
|
|
|
|
# Using this pattern flag, we can f.i. setup a kfail for an assertion failure
|
|
|
|
|
# <assert> during gdb_continue_to_breakpoint by the rewrite:
|
|
|
|
|
# gdb_continue_to_breakpoint <msg> <pattern>
|
|
|
|
|
# into:
|
|
|
|
|
# set breakpoint_pattern "(?:Breakpoint|Temporary breakpoint) .* (at|in)"
|
|
|
|
|
# gdb_test_multiple "continue" "continue to breakpoint: <msg>" {
|
|
|
|
|
# -early -re "internal-error: <assert>" {
|
|
|
|
|
# setup_kfail gdb/nnnnn "*-*-*"
|
|
|
|
|
# exp_continue
|
|
|
|
|
# }
|
|
|
|
|
# -re "$breakpoint_pattern <pattern>\r\n$gdb_prompt $" {
|
|
|
|
|
# pass $gdb_test_name
|
|
|
|
|
# }
|
|
|
|
|
# }
|
|
|
|
|
#
|
2019-07-29 11:24:04 +02:00
|
|
|
|
proc gdb_test_multiple { command message user_code { prompt_regexp "" } } {
|
2011-12-03 21:20:29 +01:00
|
|
|
|
global verbose use_gdb_stub
|
Fix paginate-*.exp races
Jan pointed out in
<https://sourceware.org/ml/gdb-patches/2014-07/msg00553.html> that
these testcases have racy results:
gdb.base/double-prompt-target-event-error.exp
gdb.base/paginate-after-ctrl-c-running.exp
gdb.base/paginate-bg-execution.exp
gdb.base/paginate-execution-startup.exp
gdb.base/paginate-inferior-exit.exp
This is easily reproducible with "read1" from:
[reproducer for races of expect incomplete reads]
http://sourceware.org/bugzilla/show_bug.cgi?id=12649
The '-notransfer -re "<return>" { exp_continue }' trick in the current
tests doesn't actually work.
The issue that led to the -notransfer trick was that
"---Type <return> to continue, or q <return> to quit---"
has two "<return>"s. If one wants gdb_test_multiple to not hit the
built-in "<return>" match that results in FAIL, one has to expect the
pagination prompt in chunks, first up to the first "<return>", then
again, up to the second. Something around these lines:
gdb_test_multiple "" $test {
-re "<return>" {
exp_continue
}
-re "to quit ---" {
pass $test
}
}
The intent was for -notransfer+exp_continue to make expect fetch more
input, and rerun the matches against the now potentially fuller
buffer, and then eventually the -re that includes the full pagination
prompt regex would match instead (because it's listed higher up, it
would match first). But, once that "<return>" -notransfer -re
matches, it keeps re-matching forever. It seems like with
exp_continue, expect immediately retries matching, instead of first
reading in more data into the buffer, if available.
Fix this like I should have done in the first place. There's actually
no good reason for gdb_test_multiple to only match "<return>". We can
make gdb_test_multiple expect the whole pagination prompt text
instead, which is store in the 'pagination_prompt' global (similar to
'gdb_prompt'). Then a gdb_test_multiple caller that doesn't want the
default match to trigger, because it wants to see one pagination
prompt, does simply:
gdb_test_multiple "" $test {
-re "$pagination_prompt$" {
pass $test
}
}
which is just like when we don't want the default $gdb_prompt match
within gdb_test_multiple to trigger, like:
gdb_test_multiple "" $test {
-re "$gdb_prompt $" {
pass $test
}
}
Tested on x86_64 Fedora 20. In addition, I've let the racy tests run
all in parallel in a loop for 30 minutes, and they never failed.
gdb/testsuite/
2014-07-25 Pedro Alves <palves@redhat.com>
* gdb.base/double-prompt-target-event-error.exp
(cancel_pagination_in_target_event): Remove '-notransfer <return>'
match.
(cancel_pagination_in_target_event): Rework double prompt
detection.
* gdb.base/paginate-after-ctrl-c-running.exp
(test_ctrlc_while_target_running_paginates): Remove '-notransfer
<return>' match.
* gdb.base/paginate-bg-execution.exp
(test_bg_execution_pagination_return)
(test_bg_execution_pagination_cancel): Remove '-notransfer
<return>' matches.
* gdb.base/paginate-execution-startup.exp
(test_fg_execution_pagination_return)
(test_fg_execution_pagination_cancel): Remove '-notransfer
<return>' matches.
* gdb.base/paginate-inferior-exit.exp
(test_paginate_inferior_exited): Remove '-notransfer <return>'
match.
* lib/gdb-utils.exp (string_to_regexp): Move here from lib/gdb.exp.
* lib/gdb.exp (pagination_prompt): Run text through
string_to_regexp.
(gdb_test_multiple): Match $pagination_prompt instead of
"<return>".
(string_to_regexp): Move to lib/gdb-utils.exp.
2014-07-25 11:07:38 +02:00
|
|
|
|
global gdb_prompt pagination_prompt
|
1999-04-16 03:35:26 +02:00
|
|
|
|
global GDB
|
testsuite: Introduce $inferior_spawn_id
Some important tests, like gdb.base/interrupt.exp end up skipped
against gdbserver, because they depend on inferior I/O, which
gdbserver doesn't do.
This patch adds a mechanism that makes it possible to make them work.
It adds a new "inferior_spawn_id" global that is the spawn ID used for
I/O interaction with the inferior. By default, for native targets, or
remote targets that can do I/O through GDB (semi-hosting) this will be
the same as the gdb/host spawn ID. Otherwise, the board may set this
to some other spawn ID. When debugging with GDBserver, this will be
set to GDBserver's spawn ID.
Then tests can use send_inferior instead of send_gdb to send input to
the inferior, and use expect's "-i" switch to select which spawn ID to
use for matching input/output. That is, something like this will now
work:
send_inferior "echo me\n"
gdb_test_multiple "continue" "test msg" {
-i "$inferior_spawn_id" -re "echo me\r\necho\r\n" {
...
}
}
Or even:
gdb_test_multiple "continue" "test msg" {
-i "$inferior_spawn_id" -re "hello world" {
...
}
-i "$gdb_spawn_id" -re "error.*$gdb_prompt $" {
...
}
}
Of course, by default, gdb_test_multiple still matches with
$gdb_spawn_id.
gdb/testsuite/ChangeLog:
2015-04-07 Pedro Alves <palves@redhat.com>
* lib/gdb.exp (inferior_spawn_id): New global.
(gdb_test_multiple): Handle "-i". Reset the spawn id to GDB's
spawn id after processing the user code.
(default_gdb_start): Set inferior_spawn_id.
(send_inferior): New procedure.
* lib/gdbserver-support.exp (gdbserver_start): Set
inferior_spawn_id.
(close_gdbserver, gdb_exit): Unset inferior_spawn_id.
2015-04-07 19:19:30 +02:00
|
|
|
|
global gdb_spawn_id
|
2011-03-07 17:03:04 +01:00
|
|
|
|
global inferior_exited_re
|
1999-04-16 03:35:26 +02:00
|
|
|
|
upvar timeout timeout
|
2004-02-01 19:04:37 +01:00
|
|
|
|
upvar expect_out expect_out
|
2015-04-23 16:48:26 +02:00
|
|
|
|
global any_spawn_id
|
1999-04-16 03:35:26 +02:00
|
|
|
|
|
2019-07-29 11:24:04 +02:00
|
|
|
|
if { "$prompt_regexp" == "" } {
|
|
|
|
|
set prompt_regexp "$gdb_prompt $"
|
|
|
|
|
}
|
|
|
|
|
|
2003-01-23 02:35:21 +01:00
|
|
|
|
if { $message == "" } {
|
|
|
|
|
set message $command
|
1999-04-16 03:35:26 +02:00
|
|
|
|
}
|
|
|
|
|
|
2010-06-28 22:09:59 +02:00
|
|
|
|
if [string match "*\[\r\n\]" $command] {
|
|
|
|
|
error "Invalid trailing newline in \"$message\" test"
|
|
|
|
|
}
|
|
|
|
|
|
2011-04-27 21:44:42 +02:00
|
|
|
|
if [string match "*\[\r\n\]*" $message] {
|
|
|
|
|
error "Invalid newline in \"$message\" test"
|
|
|
|
|
}
|
|
|
|
|
|
2011-12-03 21:20:29 +01:00
|
|
|
|
if {$use_gdb_stub
|
2012-05-09 16:29:49 +02:00
|
|
|
|
&& [regexp -nocase {^\s*(r|run|star|start|at|att|atta|attac|attach)\M} \
|
2011-12-03 21:20:29 +01:00
|
|
|
|
$command]} {
|
|
|
|
|
error "gdbserver does not support $command without extended-remote"
|
|
|
|
|
}
|
|
|
|
|
|
2003-01-23 02:35:21 +01:00
|
|
|
|
# TCL/EXPECT WART ALERT
|
|
|
|
|
# Expect does something very strange when it receives a single braced
|
|
|
|
|
# argument. It splits it along word separators and performs substitutions.
|
|
|
|
|
# This means that { "[ab]" } is evaluated as "[ab]", but { "\[ab\]" } is
|
|
|
|
|
# evaluated as "\[ab\]". But that's not how TCL normally works; inside a
|
|
|
|
|
# double-quoted list item, "\[ab\]" is just a long way of representing
|
|
|
|
|
# "[ab]", because the backslashes will be removed by lindex.
|
|
|
|
|
|
|
|
|
|
# Unfortunately, there appears to be no easy way to duplicate the splitting
|
|
|
|
|
# that expect will do from within TCL. And many places make use of the
|
|
|
|
|
# "\[0-9\]" construct, so we need to support that; and some places make use
|
|
|
|
|
# of the "[func]" construct, so we need to support that too. In order to
|
|
|
|
|
# get this right we have to substitute quoted list elements differently
|
|
|
|
|
# from braced list elements.
|
|
|
|
|
|
|
|
|
|
# We do this roughly the same way that Expect does it. We have to use two
|
|
|
|
|
# lists, because if we leave unquoted newlines in the argument to uplevel
|
|
|
|
|
# they'll be treated as command separators, and if we escape newlines
|
|
|
|
|
# we mangle newlines inside of command blocks. This assumes that the
|
|
|
|
|
# input doesn't contain a pattern which contains actual embedded newlines
|
|
|
|
|
# at this point!
|
|
|
|
|
|
|
|
|
|
regsub -all {\n} ${user_code} { } subst_code
|
|
|
|
|
set subst_code [uplevel list $subst_code]
|
|
|
|
|
|
|
|
|
|
set processed_code ""
|
2019-10-30 17:41:03 +01:00
|
|
|
|
set early_processed_code ""
|
|
|
|
|
# The variable current_list holds the name of the currently processed
|
|
|
|
|
# list, either processed_code or early_processed_code.
|
|
|
|
|
set current_list "processed_code"
|
2003-01-23 02:35:21 +01:00
|
|
|
|
set patterns ""
|
|
|
|
|
set expecting_action 0
|
2010-03-12 22:07:51 +01:00
|
|
|
|
set expecting_arg 0
|
2019-10-24 18:43:46 +02:00
|
|
|
|
set wrap_pattern 0
|
2003-01-23 02:35:21 +01:00
|
|
|
|
foreach item $user_code subst_item $subst_code {
|
|
|
|
|
if { $item == "-n" || $item == "-notransfer" || $item == "-nocase" } {
|
2019-10-30 17:41:03 +01:00
|
|
|
|
lappend $current_list $item
|
2003-01-23 02:35:21 +01:00
|
|
|
|
continue
|
|
|
|
|
}
|
2010-03-12 22:07:51 +01:00
|
|
|
|
if { $item == "-indices" || $item == "-re" || $item == "-ex" } {
|
2019-10-30 17:41:03 +01:00
|
|
|
|
lappend $current_list $item
|
|
|
|
|
continue
|
|
|
|
|
}
|
|
|
|
|
if { $item == "-early" } {
|
|
|
|
|
set current_list "early_processed_code"
|
2010-03-12 22:07:51 +01:00
|
|
|
|
continue
|
|
|
|
|
}
|
testsuite: Introduce $inferior_spawn_id
Some important tests, like gdb.base/interrupt.exp end up skipped
against gdbserver, because they depend on inferior I/O, which
gdbserver doesn't do.
This patch adds a mechanism that makes it possible to make them work.
It adds a new "inferior_spawn_id" global that is the spawn ID used for
I/O interaction with the inferior. By default, for native targets, or
remote targets that can do I/O through GDB (semi-hosting) this will be
the same as the gdb/host spawn ID. Otherwise, the board may set this
to some other spawn ID. When debugging with GDBserver, this will be
set to GDBserver's spawn ID.
Then tests can use send_inferior instead of send_gdb to send input to
the inferior, and use expect's "-i" switch to select which spawn ID to
use for matching input/output. That is, something like this will now
work:
send_inferior "echo me\n"
gdb_test_multiple "continue" "test msg" {
-i "$inferior_spawn_id" -re "echo me\r\necho\r\n" {
...
}
}
Or even:
gdb_test_multiple "continue" "test msg" {
-i "$inferior_spawn_id" -re "hello world" {
...
}
-i "$gdb_spawn_id" -re "error.*$gdb_prompt $" {
...
}
}
Of course, by default, gdb_test_multiple still matches with
$gdb_spawn_id.
gdb/testsuite/ChangeLog:
2015-04-07 Pedro Alves <palves@redhat.com>
* lib/gdb.exp (inferior_spawn_id): New global.
(gdb_test_multiple): Handle "-i". Reset the spawn id to GDB's
spawn id after processing the user code.
(default_gdb_start): Set inferior_spawn_id.
(send_inferior): New procedure.
* lib/gdbserver-support.exp (gdbserver_start): Set
inferior_spawn_id.
(close_gdbserver, gdb_exit): Unset inferior_spawn_id.
2015-04-07 19:19:30 +02:00
|
|
|
|
if { $item == "-timeout" || $item == "-i" } {
|
2010-03-12 22:07:51 +01:00
|
|
|
|
set expecting_arg 1
|
2019-10-30 17:41:03 +01:00
|
|
|
|
lappend $current_list $item
|
2010-03-12 22:07:51 +01:00
|
|
|
|
continue
|
|
|
|
|
}
|
2019-10-24 18:43:46 +02:00
|
|
|
|
if { $item == "-wrap" } {
|
|
|
|
|
set wrap_pattern 1
|
|
|
|
|
continue
|
|
|
|
|
}
|
2010-03-12 22:07:51 +01:00
|
|
|
|
if { $expecting_arg } {
|
|
|
|
|
set expecting_arg 0
|
2019-10-30 17:41:03 +01:00
|
|
|
|
lappend $current_list $subst_item
|
2003-01-23 02:35:21 +01:00
|
|
|
|
continue
|
|
|
|
|
}
|
|
|
|
|
if { $expecting_action } {
|
2019-10-30 17:41:03 +01:00
|
|
|
|
lappend $current_list "uplevel [list $item]"
|
2003-01-23 02:35:21 +01:00
|
|
|
|
set expecting_action 0
|
|
|
|
|
# Cosmetic, no effect on the list.
|
2019-10-30 17:41:03 +01:00
|
|
|
|
append $current_list "\n"
|
|
|
|
|
# End the effect of -early, it only applies to one action.
|
|
|
|
|
set current_list "processed_code"
|
2003-01-23 02:35:21 +01:00
|
|
|
|
continue
|
|
|
|
|
}
|
|
|
|
|
set expecting_action 1
|
2019-10-24 18:43:46 +02:00
|
|
|
|
if { $wrap_pattern } {
|
|
|
|
|
# Wrap subst_item as is done for the gdb_test PATTERN argument.
|
2019-10-30 17:41:03 +01:00
|
|
|
|
lappend $current_list \
|
2019-10-24 18:43:46 +02:00
|
|
|
|
"\[\r\n\]*(?:$subst_item)\[\r\n\]+$gdb_prompt $"
|
|
|
|
|
set wrap_pattern 0
|
|
|
|
|
} else {
|
2019-10-30 17:41:03 +01:00
|
|
|
|
lappend $current_list $subst_item
|
2019-10-24 18:43:46 +02:00
|
|
|
|
}
|
2003-01-23 02:35:21 +01:00
|
|
|
|
if {$patterns != ""} {
|
|
|
|
|
append patterns "; "
|
|
|
|
|
}
|
|
|
|
|
append patterns "\"$subst_item\""
|
1999-04-16 03:35:26 +02:00
|
|
|
|
}
|
|
|
|
|
|
2003-01-23 02:35:21 +01:00
|
|
|
|
# Also purely cosmetic.
|
|
|
|
|
regsub -all {\r} $patterns {\\r} patterns
|
|
|
|
|
regsub -all {\n} $patterns {\\n} patterns
|
|
|
|
|
|
1999-04-16 03:35:26 +02:00
|
|
|
|
if $verbose>2 then {
|
|
|
|
|
send_user "Sending \"$command\" to gdb\n"
|
2003-01-23 02:35:21 +01:00
|
|
|
|
send_user "Looking to match \"$patterns\"\n"
|
1999-04-16 03:35:26 +02:00
|
|
|
|
send_user "Message is \"$message\"\n"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
set result -1
|
2013-06-07 19:31:09 +02:00
|
|
|
|
set string "${command}\n"
|
1999-04-16 03:35:26 +02:00
|
|
|
|
if { $command != "" } {
|
2011-10-17 19:10:55 +02:00
|
|
|
|
set multi_line_re "\[\r\n\] *>"
|
1999-04-16 03:35:26 +02:00
|
|
|
|
while { "$string" != "" } {
|
2013-06-07 19:31:09 +02:00
|
|
|
|
set foo [string first "\n" "$string"]
|
|
|
|
|
set len [string length "$string"]
|
1999-04-16 03:35:26 +02:00
|
|
|
|
if { $foo < [expr $len - 1] } {
|
2013-06-07 19:31:09 +02:00
|
|
|
|
set str [string range "$string" 0 $foo]
|
1999-04-16 03:35:26 +02:00
|
|
|
|
if { [send_gdb "$str"] != "" } {
|
2013-06-07 19:31:09 +02:00
|
|
|
|
global suppress_flag
|
1999-04-16 03:35:26 +02:00
|
|
|
|
|
|
|
|
|
if { ! $suppress_flag } {
|
2013-06-07 19:31:09 +02:00
|
|
|
|
perror "Couldn't send $command to GDB."
|
1999-04-16 03:35:26 +02:00
|
|
|
|
}
|
2013-06-07 19:31:09 +02:00
|
|
|
|
fail "$message"
|
gdb/testsuite/
* config/monitor.exp (gdb_target_cmd): Remove semicolon after
'return'.
(gdb_target_monitor, gdb_load): Likewise.
* config/sid.exp (gdb_load): Likewise.
* config/slite.exp (gdb_load): Likewise.
* config/vx.exp (gdb_start, spawn_vxgdb): Likewise.
* gdb.ada/arrayidx.exp, gdb.ada/null_array.exp: Likewise.
* gdb.arch/mips-octeon-bbit.exp (single_step): Likewise.
(single_step_until): Likewise.
* gdb.arch/powerpc-d128-regs.exp: Likewise.
* gdb.arch/system-gcore.exp: Likewise.
* gdb.base/bigcore.exp (extract_heap): Likewise.
* gdb.base/break-on-linker-gcd-function.exp: Likewise.
* gdb.base/call-ar-st.exp: Likewise.
* gdb.base/call-rt-st.exp: Likewise.
* gdb.base/call-sc.exp, gdb.base/call-strs.exp: Likewise.
* gdb.base/callfuncs.exp, gdb.base/completion.exp: Likewise.
* gdb.base/condbreak.exp, gdb.base/constvars.exp: Likewise.
* gdb.base/corefile.exp: Likewise.
* gdb.base/dbx.exp (gdb_file_cmd): Likewise.
* gdb.base/exprs.exp, gdb.base/fileio.exp: Likewise.
* gdb.base/fixsection.exp: Likewise.
* gdb.base/funcargs.exp: Likewise.
* gdb.base/gcore-buffer-overflow.exp: Likewise.
* gdb.base/gcore-relro.exp: Likewise.
* gdb.base/gcore.exp, gdb.base/gdb11530.exp: Likewise.
* gdb.base/gdb11531.exp, gdb.base/gnu-ifunc.exp: Likewise.
* gdb.base/info-os.exp, gdb.base/info-proc.exp: Likewise.
* gdb.base/interp.exp, gdb.base/langs.exp:: Likewise.
* gdb.base/list.exp: Likewise.
(set_listsize): Likewise.
* gdb.base/logical.exp, gdb.base/mips_pro.exp: Likewise.
* gdb.base/miscexprs.exp, gdb.base/nodebug.exp: Likewise.
* gdb.base/opaque.exp, gdb.base/pointers.exp: Likewise.
* gdb.base/psymtab.exp, gdb.base/ptype.exp: Likewise.
* gdb.base/relational.exp, gdb.base/scope.exp: Likewise.
* gdb.base/setvar.exp: Likewise.
(test_set): Likewise.
* gdb.base/signals.exp, gdb.base/sizeof.exp: Likewise.
* gdb.base/solib-overlap.exp: Likewise.
* gdb.base/store.exp, gdb.base/structs.exp: Likewise.
* gdb.base/structs2.exp, gdb.base/volatile.exp: Likewise.
* gdb.base/watchpoint.exp (initialize): Likewise.
(test_simple_watchpoint): Likewise.
(test_disabling_watchpoints): Likewise.
(test_watchpoint_triggered_in_syscall): Likewise.
* gdb.base/whatis.exp, gdb.cp/ambiguous.exp: Likewise.
* gdb.cp/casts.exp, gdb.cp/ctti.exp: Likewise.
* gdb.cp/namespace.exp, gdb.cp/nsdecl.exp: Likewise.
* gdb.cp/psmang.exp, gdb.dwarf2/dw2-ranges.exp: Likewise.
* gdb.hp/gdb.aCC/optimize.exp: Likewise.
* gdb.hp/gdb.aCC/watch-cmd.exp: Likewise.
* gdb.hp/gdb.base-hp/callfwmall.exp: Likewise.
* gdb.hp/gdb.base-hp/pxdb.exp: Likewise.
* gdb.hp/gdb.compat/xdb1.exp: Likewise.
* gdb.hp/gdb.compat/xdb2.exp: Likewise.
* gdb.hp/gdb.compat/xdb3.exp: Likewise.
* gdb.hp/gdb.defects/bs14602.exp: Likewise.
* gdb.hp/gdb.defects/solib-d.exp: Likewise.
* gdb.mi/gdb792.exp: Likewise.
* gdb.mi/mi-inheritance-syntax-error.exp: Likewise.
* gdb.mi/mi-logging.exp, gdb.mi/mi-var-cp.exp : Likewise.
* gdb.mi/mi-var-rtti.exp, gdb.python/py-type.exp: Likewise.
* gdb.threads/gcore-thread.exp: Likewise.
(load_core): Likewise.
* gdb.threads/pthreads.exp (all_threads_running): Likewise.
(test_startup, check_control_c): Likewise.
* gdb.threads/sigstep-threads.exp: Likewise.
* gdb.threads/thread_check.exp: Likewise.
* gdb.trace/backtrace.exp, gdb.trace/change-loc.exp: Likewise.
* gdb.trace/circ.exp (run_trace_experiment): Likewise.
(set_a_tracepoint, trace_buffer_normal): Likewise.
(gdb_trace_circular_tests): Likewise.
* gdb.trace/collection.exp: Likewise.
* gdb.trace/disconnected-tracing.exp: Likewise.
* gdb.trace/infotrace.exp: Likewise.
* gdb.trace/mi-traceframe-changed.exp: Likewise.
* gdb.trace/mi-tracepoint-changed.exp: Likewise.
* gdb.trace/mi-tsv-changed.exp (test_create_delete_modify_tsv): Likewise.
* gdb.trace/packetlen.exp, gdb.trace/passc-dyn.exp: Likewise.
* gdb.trace/pending.exp, gdb.trace/report.exp: Likewise.
* gdb.trace/stap-trace.exp: Likewise.
* gdb.trace/status-stop.exp,gdb.trace/strace.exp: Likewise.
* gdb.trace/tfind.exp, gdb.trace/trace-break.exp: Likewise.
* gdb.trace/trace-buffer-size.exp: Likewise.
* gdb.trace/tspeed.exp, gdb.trace/tsv.exp: Likewise.
* gdb.trace/unavailable.exp: Likewise.
* gdb.trace/while-dyn.exp: Likewise.
* lib/fortran.exp (set_lang_fortran): Likewise.
* lib/gdb.exp (default_gdb_version, gdb_start_cmd): Likewise.
(gdb_breakpoint, gdb_reinitialize_dir): Likewise.
(default_gdb_start, get_compiler_info): Likewise.
(gdb_compile, gdb_compile_objc, gdb_reload, gdb_init): Likewise.
(get_debug_format, setup_xfail_format): Likewise.
(rerun_to_main, gdb_skip_float_test): Likewise.
(build_id_debug_filename_get, get_remotetimeout): Likewise.
* lib/java.exp (set_lang_java): Likewise.
* lib/mi-support.exp (default_mi_gdb_start): Likewise.
(mi_gdb_reinitialize_dir, mi_gdb_target_cmd): Likewise.
(mi_gdb_file_cmd, mi_gdb_test): Likewise.
(mi_run_cmd_full, mi_expect_interrupt): Likewise.
* lib/objc.exp (set_lang_objc): Likewise.
* lib/pascal.exp (set_lang_pascal): Likewise.
* lib/prompt.exp (default_prompt_gdb_start): Likewise.
* lib/trace-support.exp (gdb_trace_setactions, gdb_tfind_test): Likewise.
(gdb_readexpr, gdb_gettpnum, gdb_find_recursion_test_baseline): Likewise.
2013-03-14 14:34:06 +01:00
|
|
|
|
return $result
|
1999-04-16 03:35:26 +02:00
|
|
|
|
}
|
1999-08-03 01:48:37 +02:00
|
|
|
|
# since we're checking if each line of the multi-line
|
|
|
|
|
# command are 'accepted' by GDB here,
|
|
|
|
|
# we need to set -notransfer expect option so that
|
|
|
|
|
# command output is not lost for pattern matching
|
|
|
|
|
# - guo
|
2002-04-03 18:17:11 +02:00
|
|
|
|
gdb_expect 2 {
|
2011-10-17 19:10:55 +02:00
|
|
|
|
-notransfer -re "$multi_line_re$" { verbose "partial: match" 3 }
|
2002-04-03 18:17:11 +02:00
|
|
|
|
timeout { verbose "partial: timeout" 3 }
|
1999-04-16 03:35:26 +02:00
|
|
|
|
}
|
2013-06-07 19:31:09 +02:00
|
|
|
|
set string [string range "$string" [expr $foo + 1] end]
|
2011-10-17 19:10:55 +02:00
|
|
|
|
set multi_line_re "$multi_line_re.*\[\r\n\] *>"
|
1999-04-16 03:35:26 +02:00
|
|
|
|
} else {
|
2013-06-07 19:31:09 +02:00
|
|
|
|
break
|
1999-04-16 03:35:26 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if { "$string" != "" } {
|
|
|
|
|
if { [send_gdb "$string"] != "" } {
|
2013-06-07 19:31:09 +02:00
|
|
|
|
global suppress_flag
|
1999-04-16 03:35:26 +02:00
|
|
|
|
|
|
|
|
|
if { ! $suppress_flag } {
|
2013-06-07 19:31:09 +02:00
|
|
|
|
perror "Couldn't send $command to GDB."
|
1999-04-16 03:35:26 +02:00
|
|
|
|
}
|
2013-06-07 19:31:09 +02:00
|
|
|
|
fail "$message"
|
gdb/testsuite/
* config/monitor.exp (gdb_target_cmd): Remove semicolon after
'return'.
(gdb_target_monitor, gdb_load): Likewise.
* config/sid.exp (gdb_load): Likewise.
* config/slite.exp (gdb_load): Likewise.
* config/vx.exp (gdb_start, spawn_vxgdb): Likewise.
* gdb.ada/arrayidx.exp, gdb.ada/null_array.exp: Likewise.
* gdb.arch/mips-octeon-bbit.exp (single_step): Likewise.
(single_step_until): Likewise.
* gdb.arch/powerpc-d128-regs.exp: Likewise.
* gdb.arch/system-gcore.exp: Likewise.
* gdb.base/bigcore.exp (extract_heap): Likewise.
* gdb.base/break-on-linker-gcd-function.exp: Likewise.
* gdb.base/call-ar-st.exp: Likewise.
* gdb.base/call-rt-st.exp: Likewise.
* gdb.base/call-sc.exp, gdb.base/call-strs.exp: Likewise.
* gdb.base/callfuncs.exp, gdb.base/completion.exp: Likewise.
* gdb.base/condbreak.exp, gdb.base/constvars.exp: Likewise.
* gdb.base/corefile.exp: Likewise.
* gdb.base/dbx.exp (gdb_file_cmd): Likewise.
* gdb.base/exprs.exp, gdb.base/fileio.exp: Likewise.
* gdb.base/fixsection.exp: Likewise.
* gdb.base/funcargs.exp: Likewise.
* gdb.base/gcore-buffer-overflow.exp: Likewise.
* gdb.base/gcore-relro.exp: Likewise.
* gdb.base/gcore.exp, gdb.base/gdb11530.exp: Likewise.
* gdb.base/gdb11531.exp, gdb.base/gnu-ifunc.exp: Likewise.
* gdb.base/info-os.exp, gdb.base/info-proc.exp: Likewise.
* gdb.base/interp.exp, gdb.base/langs.exp:: Likewise.
* gdb.base/list.exp: Likewise.
(set_listsize): Likewise.
* gdb.base/logical.exp, gdb.base/mips_pro.exp: Likewise.
* gdb.base/miscexprs.exp, gdb.base/nodebug.exp: Likewise.
* gdb.base/opaque.exp, gdb.base/pointers.exp: Likewise.
* gdb.base/psymtab.exp, gdb.base/ptype.exp: Likewise.
* gdb.base/relational.exp, gdb.base/scope.exp: Likewise.
* gdb.base/setvar.exp: Likewise.
(test_set): Likewise.
* gdb.base/signals.exp, gdb.base/sizeof.exp: Likewise.
* gdb.base/solib-overlap.exp: Likewise.
* gdb.base/store.exp, gdb.base/structs.exp: Likewise.
* gdb.base/structs2.exp, gdb.base/volatile.exp: Likewise.
* gdb.base/watchpoint.exp (initialize): Likewise.
(test_simple_watchpoint): Likewise.
(test_disabling_watchpoints): Likewise.
(test_watchpoint_triggered_in_syscall): Likewise.
* gdb.base/whatis.exp, gdb.cp/ambiguous.exp: Likewise.
* gdb.cp/casts.exp, gdb.cp/ctti.exp: Likewise.
* gdb.cp/namespace.exp, gdb.cp/nsdecl.exp: Likewise.
* gdb.cp/psmang.exp, gdb.dwarf2/dw2-ranges.exp: Likewise.
* gdb.hp/gdb.aCC/optimize.exp: Likewise.
* gdb.hp/gdb.aCC/watch-cmd.exp: Likewise.
* gdb.hp/gdb.base-hp/callfwmall.exp: Likewise.
* gdb.hp/gdb.base-hp/pxdb.exp: Likewise.
* gdb.hp/gdb.compat/xdb1.exp: Likewise.
* gdb.hp/gdb.compat/xdb2.exp: Likewise.
* gdb.hp/gdb.compat/xdb3.exp: Likewise.
* gdb.hp/gdb.defects/bs14602.exp: Likewise.
* gdb.hp/gdb.defects/solib-d.exp: Likewise.
* gdb.mi/gdb792.exp: Likewise.
* gdb.mi/mi-inheritance-syntax-error.exp: Likewise.
* gdb.mi/mi-logging.exp, gdb.mi/mi-var-cp.exp : Likewise.
* gdb.mi/mi-var-rtti.exp, gdb.python/py-type.exp: Likewise.
* gdb.threads/gcore-thread.exp: Likewise.
(load_core): Likewise.
* gdb.threads/pthreads.exp (all_threads_running): Likewise.
(test_startup, check_control_c): Likewise.
* gdb.threads/sigstep-threads.exp: Likewise.
* gdb.threads/thread_check.exp: Likewise.
* gdb.trace/backtrace.exp, gdb.trace/change-loc.exp: Likewise.
* gdb.trace/circ.exp (run_trace_experiment): Likewise.
(set_a_tracepoint, trace_buffer_normal): Likewise.
(gdb_trace_circular_tests): Likewise.
* gdb.trace/collection.exp: Likewise.
* gdb.trace/disconnected-tracing.exp: Likewise.
* gdb.trace/infotrace.exp: Likewise.
* gdb.trace/mi-traceframe-changed.exp: Likewise.
* gdb.trace/mi-tracepoint-changed.exp: Likewise.
* gdb.trace/mi-tsv-changed.exp (test_create_delete_modify_tsv): Likewise.
* gdb.trace/packetlen.exp, gdb.trace/passc-dyn.exp: Likewise.
* gdb.trace/pending.exp, gdb.trace/report.exp: Likewise.
* gdb.trace/stap-trace.exp: Likewise.
* gdb.trace/status-stop.exp,gdb.trace/strace.exp: Likewise.
* gdb.trace/tfind.exp, gdb.trace/trace-break.exp: Likewise.
* gdb.trace/trace-buffer-size.exp: Likewise.
* gdb.trace/tspeed.exp, gdb.trace/tsv.exp: Likewise.
* gdb.trace/unavailable.exp: Likewise.
* gdb.trace/while-dyn.exp: Likewise.
* lib/fortran.exp (set_lang_fortran): Likewise.
* lib/gdb.exp (default_gdb_version, gdb_start_cmd): Likewise.
(gdb_breakpoint, gdb_reinitialize_dir): Likewise.
(default_gdb_start, get_compiler_info): Likewise.
(gdb_compile, gdb_compile_objc, gdb_reload, gdb_init): Likewise.
(get_debug_format, setup_xfail_format): Likewise.
(rerun_to_main, gdb_skip_float_test): Likewise.
(build_id_debug_filename_get, get_remotetimeout): Likewise.
* lib/java.exp (set_lang_java): Likewise.
* lib/mi-support.exp (default_mi_gdb_start): Likewise.
(mi_gdb_reinitialize_dir, mi_gdb_target_cmd): Likewise.
(mi_gdb_file_cmd, mi_gdb_test): Likewise.
(mi_run_cmd_full, mi_expect_interrupt): Likewise.
* lib/objc.exp (set_lang_objc): Likewise.
* lib/pascal.exp (set_lang_pascal): Likewise.
* lib/prompt.exp (default_prompt_gdb_start): Likewise.
* lib/trace-support.exp (gdb_trace_setactions, gdb_tfind_test): Likewise.
(gdb_readexpr, gdb_gettpnum, gdb_find_recursion_test_baseline): Likewise.
2013-03-14 14:34:06 +01:00
|
|
|
|
return $result
|
1999-04-16 03:35:26 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2019-10-30 17:41:03 +01:00
|
|
|
|
set code $early_processed_code
|
|
|
|
|
append code {
|
2012-05-09 16:29:49 +02:00
|
|
|
|
-re ".*A problem internal to GDB has been detected" {
|
|
|
|
|
fail "$message (GDB internal error)"
|
|
|
|
|
gdb_internal_error_resync
|
2015-03-02 21:05:25 +01:00
|
|
|
|
set result -1
|
2012-05-09 16:29:49 +02:00
|
|
|
|
}
|
|
|
|
|
-re "\\*\\*\\* DOSEXIT code.*" {
|
|
|
|
|
if { $message != "" } {
|
2013-06-07 19:31:09 +02:00
|
|
|
|
fail "$message"
|
2012-05-09 16:29:49 +02:00
|
|
|
|
}
|
2013-06-07 19:31:09 +02:00
|
|
|
|
gdb_suppress_entire_file "GDB died"
|
|
|
|
|
set result -1
|
2012-05-09 16:29:49 +02:00
|
|
|
|
}
|
2007-07-02 23:29:28 +02:00
|
|
|
|
}
|
|
|
|
|
append code $processed_code
|
Fix testsuite hangs when gdb_test_multiple body errors out
This commit fixes a regression in the testsuite itself, triggered by
errors being raised from within gdb_test_multiple, originally reported
by Pedro Franco de Carvalho's at
<https://sourceware.org/ml/gdb-patches/2019-03/msg00160.html>. Parts
of the commit message are based on his report.
This started happening due to a commit that was introduced recently,
and it can cause the testsuite to hang.
The commit that triggers this is:
fe1a5cad302b5535030cdf62895e79512713d738
[gdb/testsuite] Log wait status on process no longer exists error
That commit introduces a new "eof" block in gdb_test_multiple. That
is not incorrect itself, but dejagnu's remote_expect is picking that
block as the "default" action when an error is raised from within the
commands inside a call to gdb_test_multiple:
# remote_expect works basically the same as standard expect, but it
# also takes care of getting the file descriptor from the specified
# host and also calling the timeout/eof/default section if there is an
# error on the expect call.
#
proc remote_expect { board timeout args } {
I find that "feature" surprising, and I don't really know why it
exists, but this means that the eof section that remote_expect picks
as the error block can be executed even when there was no actual eof
and the GDB process is still running, so the wait introduced in the
commit that tries to get the exit status of GDB hangs forever, while
GDB itself waits for input.
This only happens when there are internal testsuite errors (not
testcase failures). This can be reproduced easily with a testcase
such as:
gdb_start
gdb_test_multiple "show version" "show version" {
-re ".*" {
error "forced error"
}
}
I think that working around this in GDB is useful so that the
testsuite doesn't hang in these cases.
Adding an empty "default" block at the end of the expect body in
gdb_test_multiple doesn't work, because dejagnu gives preference to
"eof" blocks:
if { $x eq "eof" } {
set save_next 1
} elseif { $x eq "default" || $x eq "timeout" } {
if { $error_sect eq "" } {
set save_next 1
}
}
And we do have "eof" blocks. So we need to make sure that the last
"eof" block is safe to use as the default error block. It's also
pedantically incorrect to print
"ERROR: Process no longer exists"
which is what we'd get if the last eof block we have was selected
(more below on this).
So this commit solves this by appending an "eof" with an empty
spawn_id list, so that it won't ever match.
Now, why is the first "eof" block selected today as the error block,
instead of the last one?
The reason is that remote_expect, while parsing the body to select the
default block to execute after an error, is affected by the comments
in the body (since they are also parsed).
If this comment in gdb_test_multiple
# patterns below apply to any spawn id specified.
is changed to
# The patterns below apply to any spawn id specified.
then the second eof block is selected and there is no hang.
Any comment at that same place with an even number of tokens also
works.
This is IMO a coincidence caused by how comments work in TCL.
Comments should only appear in places where a command can appear. And
here, remote_expect is parsing a list of options, not commands, so
it's not unreasonable to not parse comments, similarly to how this:
set a_list {
an_element
# another_element
}
results in a list with three elements, not one element.
The fact that comments with an even number of tokens work is just a
coincidence of how remote_expect's little state machine is
implemented.
I thought we could solve this by stripping out comment lines in
gdb_expect, but I didn't find an easy way to do that. Particularly, a
couple naive approaches I tried run into complications. For example,
we have gdb_test calls with regular expressions that include sequences
like "\r\n#", and by the time we get to gdb_expect, the \r\n have
already been expanded to a real newline, so just splitting the whole
body at newline boundaries, looking for lines that start with #
results in incorrectly stripping out half of the gdb_text regexp. I
think it's better (at least in this commit), to move the comments out
of the list, because it's much simpler and risk free.
gdb/testsuite/ChangeLog:
2019-03-25 Pedro Alves <palves@redhat.com>
* lib/gdb.exp (gdb_test_multiple): Split appends to $code and
move comments outside list. Append '-i "" eof' section.
2019-03-25 14:26:23 +01:00
|
|
|
|
|
|
|
|
|
# Reset the spawn id, in case the processed code used -i.
|
2007-07-02 23:29:28 +02:00
|
|
|
|
append code {
|
testsuite: Introduce $inferior_spawn_id
Some important tests, like gdb.base/interrupt.exp end up skipped
against gdbserver, because they depend on inferior I/O, which
gdbserver doesn't do.
This patch adds a mechanism that makes it possible to make them work.
It adds a new "inferior_spawn_id" global that is the spawn ID used for
I/O interaction with the inferior. By default, for native targets, or
remote targets that can do I/O through GDB (semi-hosting) this will be
the same as the gdb/host spawn ID. Otherwise, the board may set this
to some other spawn ID. When debugging with GDBserver, this will be
set to GDBserver's spawn ID.
Then tests can use send_inferior instead of send_gdb to send input to
the inferior, and use expect's "-i" switch to select which spawn ID to
use for matching input/output. That is, something like this will now
work:
send_inferior "echo me\n"
gdb_test_multiple "continue" "test msg" {
-i "$inferior_spawn_id" -re "echo me\r\necho\r\n" {
...
}
}
Or even:
gdb_test_multiple "continue" "test msg" {
-i "$inferior_spawn_id" -re "hello world" {
...
}
-i "$gdb_spawn_id" -re "error.*$gdb_prompt $" {
...
}
}
Of course, by default, gdb_test_multiple still matches with
$gdb_spawn_id.
gdb/testsuite/ChangeLog:
2015-04-07 Pedro Alves <palves@redhat.com>
* lib/gdb.exp (inferior_spawn_id): New global.
(gdb_test_multiple): Handle "-i". Reset the spawn id to GDB's
spawn id after processing the user code.
(default_gdb_start): Set inferior_spawn_id.
(send_inferior): New procedure.
* lib/gdbserver-support.exp (gdbserver_start): Set
inferior_spawn_id.
(close_gdbserver, gdb_exit): Unset inferior_spawn_id.
2015-04-07 19:19:30 +02:00
|
|
|
|
-i "$gdb_spawn_id"
|
Fix testsuite hangs when gdb_test_multiple body errors out
This commit fixes a regression in the testsuite itself, triggered by
errors being raised from within gdb_test_multiple, originally reported
by Pedro Franco de Carvalho's at
<https://sourceware.org/ml/gdb-patches/2019-03/msg00160.html>. Parts
of the commit message are based on his report.
This started happening due to a commit that was introduced recently,
and it can cause the testsuite to hang.
The commit that triggers this is:
fe1a5cad302b5535030cdf62895e79512713d738
[gdb/testsuite] Log wait status on process no longer exists error
That commit introduces a new "eof" block in gdb_test_multiple. That
is not incorrect itself, but dejagnu's remote_expect is picking that
block as the "default" action when an error is raised from within the
commands inside a call to gdb_test_multiple:
# remote_expect works basically the same as standard expect, but it
# also takes care of getting the file descriptor from the specified
# host and also calling the timeout/eof/default section if there is an
# error on the expect call.
#
proc remote_expect { board timeout args } {
I find that "feature" surprising, and I don't really know why it
exists, but this means that the eof section that remote_expect picks
as the error block can be executed even when there was no actual eof
and the GDB process is still running, so the wait introduced in the
commit that tries to get the exit status of GDB hangs forever, while
GDB itself waits for input.
This only happens when there are internal testsuite errors (not
testcase failures). This can be reproduced easily with a testcase
such as:
gdb_start
gdb_test_multiple "show version" "show version" {
-re ".*" {
error "forced error"
}
}
I think that working around this in GDB is useful so that the
testsuite doesn't hang in these cases.
Adding an empty "default" block at the end of the expect body in
gdb_test_multiple doesn't work, because dejagnu gives preference to
"eof" blocks:
if { $x eq "eof" } {
set save_next 1
} elseif { $x eq "default" || $x eq "timeout" } {
if { $error_sect eq "" } {
set save_next 1
}
}
And we do have "eof" blocks. So we need to make sure that the last
"eof" block is safe to use as the default error block. It's also
pedantically incorrect to print
"ERROR: Process no longer exists"
which is what we'd get if the last eof block we have was selected
(more below on this).
So this commit solves this by appending an "eof" with an empty
spawn_id list, so that it won't ever match.
Now, why is the first "eof" block selected today as the error block,
instead of the last one?
The reason is that remote_expect, while parsing the body to select the
default block to execute after an error, is affected by the comments
in the body (since they are also parsed).
If this comment in gdb_test_multiple
# patterns below apply to any spawn id specified.
is changed to
# The patterns below apply to any spawn id specified.
then the second eof block is selected and there is no hang.
Any comment at that same place with an even number of tokens also
works.
This is IMO a coincidence caused by how comments work in TCL.
Comments should only appear in places where a command can appear. And
here, remote_expect is parsing a list of options, not commands, so
it's not unreasonable to not parse comments, similarly to how this:
set a_list {
an_element
# another_element
}
results in a list with three elements, not one element.
The fact that comments with an even number of tokens work is just a
coincidence of how remote_expect's little state machine is
implemented.
I thought we could solve this by stripping out comment lines in
gdb_expect, but I didn't find an easy way to do that. Particularly, a
couple naive approaches I tried run into complications. For example,
we have gdb_test calls with regular expressions that include sequences
like "\r\n#", and by the time we get to gdb_expect, the \r\n have
already been expanded to a real newline, so just splitting the whole
body at newline boundaries, looking for lines that start with #
results in incorrectly stripping out half of the gdb_text regexp. I
think it's better (at least in this commit), to move the comments out
of the list, because it's much simpler and risk free.
gdb/testsuite/ChangeLog:
2019-03-25 Pedro Alves <palves@redhat.com>
* lib/gdb.exp (gdb_test_multiple): Split appends to $code and
move comments outside list. Append '-i "" eof' section.
2019-03-25 14:26:23 +01:00
|
|
|
|
}
|
testsuite: Introduce $inferior_spawn_id
Some important tests, like gdb.base/interrupt.exp end up skipped
against gdbserver, because they depend on inferior I/O, which
gdbserver doesn't do.
This patch adds a mechanism that makes it possible to make them work.
It adds a new "inferior_spawn_id" global that is the spawn ID used for
I/O interaction with the inferior. By default, for native targets, or
remote targets that can do I/O through GDB (semi-hosting) this will be
the same as the gdb/host spawn ID. Otherwise, the board may set this
to some other spawn ID. When debugging with GDBserver, this will be
set to GDBserver's spawn ID.
Then tests can use send_inferior instead of send_gdb to send input to
the inferior, and use expect's "-i" switch to select which spawn ID to
use for matching input/output. That is, something like this will now
work:
send_inferior "echo me\n"
gdb_test_multiple "continue" "test msg" {
-i "$inferior_spawn_id" -re "echo me\r\necho\r\n" {
...
}
}
Or even:
gdb_test_multiple "continue" "test msg" {
-i "$inferior_spawn_id" -re "hello world" {
...
}
-i "$gdb_spawn_id" -re "error.*$gdb_prompt $" {
...
}
}
Of course, by default, gdb_test_multiple still matches with
$gdb_spawn_id.
gdb/testsuite/ChangeLog:
2015-04-07 Pedro Alves <palves@redhat.com>
* lib/gdb.exp (inferior_spawn_id): New global.
(gdb_test_multiple): Handle "-i". Reset the spawn id to GDB's
spawn id after processing the user code.
(default_gdb_start): Set inferior_spawn_id.
(send_inferior): New procedure.
* lib/gdbserver-support.exp (gdbserver_start): Set
inferior_spawn_id.
(close_gdbserver, gdb_exit): Unset inferior_spawn_id.
2015-04-07 19:19:30 +02:00
|
|
|
|
|
Fix testsuite hangs when gdb_test_multiple body errors out
This commit fixes a regression in the testsuite itself, triggered by
errors being raised from within gdb_test_multiple, originally reported
by Pedro Franco de Carvalho's at
<https://sourceware.org/ml/gdb-patches/2019-03/msg00160.html>. Parts
of the commit message are based on his report.
This started happening due to a commit that was introduced recently,
and it can cause the testsuite to hang.
The commit that triggers this is:
fe1a5cad302b5535030cdf62895e79512713d738
[gdb/testsuite] Log wait status on process no longer exists error
That commit introduces a new "eof" block in gdb_test_multiple. That
is not incorrect itself, but dejagnu's remote_expect is picking that
block as the "default" action when an error is raised from within the
commands inside a call to gdb_test_multiple:
# remote_expect works basically the same as standard expect, but it
# also takes care of getting the file descriptor from the specified
# host and also calling the timeout/eof/default section if there is an
# error on the expect call.
#
proc remote_expect { board timeout args } {
I find that "feature" surprising, and I don't really know why it
exists, but this means that the eof section that remote_expect picks
as the error block can be executed even when there was no actual eof
and the GDB process is still running, so the wait introduced in the
commit that tries to get the exit status of GDB hangs forever, while
GDB itself waits for input.
This only happens when there are internal testsuite errors (not
testcase failures). This can be reproduced easily with a testcase
such as:
gdb_start
gdb_test_multiple "show version" "show version" {
-re ".*" {
error "forced error"
}
}
I think that working around this in GDB is useful so that the
testsuite doesn't hang in these cases.
Adding an empty "default" block at the end of the expect body in
gdb_test_multiple doesn't work, because dejagnu gives preference to
"eof" blocks:
if { $x eq "eof" } {
set save_next 1
} elseif { $x eq "default" || $x eq "timeout" } {
if { $error_sect eq "" } {
set save_next 1
}
}
And we do have "eof" blocks. So we need to make sure that the last
"eof" block is safe to use as the default error block. It's also
pedantically incorrect to print
"ERROR: Process no longer exists"
which is what we'd get if the last eof block we have was selected
(more below on this).
So this commit solves this by appending an "eof" with an empty
spawn_id list, so that it won't ever match.
Now, why is the first "eof" block selected today as the error block,
instead of the last one?
The reason is that remote_expect, while parsing the body to select the
default block to execute after an error, is affected by the comments
in the body (since they are also parsed).
If this comment in gdb_test_multiple
# patterns below apply to any spawn id specified.
is changed to
# The patterns below apply to any spawn id specified.
then the second eof block is selected and there is no hang.
Any comment at that same place with an even number of tokens also
works.
This is IMO a coincidence caused by how comments work in TCL.
Comments should only appear in places where a command can appear. And
here, remote_expect is parsing a list of options, not commands, so
it's not unreasonable to not parse comments, similarly to how this:
set a_list {
an_element
# another_element
}
results in a list with three elements, not one element.
The fact that comments with an even number of tokens work is just a
coincidence of how remote_expect's little state machine is
implemented.
I thought we could solve this by stripping out comment lines in
gdb_expect, but I didn't find an easy way to do that. Particularly, a
couple naive approaches I tried run into complications. For example,
we have gdb_test calls with regular expressions that include sequences
like "\r\n#", and by the time we get to gdb_expect, the \r\n have
already been expanded to a real newline, so just splitting the whole
body at newline boundaries, looking for lines that start with #
results in incorrectly stripping out half of the gdb_text regexp. I
think it's better (at least in this commit), to move the comments out
of the list, because it's much simpler and risk free.
gdb/testsuite/ChangeLog:
2019-03-25 Pedro Alves <palves@redhat.com>
* lib/gdb.exp (gdb_test_multiple): Split appends to $code and
move comments outside list. Append '-i "" eof' section.
2019-03-25 14:26:23 +01:00
|
|
|
|
append code {
|
2019-07-29 11:24:04 +02:00
|
|
|
|
-re "Ending remote debugging.*$prompt_regexp" {
|
1999-04-16 03:35:26 +02:00
|
|
|
|
if ![isnative] then {
|
|
|
|
|
warning "Can`t communicate to remote target."
|
|
|
|
|
}
|
|
|
|
|
gdb_exit
|
|
|
|
|
gdb_start
|
|
|
|
|
set result -1
|
|
|
|
|
}
|
2019-07-29 11:24:04 +02:00
|
|
|
|
-re "Undefined\[a-z\]* command:.*$prompt_regexp" {
|
1999-04-16 03:35:26 +02:00
|
|
|
|
perror "Undefined command \"$command\"."
|
2012-05-09 16:29:49 +02:00
|
|
|
|
fail "$message"
|
1999-04-16 03:35:26 +02:00
|
|
|
|
set result 1
|
|
|
|
|
}
|
2019-07-29 11:24:04 +02:00
|
|
|
|
-re "Ambiguous command.*$prompt_regexp" {
|
1999-04-16 03:35:26 +02:00
|
|
|
|
perror "\"$command\" is not a unique command name."
|
2012-05-09 16:29:49 +02:00
|
|
|
|
fail "$message"
|
1999-04-16 03:35:26 +02:00
|
|
|
|
set result 1
|
|
|
|
|
}
|
2019-07-29 11:24:04 +02:00
|
|
|
|
-re "$inferior_exited_re with code \[0-9\]+.*$prompt_regexp" {
|
1999-04-16 03:35:26 +02:00
|
|
|
|
if ![string match "" $message] then {
|
2003-04-03 18:34:48 +02:00
|
|
|
|
set errmsg "$message (the program exited)"
|
1999-04-16 03:35:26 +02:00
|
|
|
|
} else {
|
2003-04-03 18:34:48 +02:00
|
|
|
|
set errmsg "$command (the program exited)"
|
1999-04-16 03:35:26 +02:00
|
|
|
|
}
|
|
|
|
|
fail "$errmsg"
|
2003-01-23 02:35:21 +01:00
|
|
|
|
set result -1
|
2002-05-07 04:22:08 +02:00
|
|
|
|
}
|
2019-07-29 11:24:04 +02:00
|
|
|
|
-re "$inferior_exited_re normally.*$prompt_regexp" {
|
2002-05-07 04:22:08 +02:00
|
|
|
|
if ![string match "" $message] then {
|
2003-04-03 18:34:48 +02:00
|
|
|
|
set errmsg "$message (the program exited)"
|
2002-05-07 04:22:08 +02:00
|
|
|
|
} else {
|
2003-04-03 18:34:48 +02:00
|
|
|
|
set errmsg "$command (the program exited)"
|
2002-05-07 04:22:08 +02:00
|
|
|
|
}
|
|
|
|
|
fail "$errmsg"
|
2003-01-23 02:35:21 +01:00
|
|
|
|
set result -1
|
1999-04-16 03:35:26 +02:00
|
|
|
|
}
|
2019-07-29 11:24:04 +02:00
|
|
|
|
-re "The program is not being run.*$prompt_regexp" {
|
1999-04-16 03:35:26 +02:00
|
|
|
|
if ![string match "" $message] then {
|
2003-04-03 18:34:48 +02:00
|
|
|
|
set errmsg "$message (the program is no longer running)"
|
1999-04-16 03:35:26 +02:00
|
|
|
|
} else {
|
2003-04-03 18:34:48 +02:00
|
|
|
|
set errmsg "$command (the program is no longer running)"
|
1999-04-16 03:35:26 +02:00
|
|
|
|
}
|
|
|
|
|
fail "$errmsg"
|
2003-01-23 02:35:21 +01:00
|
|
|
|
set result -1
|
1999-04-16 03:35:26 +02:00
|
|
|
|
}
|
2019-07-29 11:24:04 +02:00
|
|
|
|
-re "\r\n$prompt_regexp" {
|
1999-04-16 03:35:26 +02:00
|
|
|
|
if ![string match "" $message] then {
|
|
|
|
|
fail "$message"
|
|
|
|
|
}
|
|
|
|
|
set result 1
|
|
|
|
|
}
|
Fix paginate-*.exp races
Jan pointed out in
<https://sourceware.org/ml/gdb-patches/2014-07/msg00553.html> that
these testcases have racy results:
gdb.base/double-prompt-target-event-error.exp
gdb.base/paginate-after-ctrl-c-running.exp
gdb.base/paginate-bg-execution.exp
gdb.base/paginate-execution-startup.exp
gdb.base/paginate-inferior-exit.exp
This is easily reproducible with "read1" from:
[reproducer for races of expect incomplete reads]
http://sourceware.org/bugzilla/show_bug.cgi?id=12649
The '-notransfer -re "<return>" { exp_continue }' trick in the current
tests doesn't actually work.
The issue that led to the -notransfer trick was that
"---Type <return> to continue, or q <return> to quit---"
has two "<return>"s. If one wants gdb_test_multiple to not hit the
built-in "<return>" match that results in FAIL, one has to expect the
pagination prompt in chunks, first up to the first "<return>", then
again, up to the second. Something around these lines:
gdb_test_multiple "" $test {
-re "<return>" {
exp_continue
}
-re "to quit ---" {
pass $test
}
}
The intent was for -notransfer+exp_continue to make expect fetch more
input, and rerun the matches against the now potentially fuller
buffer, and then eventually the -re that includes the full pagination
prompt regex would match instead (because it's listed higher up, it
would match first). But, once that "<return>" -notransfer -re
matches, it keeps re-matching forever. It seems like with
exp_continue, expect immediately retries matching, instead of first
reading in more data into the buffer, if available.
Fix this like I should have done in the first place. There's actually
no good reason for gdb_test_multiple to only match "<return>". We can
make gdb_test_multiple expect the whole pagination prompt text
instead, which is store in the 'pagination_prompt' global (similar to
'gdb_prompt'). Then a gdb_test_multiple caller that doesn't want the
default match to trigger, because it wants to see one pagination
prompt, does simply:
gdb_test_multiple "" $test {
-re "$pagination_prompt$" {
pass $test
}
}
which is just like when we don't want the default $gdb_prompt match
within gdb_test_multiple to trigger, like:
gdb_test_multiple "" $test {
-re "$gdb_prompt $" {
pass $test
}
}
Tested on x86_64 Fedora 20. In addition, I've let the racy tests run
all in parallel in a loop for 30 minutes, and they never failed.
gdb/testsuite/
2014-07-25 Pedro Alves <palves@redhat.com>
* gdb.base/double-prompt-target-event-error.exp
(cancel_pagination_in_target_event): Remove '-notransfer <return>'
match.
(cancel_pagination_in_target_event): Rework double prompt
detection.
* gdb.base/paginate-after-ctrl-c-running.exp
(test_ctrlc_while_target_running_paginates): Remove '-notransfer
<return>' match.
* gdb.base/paginate-bg-execution.exp
(test_bg_execution_pagination_return)
(test_bg_execution_pagination_cancel): Remove '-notransfer
<return>' matches.
* gdb.base/paginate-execution-startup.exp
(test_fg_execution_pagination_return)
(test_fg_execution_pagination_cancel): Remove '-notransfer
<return>' matches.
* gdb.base/paginate-inferior-exit.exp
(test_paginate_inferior_exited): Remove '-notransfer <return>'
match.
* lib/gdb-utils.exp (string_to_regexp): Move here from lib/gdb.exp.
* lib/gdb.exp (pagination_prompt): Run text through
string_to_regexp.
(gdb_test_multiple): Match $pagination_prompt instead of
"<return>".
(string_to_regexp): Move to lib/gdb-utils.exp.
2014-07-25 11:07:38 +02:00
|
|
|
|
-re "$pagination_prompt" {
|
1999-04-16 03:35:26 +02:00
|
|
|
|
send_gdb "\n"
|
|
|
|
|
perror "Window too small."
|
2012-05-09 16:29:49 +02:00
|
|
|
|
fail "$message"
|
2003-01-23 02:35:21 +01:00
|
|
|
|
set result -1
|
1999-04-16 03:35:26 +02:00
|
|
|
|
}
|
2009-11-12 20:54:39 +01:00
|
|
|
|
-re "\\((y or n|y or \\\[n\\\]|\\\[y\\\] or n)\\) " {
|
2019-05-17 17:30:09 +02:00
|
|
|
|
send_gdb "n\n" answer
|
2019-07-29 11:24:04 +02:00
|
|
|
|
gdb_expect -re "$prompt_regexp"
|
2009-11-12 20:54:39 +01:00
|
|
|
|
fail "$message (got interactive prompt)"
|
|
|
|
|
set result -1
|
|
|
|
|
}
|
|
|
|
|
-re "\\\[0\\\] cancel\r\n\\\[1\\\] all.*\r\n> $" {
|
|
|
|
|
send_gdb "0\n"
|
2019-07-29 11:24:04 +02:00
|
|
|
|
gdb_expect -re "$prompt_regexp"
|
2009-11-12 20:54:39 +01:00
|
|
|
|
fail "$message (got breakpoint menu)"
|
2003-01-23 02:35:21 +01:00
|
|
|
|
set result -1
|
1999-04-16 03:35:26 +02:00
|
|
|
|
}
|
2015-04-23 16:48:26 +02:00
|
|
|
|
|
2018-10-24 12:54:33 +02:00
|
|
|
|
-i $gdb_spawn_id
|
|
|
|
|
eof {
|
|
|
|
|
perror "GDB process no longer exists"
|
|
|
|
|
set wait_status [wait -i $gdb_spawn_id]
|
|
|
|
|
verbose -log "GDB process exited with wait status $wait_status"
|
|
|
|
|
if { $message != "" } {
|
|
|
|
|
fail "$message"
|
|
|
|
|
}
|
|
|
|
|
return -1
|
|
|
|
|
}
|
Fix testsuite hangs when gdb_test_multiple body errors out
This commit fixes a regression in the testsuite itself, triggered by
errors being raised from within gdb_test_multiple, originally reported
by Pedro Franco de Carvalho's at
<https://sourceware.org/ml/gdb-patches/2019-03/msg00160.html>. Parts
of the commit message are based on his report.
This started happening due to a commit that was introduced recently,
and it can cause the testsuite to hang.
The commit that triggers this is:
fe1a5cad302b5535030cdf62895e79512713d738
[gdb/testsuite] Log wait status on process no longer exists error
That commit introduces a new "eof" block in gdb_test_multiple. That
is not incorrect itself, but dejagnu's remote_expect is picking that
block as the "default" action when an error is raised from within the
commands inside a call to gdb_test_multiple:
# remote_expect works basically the same as standard expect, but it
# also takes care of getting the file descriptor from the specified
# host and also calling the timeout/eof/default section if there is an
# error on the expect call.
#
proc remote_expect { board timeout args } {
I find that "feature" surprising, and I don't really know why it
exists, but this means that the eof section that remote_expect picks
as the error block can be executed even when there was no actual eof
and the GDB process is still running, so the wait introduced in the
commit that tries to get the exit status of GDB hangs forever, while
GDB itself waits for input.
This only happens when there are internal testsuite errors (not
testcase failures). This can be reproduced easily with a testcase
such as:
gdb_start
gdb_test_multiple "show version" "show version" {
-re ".*" {
error "forced error"
}
}
I think that working around this in GDB is useful so that the
testsuite doesn't hang in these cases.
Adding an empty "default" block at the end of the expect body in
gdb_test_multiple doesn't work, because dejagnu gives preference to
"eof" blocks:
if { $x eq "eof" } {
set save_next 1
} elseif { $x eq "default" || $x eq "timeout" } {
if { $error_sect eq "" } {
set save_next 1
}
}
And we do have "eof" blocks. So we need to make sure that the last
"eof" block is safe to use as the default error block. It's also
pedantically incorrect to print
"ERROR: Process no longer exists"
which is what we'd get if the last eof block we have was selected
(more below on this).
So this commit solves this by appending an "eof" with an empty
spawn_id list, so that it won't ever match.
Now, why is the first "eof" block selected today as the error block,
instead of the last one?
The reason is that remote_expect, while parsing the body to select the
default block to execute after an error, is affected by the comments
in the body (since they are also parsed).
If this comment in gdb_test_multiple
# patterns below apply to any spawn id specified.
is changed to
# The patterns below apply to any spawn id specified.
then the second eof block is selected and there is no hang.
Any comment at that same place with an even number of tokens also
works.
This is IMO a coincidence caused by how comments work in TCL.
Comments should only appear in places where a command can appear. And
here, remote_expect is parsing a list of options, not commands, so
it's not unreasonable to not parse comments, similarly to how this:
set a_list {
an_element
# another_element
}
results in a list with three elements, not one element.
The fact that comments with an even number of tokens work is just a
coincidence of how remote_expect's little state machine is
implemented.
I thought we could solve this by stripping out comment lines in
gdb_expect, but I didn't find an easy way to do that. Particularly, a
couple naive approaches I tried run into complications. For example,
we have gdb_test calls with regular expressions that include sequences
like "\r\n#", and by the time we get to gdb_expect, the \r\n have
already been expanded to a real newline, so just splitting the whole
body at newline boundaries, looking for lines that start with #
results in incorrectly stripping out half of the gdb_text regexp. I
think it's better (at least in this commit), to move the comments out
of the list, because it's much simpler and risk free.
gdb/testsuite/ChangeLog:
2019-03-25 Pedro Alves <palves@redhat.com>
* lib/gdb.exp (gdb_test_multiple): Split appends to $code and
move comments outside list. Append '-i "" eof' section.
2019-03-25 14:26:23 +01:00
|
|
|
|
}
|
2018-10-24 12:54:33 +02:00
|
|
|
|
|
Fix testsuite hangs when gdb_test_multiple body errors out
This commit fixes a regression in the testsuite itself, triggered by
errors being raised from within gdb_test_multiple, originally reported
by Pedro Franco de Carvalho's at
<https://sourceware.org/ml/gdb-patches/2019-03/msg00160.html>. Parts
of the commit message are based on his report.
This started happening due to a commit that was introduced recently,
and it can cause the testsuite to hang.
The commit that triggers this is:
fe1a5cad302b5535030cdf62895e79512713d738
[gdb/testsuite] Log wait status on process no longer exists error
That commit introduces a new "eof" block in gdb_test_multiple. That
is not incorrect itself, but dejagnu's remote_expect is picking that
block as the "default" action when an error is raised from within the
commands inside a call to gdb_test_multiple:
# remote_expect works basically the same as standard expect, but it
# also takes care of getting the file descriptor from the specified
# host and also calling the timeout/eof/default section if there is an
# error on the expect call.
#
proc remote_expect { board timeout args } {
I find that "feature" surprising, and I don't really know why it
exists, but this means that the eof section that remote_expect picks
as the error block can be executed even when there was no actual eof
and the GDB process is still running, so the wait introduced in the
commit that tries to get the exit status of GDB hangs forever, while
GDB itself waits for input.
This only happens when there are internal testsuite errors (not
testcase failures). This can be reproduced easily with a testcase
such as:
gdb_start
gdb_test_multiple "show version" "show version" {
-re ".*" {
error "forced error"
}
}
I think that working around this in GDB is useful so that the
testsuite doesn't hang in these cases.
Adding an empty "default" block at the end of the expect body in
gdb_test_multiple doesn't work, because dejagnu gives preference to
"eof" blocks:
if { $x eq "eof" } {
set save_next 1
} elseif { $x eq "default" || $x eq "timeout" } {
if { $error_sect eq "" } {
set save_next 1
}
}
And we do have "eof" blocks. So we need to make sure that the last
"eof" block is safe to use as the default error block. It's also
pedantically incorrect to print
"ERROR: Process no longer exists"
which is what we'd get if the last eof block we have was selected
(more below on this).
So this commit solves this by appending an "eof" with an empty
spawn_id list, so that it won't ever match.
Now, why is the first "eof" block selected today as the error block,
instead of the last one?
The reason is that remote_expect, while parsing the body to select the
default block to execute after an error, is affected by the comments
in the body (since they are also parsed).
If this comment in gdb_test_multiple
# patterns below apply to any spawn id specified.
is changed to
# The patterns below apply to any spawn id specified.
then the second eof block is selected and there is no hang.
Any comment at that same place with an even number of tokens also
works.
This is IMO a coincidence caused by how comments work in TCL.
Comments should only appear in places where a command can appear. And
here, remote_expect is parsing a list of options, not commands, so
it's not unreasonable to not parse comments, similarly to how this:
set a_list {
an_element
# another_element
}
results in a list with three elements, not one element.
The fact that comments with an even number of tokens work is just a
coincidence of how remote_expect's little state machine is
implemented.
I thought we could solve this by stripping out comment lines in
gdb_expect, but I didn't find an easy way to do that. Particularly, a
couple naive approaches I tried run into complications. For example,
we have gdb_test calls with regular expressions that include sequences
like "\r\n#", and by the time we get to gdb_expect, the \r\n have
already been expanded to a real newline, so just splitting the whole
body at newline boundaries, looking for lines that start with #
results in incorrectly stripping out half of the gdb_text regexp. I
think it's better (at least in this commit), to move the comments out
of the list, because it's much simpler and risk free.
gdb/testsuite/ChangeLog:
2019-03-25 Pedro Alves <palves@redhat.com>
* lib/gdb.exp (gdb_test_multiple): Split appends to $code and
move comments outside list. Append '-i "" eof' section.
2019-03-25 14:26:23 +01:00
|
|
|
|
# Now patterns that apply to any spawn id specified.
|
|
|
|
|
append code {
|
2015-04-23 16:48:26 +02:00
|
|
|
|
-i $any_spawn_id
|
2012-05-09 16:29:49 +02:00
|
|
|
|
eof {
|
|
|
|
|
perror "Process no longer exists"
|
|
|
|
|
if { $message != "" } {
|
|
|
|
|
fail "$message"
|
|
|
|
|
}
|
|
|
|
|
return -1
|
1999-04-16 03:35:26 +02:00
|
|
|
|
}
|
2012-05-09 16:29:49 +02:00
|
|
|
|
full_buffer {
|
1999-04-16 03:35:26 +02:00
|
|
|
|
perror "internal buffer is full."
|
2012-05-09 16:29:49 +02:00
|
|
|
|
fail "$message"
|
2003-01-23 02:35:21 +01:00
|
|
|
|
set result -1
|
1999-04-16 03:35:26 +02:00
|
|
|
|
}
|
|
|
|
|
timeout {
|
|
|
|
|
if ![string match "" $message] then {
|
|
|
|
|
fail "$message (timeout)"
|
|
|
|
|
}
|
|
|
|
|
set result 1
|
|
|
|
|
}
|
|
|
|
|
}
|
2003-01-23 02:35:21 +01:00
|
|
|
|
|
Fix testsuite hangs when gdb_test_multiple body errors out
This commit fixes a regression in the testsuite itself, triggered by
errors being raised from within gdb_test_multiple, originally reported
by Pedro Franco de Carvalho's at
<https://sourceware.org/ml/gdb-patches/2019-03/msg00160.html>. Parts
of the commit message are based on his report.
This started happening due to a commit that was introduced recently,
and it can cause the testsuite to hang.
The commit that triggers this is:
fe1a5cad302b5535030cdf62895e79512713d738
[gdb/testsuite] Log wait status on process no longer exists error
That commit introduces a new "eof" block in gdb_test_multiple. That
is not incorrect itself, but dejagnu's remote_expect is picking that
block as the "default" action when an error is raised from within the
commands inside a call to gdb_test_multiple:
# remote_expect works basically the same as standard expect, but it
# also takes care of getting the file descriptor from the specified
# host and also calling the timeout/eof/default section if there is an
# error on the expect call.
#
proc remote_expect { board timeout args } {
I find that "feature" surprising, and I don't really know why it
exists, but this means that the eof section that remote_expect picks
as the error block can be executed even when there was no actual eof
and the GDB process is still running, so the wait introduced in the
commit that tries to get the exit status of GDB hangs forever, while
GDB itself waits for input.
This only happens when there are internal testsuite errors (not
testcase failures). This can be reproduced easily with a testcase
such as:
gdb_start
gdb_test_multiple "show version" "show version" {
-re ".*" {
error "forced error"
}
}
I think that working around this in GDB is useful so that the
testsuite doesn't hang in these cases.
Adding an empty "default" block at the end of the expect body in
gdb_test_multiple doesn't work, because dejagnu gives preference to
"eof" blocks:
if { $x eq "eof" } {
set save_next 1
} elseif { $x eq "default" || $x eq "timeout" } {
if { $error_sect eq "" } {
set save_next 1
}
}
And we do have "eof" blocks. So we need to make sure that the last
"eof" block is safe to use as the default error block. It's also
pedantically incorrect to print
"ERROR: Process no longer exists"
which is what we'd get if the last eof block we have was selected
(more below on this).
So this commit solves this by appending an "eof" with an empty
spawn_id list, so that it won't ever match.
Now, why is the first "eof" block selected today as the error block,
instead of the last one?
The reason is that remote_expect, while parsing the body to select the
default block to execute after an error, is affected by the comments
in the body (since they are also parsed).
If this comment in gdb_test_multiple
# patterns below apply to any spawn id specified.
is changed to
# The patterns below apply to any spawn id specified.
then the second eof block is selected and there is no hang.
Any comment at that same place with an even number of tokens also
works.
This is IMO a coincidence caused by how comments work in TCL.
Comments should only appear in places where a command can appear. And
here, remote_expect is parsing a list of options, not commands, so
it's not unreasonable to not parse comments, similarly to how this:
set a_list {
an_element
# another_element
}
results in a list with three elements, not one element.
The fact that comments with an even number of tokens work is just a
coincidence of how remote_expect's little state machine is
implemented.
I thought we could solve this by stripping out comment lines in
gdb_expect, but I didn't find an easy way to do that. Particularly, a
couple naive approaches I tried run into complications. For example,
we have gdb_test calls with regular expressions that include sequences
like "\r\n#", and by the time we get to gdb_expect, the \r\n have
already been expanded to a real newline, so just splitting the whole
body at newline boundaries, looking for lines that start with #
results in incorrectly stripping out half of the gdb_text regexp. I
think it's better (at least in this commit), to move the comments out
of the list, because it's much simpler and risk free.
gdb/testsuite/ChangeLog:
2019-03-25 Pedro Alves <palves@redhat.com>
* lib/gdb.exp (gdb_test_multiple): Split appends to $code and
move comments outside list. Append '-i "" eof' section.
2019-03-25 14:26:23 +01:00
|
|
|
|
# remote_expect calls the eof section if there is an error on the
|
|
|
|
|
# expect call. We already have eof sections above, and we don't
|
|
|
|
|
# want them to get called in that situation. Since the last eof
|
|
|
|
|
# section becomes the error section, here we define another eof
|
|
|
|
|
# section, but with an empty spawn_id list, so that it won't ever
|
|
|
|
|
# match.
|
|
|
|
|
append code {
|
|
|
|
|
-i "" eof {
|
|
|
|
|
# This comment is here because the eof section must not be
|
|
|
|
|
# the empty string, otherwise remote_expect won't realize
|
|
|
|
|
# it exists.
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
gdb/testsuite: Add gdb_test_name variable
This commit adds a new feature to gdb_test_multiple, an automatically
created variable gdb_test_name. The idea is to make it easier to
write tests using gdb_test_multiple, and avoid places where the string
passed to pass/fail within an action element is different to the
message passed to the top level gdb_test_multiple.
As an example, previously you might write this:
gdb_test_multiple "print foo" "test foo" {
-re "expected output 1" {
pass "test foo"
}
-re "expected output 2" {
fail "test foo"
}
}
This is OK, but it's easy for the pass/fail strings to come out of
sync, or contain a typo. A better version would look like this:
set testname "test foo"
gdb_test_multiple "print foo" $testname {
-re "expected output 1" {
pass $testname
}
-re "expected output 2" {
fail $testname
}
}
This is better, but its a bit of a drag having to create a new
variable each time.
After this patch you can now write this:
gdb_test_multiple "print foo" "test foo" {
-re "expected output 1" {
pass $gdb_test_name
}
-re "expected output 2" {
fail $gdb_test_name
}
}
The $gdb_test_name is setup by gdb_test_multiple, and cleaned up once
the test has completed. Nested calls to gdb_test_multiple are
supported, though $gdb_test_name will only ever contain the inner most
test message (which is probably what you want).
My only regret is that '$gdb_test_name' is so long, but I wanted
something that was unlikely to clash with any existing variable name,
or anything that a user is likely to want to use.
I've tested this on x86-64/GNU Linux and see no test regressions, and
I've converted one test script over to make use of this new technique
both as an example, and to ensure that the new facility doesn't get
broken. I have no plans to convert all tests over to this technique,
but I hope others will find this useful for writing tests in the
future.
gdb/testsuite/ChangeLog:
* lib/gdb.exp (gdb_test_multiple): Add gdb_test_name mechanism.
* gdb.base/annota1.exp: Update to use gdb_test_name.
2019-10-01 16:29:20 +02:00
|
|
|
|
# Create gdb_test_name in the parent scope. If this variable
|
|
|
|
|
# already exists, which it might if we have nested calls to
|
|
|
|
|
# gdb_test_multiple, then preserve the old value, otherwise,
|
|
|
|
|
# create a new variable in the parent scope.
|
|
|
|
|
upvar gdb_test_name gdb_test_name
|
|
|
|
|
if { [info exists gdb_test_name] } {
|
|
|
|
|
set gdb_test_name_old "$gdb_test_name"
|
|
|
|
|
}
|
|
|
|
|
set gdb_test_name "$message"
|
|
|
|
|
|
2003-01-23 02:35:21 +01:00
|
|
|
|
set result 0
|
GDB/testsuite: Avoid timeout lowering
The recent change to introduce `gdb_reverse_timeout' turned out
ineffective for board setups that set the `gdb,timeout' target variable.
A lower `gdb,timeout' setting takes precedence and defeats the effect of
`gdb_reverse_timeout'. This is because the global timeout is overridden
in gdb_test_multiple and then again in gdb_expect.
Three timeout variables are taken into account in these two places, in
this precedence:
1. The `gdb,timeout' target variable.
2. The caller's local `timeout' variable (upvar timeout)
3. The global `timeout' variable.
This precedence is obeyed by gdb_test_multiple strictly. OTOH
gdb_expect will select the higher of the two formers and will only take
the latter into account if none of the formers is present. However the
two timeout selections are conceptually the same and gdb_test_multiple
does its only for the purpose of passing it down to gdb_expect.
Therefore I decided there is no point to keep carrying on this
duplication and removed the sequence from gdb_test_multiple, however
retaining the `upvar timeout' variable definition. This way gdb_expect
will still access gdb_test_multiple's caller `timeout' variable (if any)
via its own `upvar timeout' reference.
Now as to the sequence in gdb_expect. In addition to the three
variables described above it also takes a timeout argument into account,
as the fourth value to choose from. It is currently used if it is
higher than the timeout selected from the variables as described above.
With the timeout selection code from gdb_test_multiple gone, gone is
also the most prominent use of this timeout argument, it's now used in
a couple of places only, mostly within this test framework library code
itself for preparatory commands or suchlike. With this being the case
this timeout selection code can be simplified as follows:
1. Among the three timeout variables, the highest is always chosen.
This is so that a test case doesn't inadvertently lower a high value
timeout needed by slow target boards. This is what all test cases
use.
2. Any timeout argument takes precedence. This is for special cases
such as within the framework library code, e.g. it doesn't make sense
to send `set height 0' with a timeout of 7200 seconds. This is a
local command that does not interact with the target and setting a
high timeout here only risks a test suite run taking ages if it goes
astray for some reason.
3. The fallback timeout of 60s remains.
* lib/gdb.exp (gdb_test_multiple): Remove code to select the
timeout, don't pass one down to gdb_expect.
(gdb_expect): Rework timeout selection.
2014-09-09 17:39:16 +02:00
|
|
|
|
set code [catch {gdb_expect $code} string]
|
gdb/testsuite: Add gdb_test_name variable
This commit adds a new feature to gdb_test_multiple, an automatically
created variable gdb_test_name. The idea is to make it easier to
write tests using gdb_test_multiple, and avoid places where the string
passed to pass/fail within an action element is different to the
message passed to the top level gdb_test_multiple.
As an example, previously you might write this:
gdb_test_multiple "print foo" "test foo" {
-re "expected output 1" {
pass "test foo"
}
-re "expected output 2" {
fail "test foo"
}
}
This is OK, but it's easy for the pass/fail strings to come out of
sync, or contain a typo. A better version would look like this:
set testname "test foo"
gdb_test_multiple "print foo" $testname {
-re "expected output 1" {
pass $testname
}
-re "expected output 2" {
fail $testname
}
}
This is better, but its a bit of a drag having to create a new
variable each time.
After this patch you can now write this:
gdb_test_multiple "print foo" "test foo" {
-re "expected output 1" {
pass $gdb_test_name
}
-re "expected output 2" {
fail $gdb_test_name
}
}
The $gdb_test_name is setup by gdb_test_multiple, and cleaned up once
the test has completed. Nested calls to gdb_test_multiple are
supported, though $gdb_test_name will only ever contain the inner most
test message (which is probably what you want).
My only regret is that '$gdb_test_name' is so long, but I wanted
something that was unlikely to clash with any existing variable name,
or anything that a user is likely to want to use.
I've tested this on x86-64/GNU Linux and see no test regressions, and
I've converted one test script over to make use of this new technique
both as an example, and to ensure that the new facility doesn't get
broken. I have no plans to convert all tests over to this technique,
but I hope others will find this useful for writing tests in the
future.
gdb/testsuite/ChangeLog:
* lib/gdb.exp (gdb_test_multiple): Add gdb_test_name mechanism.
* gdb.base/annota1.exp: Update to use gdb_test_name.
2019-10-01 16:29:20 +02:00
|
|
|
|
|
|
|
|
|
# Clean up the gdb_test_name variable. If we had a
|
|
|
|
|
# previous value then restore it, otherwise, delete the variable
|
|
|
|
|
# from the parent scope.
|
|
|
|
|
if { [info exists gdb_test_name_old] } {
|
|
|
|
|
set gdb_test_name "$gdb_test_name_old"
|
|
|
|
|
} else {
|
|
|
|
|
unset gdb_test_name
|
|
|
|
|
}
|
|
|
|
|
|
2004-08-09 15:16:16 +02:00
|
|
|
|
if {$code == 1} {
|
2013-06-07 19:31:09 +02:00
|
|
|
|
global errorInfo errorCode
|
2004-08-09 15:16:16 +02:00
|
|
|
|
return -code error -errorinfo $errorInfo -errorcode $errorCode $string
|
2011-12-03 00:58:01 +01:00
|
|
|
|
} elseif {$code > 1} {
|
2004-08-09 15:16:16 +02:00
|
|
|
|
return -code $code $string
|
|
|
|
|
}
|
1999-04-16 03:35:26 +02:00
|
|
|
|
return $result
|
|
|
|
|
}
|
2003-01-23 02:35:21 +01:00
|
|
|
|
|
|
|
|
|
# gdb_test COMMAND PATTERN MESSAGE QUESTION RESPONSE
|
|
|
|
|
# Send a command to gdb; test the result.
|
|
|
|
|
#
|
|
|
|
|
# COMMAND is the command to execute, send to GDB with send_gdb. If
|
|
|
|
|
# this is the null string no command is sent.
|
|
|
|
|
# PATTERN is the pattern to match for a PASS, and must NOT include
|
2015-12-25 20:36:52 +01:00
|
|
|
|
# the \r\n sequence immediately before the gdb prompt. This argument
|
|
|
|
|
# may be omitted to just match the prompt, ignoring whatever output
|
|
|
|
|
# precedes it.
|
2003-01-23 02:35:21 +01:00
|
|
|
|
# MESSAGE is an optional message to be printed. If this is
|
|
|
|
|
# omitted, then the pass/fail messages use the command string as the
|
|
|
|
|
# message. (If this is the empty string, then sometimes we don't
|
|
|
|
|
# call pass or fail at all; I don't understand this at all.)
|
|
|
|
|
# QUESTION is a question GDB may ask in response to COMMAND, like
|
|
|
|
|
# "are you sure?"
|
|
|
|
|
# RESPONSE is the response to send if QUESTION appears.
|
|
|
|
|
#
|
|
|
|
|
# Returns:
|
|
|
|
|
# 1 if the test failed,
|
|
|
|
|
# 0 if the test passes,
|
|
|
|
|
# -1 if there was an internal error.
|
|
|
|
|
#
|
|
|
|
|
proc gdb_test { args } {
|
|
|
|
|
global gdb_prompt
|
|
|
|
|
upvar timeout timeout
|
|
|
|
|
|
|
|
|
|
if [llength $args]>2 then {
|
|
|
|
|
set message [lindex $args 2]
|
|
|
|
|
} else {
|
|
|
|
|
set message [lindex $args 0]
|
|
|
|
|
}
|
|
|
|
|
set command [lindex $args 0]
|
|
|
|
|
set pattern [lindex $args 1]
|
|
|
|
|
|
2019-09-19 19:54:15 +02:00
|
|
|
|
set user_code {}
|
|
|
|
|
lappend user_code {
|
Use noncapturing subpattern/parens in gdb_test implementation
This is the portion of gdb_test which performs the match against
the RE (regular expression) passed to it:
return [gdb_test_multiple $command $message {
-re "\[\r\n\]*($pattern)\[\r\n\]+$gdb_prompt $" {
if ![string match "" $message] then {
pass "$message"
}
}
In a test that I've been working on recently, I wanted to use
a backreference - that's the \1 in the the RE below:
gdb_test "info threads" \
{.*[\r\n]+\* +([0-9]+) +Thread[^\r\n]* do_something \(n=\1\) at.*}
Put into English, I wanted to make sure that the value of n passed to
do_something() is the same as the thread number shown in the "info
threads" Id column. (I've structured the test case so that this
*should* be the case.)
It didn't work though. It turned out that ($pattern) in the RE
noted above is capturing the attempted backreference. So, in this
case, the backreference does not refer to ([0-9]+) as intended, but
instead refers to ($pattern). This is wrong because it's not what I
intended, but is also wrong because, if allowed, it could only match a
string of infinite length.
This problem can be fixed by using parens for a "noncapturing
subpattern". The way that this is done, syntactically, is to use
(?:$pattern) instead of ($pattern).
My research shows that this feature has been present since tcl8.1 which
was released in 1999.
The current tcl version is 8.6 - at least that's what I have on my
machine. It appears to me that mingw uses some subversion of tcl8.4
which will also have this feature (since 8.4 > 8.1).
So it seems to me that any platform upon which we might wish to test
GDB will have a version of tcl which has this feature. That being the
case, my hope is that there won't be any objections to its use.
When I looked at the implementation of gdb_test, I wondered whether
the parens were needed at all. I've concluded that they are. In the
event that $pattern is an RE which uses alternation at the top level,
e.g. a|b, we need to make $pattern a subpattern (via parens) to limit
the extend of the alternation. I.e, we don't want the alternation to
extend to the other portions of the RE which gdb_test uses to match
potential blank lines at the beginning of the pattern or the gdb
prompt at the end.
gdb/testsuite/ChangeLog:
* gdb.exp (gdb_test): Using noncapturing parens for the $pattern
subpattern.
2017-06-03 02:58:12 +02:00
|
|
|
|
-re "\[\r\n\]*(?:$pattern)\[\r\n\]+$gdb_prompt $" {
|
2003-01-23 02:35:21 +01:00
|
|
|
|
if ![string match "" $message] then {
|
|
|
|
|
pass "$message"
|
|
|
|
|
}
|
|
|
|
|
}
|
2019-09-19 19:54:15 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if { [llength $args] == 5 } {
|
|
|
|
|
set question_string [lindex $args 3]
|
|
|
|
|
set response_string [lindex $args 4]
|
|
|
|
|
lappend user_code {
|
|
|
|
|
-re "(${question_string})$" {
|
|
|
|
|
send_gdb "$response_string\n"
|
|
|
|
|
exp_continue
|
|
|
|
|
}
|
2003-01-23 02:35:21 +01:00
|
|
|
|
}
|
2019-09-19 19:54:15 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
set user_code [join $user_code]
|
|
|
|
|
return [gdb_test_multiple $command $message $user_code]
|
2003-01-23 02:35:21 +01:00
|
|
|
|
}
|
2010-05-20 21:18:58 +02:00
|
|
|
|
|
2019-08-05 12:51:58 +02:00
|
|
|
|
# Return 1 if version MAJOR.MINOR is at least AT_LEAST_MAJOR.AT_LEAST_MINOR.
|
|
|
|
|
proc version_at_least { major minor at_least_major at_least_minor} {
|
|
|
|
|
if { $major > $at_least_major } {
|
2019-08-01 10:48:11 +02:00
|
|
|
|
return 1
|
2019-08-05 12:51:58 +02:00
|
|
|
|
} elseif { $major == $at_least_major \
|
|
|
|
|
&& $minor >= $at_least_minor } {
|
2019-08-01 10:48:11 +02:00
|
|
|
|
return 1
|
|
|
|
|
} else {
|
|
|
|
|
return 0
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2019-08-05 12:51:58 +02:00
|
|
|
|
# Return 1 if tcl version used is at least MAJOR.MINOR
|
|
|
|
|
proc tcl_version_at_least { major minor } {
|
|
|
|
|
global tcl_version
|
|
|
|
|
regexp {^([0-9]+)\.([0-9]+)$} $tcl_version \
|
|
|
|
|
dummy tcl_version_major tcl_version_minor
|
|
|
|
|
return [version_at_least $tcl_version_major $tcl_version_minor \
|
|
|
|
|
$major $minor]
|
|
|
|
|
}
|
|
|
|
|
|
2019-08-01 10:48:11 +02:00
|
|
|
|
if { [tcl_version_at_least 8 5] == 0 } {
|
|
|
|
|
# lrepeat was added in tcl 8.5. Only add if missing.
|
|
|
|
|
proc lrepeat { n element } {
|
|
|
|
|
if { [string is integer -strict $n] == 0 } {
|
|
|
|
|
error "expected integer but got \"$n\""
|
|
|
|
|
}
|
|
|
|
|
if { $n < 0 } {
|
|
|
|
|
error "bad count \"$n\": must be integer >= 0"
|
|
|
|
|
}
|
|
|
|
|
set res [list]
|
|
|
|
|
for {set i 0} {$i < $n} {incr i} {
|
|
|
|
|
lappend res $element
|
|
|
|
|
}
|
|
|
|
|
return $res
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2010-05-20 21:18:58 +02:00
|
|
|
|
# gdb_test_no_output COMMAND MESSAGE
|
|
|
|
|
# Send a command to GDB and verify that this command generated no output.
|
|
|
|
|
#
|
|
|
|
|
# See gdb_test_multiple for a description of the COMMAND and MESSAGE
|
|
|
|
|
# parameters. If MESSAGE is ommitted, then COMMAND will be used as
|
2010-06-03 22:29:27 +02:00
|
|
|
|
# the message. (If MESSAGE is the empty string, then sometimes we do not
|
|
|
|
|
# call pass or fail at all; I don't understand this at all.)
|
2010-05-20 21:18:58 +02:00
|
|
|
|
|
|
|
|
|
proc gdb_test_no_output { args } {
|
|
|
|
|
global gdb_prompt
|
|
|
|
|
set command [lindex $args 0]
|
|
|
|
|
if [llength $args]>1 then {
|
|
|
|
|
set message [lindex $args 1]
|
|
|
|
|
} else {
|
|
|
|
|
set message $command
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
set command_regex [string_to_regexp $command]
|
|
|
|
|
gdb_test_multiple $command $message {
|
|
|
|
|
-re "^$command_regex\r\n$gdb_prompt $" {
|
2010-06-03 22:29:27 +02:00
|
|
|
|
if ![string match "" $message] then {
|
|
|
|
|
pass "$message"
|
|
|
|
|
}
|
2010-05-20 21:18:58 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2010-11-23 23:25:37 +01:00
|
|
|
|
# Send a command and then wait for a sequence of outputs.
|
|
|
|
|
# This is useful when the sequence is long and contains ".*", a single
|
|
|
|
|
# regexp to match the entire output can get a timeout much easier.
|
|
|
|
|
#
|
2017-11-16 12:57:01 +01:00
|
|
|
|
# COMMAND is the command to execute, send to GDB with send_gdb. If
|
|
|
|
|
# this is the null string no command is sent.
|
2010-11-23 23:25:37 +01:00
|
|
|
|
# TEST_NAME is passed to pass/fail. COMMAND is used if TEST_NAME is "".
|
|
|
|
|
# EXPECTED_OUTPUT_LIST is a list of regexps of expected output, which are
|
|
|
|
|
# processed in order, and all must be present in the output.
|
|
|
|
|
#
|
|
|
|
|
# It is unnecessary to specify ".*" at the beginning or end of any regexp,
|
|
|
|
|
# there is an implicit ".*" between each element of EXPECTED_OUTPUT_LIST.
|
|
|
|
|
# There is also an implicit ".*" between the last regexp and the gdb prompt.
|
|
|
|
|
#
|
|
|
|
|
# Like gdb_test and gdb_test_multiple, the output is expected to end with the
|
|
|
|
|
# gdb prompt, which must not be specified in EXPECTED_OUTPUT_LIST.
|
2010-11-30 18:41:14 +01:00
|
|
|
|
#
|
|
|
|
|
# Returns:
|
|
|
|
|
# 1 if the test failed,
|
|
|
|
|
# 0 if the test passes,
|
|
|
|
|
# -1 if there was an internal error.
|
2010-11-23 23:25:37 +01:00
|
|
|
|
|
|
|
|
|
proc gdb_test_sequence { command test_name expected_output_list } {
|
|
|
|
|
global gdb_prompt
|
|
|
|
|
if { $test_name == "" } {
|
|
|
|
|
set test_name $command
|
|
|
|
|
}
|
|
|
|
|
lappend expected_output_list ""; # implicit ".*" before gdb prompt
|
2017-11-16 12:57:01 +01:00
|
|
|
|
if { $command != "" } {
|
|
|
|
|
send_gdb "$command\n"
|
|
|
|
|
}
|
2010-11-30 18:41:14 +01:00
|
|
|
|
return [gdb_expect_list $test_name "$gdb_prompt $" $expected_output_list]
|
2010-11-23 23:25:37 +01:00
|
|
|
|
}
|
|
|
|
|
|
1999-04-16 03:35:26 +02:00
|
|
|
|
|
|
|
|
|
# Test that a command gives an error. For pass or fail, return
|
|
|
|
|
# a 1 to indicate that more tests can proceed. However a timeout
|
|
|
|
|
# is a serious error, generates a special fail message, and causes
|
|
|
|
|
# a 0 to be returned to indicate that more tests are likely to fail
|
|
|
|
|
# as well.
|
|
|
|
|
|
|
|
|
|
proc test_print_reject { args } {
|
|
|
|
|
global gdb_prompt
|
|
|
|
|
global verbose
|
|
|
|
|
|
|
|
|
|
if [llength $args]==2 then {
|
|
|
|
|
set expectthis [lindex $args 1]
|
|
|
|
|
} else {
|
|
|
|
|
set expectthis "should never match this bogus string"
|
|
|
|
|
}
|
|
|
|
|
set sendthis [lindex $args 0]
|
|
|
|
|
if $verbose>2 then {
|
|
|
|
|
send_user "Sending \"$sendthis\" to gdb\n"
|
|
|
|
|
send_user "Looking to match \"$expectthis\"\n"
|
|
|
|
|
}
|
|
|
|
|
send_gdb "$sendthis\n"
|
|
|
|
|
#FIXME: Should add timeout as parameter.
|
|
|
|
|
gdb_expect {
|
|
|
|
|
-re "A .* in expression.*\\.*$gdb_prompt $" {
|
|
|
|
|
pass "reject $sendthis"
|
|
|
|
|
return 1
|
|
|
|
|
}
|
|
|
|
|
-re "Invalid syntax in expression.*$gdb_prompt $" {
|
|
|
|
|
pass "reject $sendthis"
|
|
|
|
|
return 1
|
|
|
|
|
}
|
|
|
|
|
-re "Junk after end of expression.*$gdb_prompt $" {
|
|
|
|
|
pass "reject $sendthis"
|
|
|
|
|
return 1
|
|
|
|
|
}
|
|
|
|
|
-re "Invalid number.*$gdb_prompt $" {
|
|
|
|
|
pass "reject $sendthis"
|
|
|
|
|
return 1
|
|
|
|
|
}
|
|
|
|
|
-re "Invalid character constant.*$gdb_prompt $" {
|
|
|
|
|
pass "reject $sendthis"
|
|
|
|
|
return 1
|
|
|
|
|
}
|
|
|
|
|
-re "No symbol table is loaded.*$gdb_prompt $" {
|
|
|
|
|
pass "reject $sendthis"
|
|
|
|
|
return 1
|
|
|
|
|
}
|
|
|
|
|
-re "No symbol .* in current context.*$gdb_prompt $" {
|
|
|
|
|
pass "reject $sendthis"
|
|
|
|
|
return 1
|
|
|
|
|
}
|
2002-05-10 20:38:09 +02:00
|
|
|
|
-re "Unmatched single quote.*$gdb_prompt $" {
|
|
|
|
|
pass "reject $sendthis"
|
|
|
|
|
return 1
|
|
|
|
|
}
|
|
|
|
|
-re "A character constant must contain at least one character.*$gdb_prompt $" {
|
|
|
|
|
pass "reject $sendthis"
|
|
|
|
|
return 1
|
|
|
|
|
}
|
1999-04-16 03:35:26 +02:00
|
|
|
|
-re "$expectthis.*$gdb_prompt $" {
|
|
|
|
|
pass "reject $sendthis"
|
|
|
|
|
return 1
|
|
|
|
|
}
|
|
|
|
|
-re ".*$gdb_prompt $" {
|
|
|
|
|
fail "reject $sendthis"
|
|
|
|
|
return 1
|
|
|
|
|
}
|
|
|
|
|
default {
|
|
|
|
|
fail "reject $sendthis (eof or timeout)"
|
|
|
|
|
return 0
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Same as gdb_test, but the second parameter is not a regexp,
|
|
|
|
|
# but a string that must match exactly.
|
|
|
|
|
|
|
|
|
|
proc gdb_test_exact { args } {
|
|
|
|
|
upvar timeout timeout
|
|
|
|
|
|
|
|
|
|
set command [lindex $args 0]
|
|
|
|
|
|
|
|
|
|
# This applies a special meaning to a null string pattern. Without
|
|
|
|
|
# this, "$pattern\r\n$gdb_prompt $" will match anything, including error
|
|
|
|
|
# messages from commands that should have no output except a new
|
|
|
|
|
# prompt. With this, only results of a null string will match a null
|
|
|
|
|
# string pattern.
|
|
|
|
|
|
|
|
|
|
set pattern [lindex $args 1]
|
|
|
|
|
if [string match $pattern ""] {
|
|
|
|
|
set pattern [string_to_regexp [lindex $args 0]]
|
|
|
|
|
} else {
|
|
|
|
|
set pattern [string_to_regexp [lindex $args 1]]
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# It is most natural to write the pattern argument with only
|
|
|
|
|
# embedded \n's, especially if you are trying to avoid Tcl quoting
|
|
|
|
|
# problems. But gdb_expect really wants to see \r\n in patterns. So
|
|
|
|
|
# transform the pattern here. First transform \r\n back to \n, in
|
|
|
|
|
# case some users of gdb_test_exact already do the right thing.
|
|
|
|
|
regsub -all "\r\n" $pattern "\n" pattern
|
|
|
|
|
regsub -all "\n" $pattern "\r\n" pattern
|
|
|
|
|
if [llength $args]==3 then {
|
|
|
|
|
set message [lindex $args 2]
|
2019-10-31 23:03:25 +01:00
|
|
|
|
return [gdb_test $command $pattern $message]
|
1999-04-16 03:35:26 +02:00
|
|
|
|
}
|
|
|
|
|
|
2019-10-31 23:03:25 +01:00
|
|
|
|
return [gdb_test $command $pattern]
|
1999-04-16 03:35:26 +02:00
|
|
|
|
}
|
2010-07-07 20:49:51 +02:00
|
|
|
|
|
|
|
|
|
# Wrapper around gdb_test_multiple that looks for a list of expected
|
|
|
|
|
# output elements, but which can appear in any order.
|
|
|
|
|
# CMD is the gdb command.
|
|
|
|
|
# NAME is the name of the test.
|
|
|
|
|
# ELM_FIND_REGEXP specifies how to partition the output into elements to
|
|
|
|
|
# compare.
|
|
|
|
|
# ELM_EXTRACT_REGEXP specifies the part of ELM_FIND_REGEXP to compare.
|
|
|
|
|
# RESULT_MATCH_LIST is a list of exact matches for each expected element.
|
|
|
|
|
# All elements of RESULT_MATCH_LIST must appear for the test to pass.
|
|
|
|
|
#
|
|
|
|
|
# A typical use of ELM_FIND_REGEXP/ELM_EXTRACT_REGEXP is to extract one line
|
|
|
|
|
# of text per element and then strip trailing \r\n's.
|
|
|
|
|
# Example:
|
|
|
|
|
# gdb_test_list_exact "foo" "bar" \
|
2011-05-20 16:37:20 +02:00
|
|
|
|
# "\[^\r\n\]+\[\r\n\]+" \
|
|
|
|
|
# "\[^\r\n\]+" \
|
2010-07-07 20:49:51 +02:00
|
|
|
|
# { \
|
|
|
|
|
# {expected result 1} \
|
|
|
|
|
# {expected result 2} \
|
|
|
|
|
# }
|
|
|
|
|
|
|
|
|
|
proc gdb_test_list_exact { cmd name elm_find_regexp elm_extract_regexp result_match_list } {
|
|
|
|
|
global gdb_prompt
|
|
|
|
|
|
|
|
|
|
set matches [lsort $result_match_list]
|
|
|
|
|
set seen {}
|
|
|
|
|
gdb_test_multiple $cmd $name {
|
|
|
|
|
"$cmd\[\r\n\]" { exp_continue }
|
|
|
|
|
-re $elm_find_regexp {
|
|
|
|
|
set str $expect_out(0,string)
|
|
|
|
|
verbose -log "seen: $str" 3
|
|
|
|
|
regexp -- $elm_extract_regexp $str elm_seen
|
|
|
|
|
verbose -log "extracted: $elm_seen" 3
|
|
|
|
|
lappend seen $elm_seen
|
|
|
|
|
exp_continue
|
|
|
|
|
}
|
|
|
|
|
-re "$gdb_prompt $" {
|
|
|
|
|
set failed ""
|
|
|
|
|
foreach got [lsort $seen] have $matches {
|
|
|
|
|
if {![string equal $got $have]} {
|
|
|
|
|
set failed $have
|
|
|
|
|
break
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if {[string length $failed] != 0} {
|
|
|
|
|
fail "$name ($failed not found)"
|
|
|
|
|
} else {
|
|
|
|
|
pass $name
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2015-07-29 12:09:37 +02:00
|
|
|
|
|
|
|
|
|
# gdb_test_stdio COMMAND INFERIOR_PATTERN GDB_PATTERN MESSAGE
|
|
|
|
|
# Send a command to gdb; expect inferior and gdb output.
|
|
|
|
|
#
|
|
|
|
|
# See gdb_test_multiple for a description of the COMMAND and MESSAGE
|
|
|
|
|
# parameters.
|
|
|
|
|
#
|
|
|
|
|
# INFERIOR_PATTERN is the pattern to match against inferior output.
|
|
|
|
|
#
|
|
|
|
|
# GDB_PATTERN is the pattern to match against gdb output, and must NOT
|
|
|
|
|
# include the \r\n sequence immediately before the gdb prompt, nor the
|
|
|
|
|
# prompt. The default is empty.
|
|
|
|
|
#
|
|
|
|
|
# Both inferior and gdb patterns must match for a PASS.
|
|
|
|
|
#
|
|
|
|
|
# If MESSAGE is ommitted, then COMMAND will be used as the message.
|
|
|
|
|
#
|
|
|
|
|
# Returns:
|
|
|
|
|
# 1 if the test failed,
|
|
|
|
|
# 0 if the test passes,
|
|
|
|
|
# -1 if there was an internal error.
|
|
|
|
|
#
|
|
|
|
|
|
|
|
|
|
proc gdb_test_stdio {command inferior_pattern {gdb_pattern ""} {message ""}} {
|
|
|
|
|
global inferior_spawn_id gdb_spawn_id
|
|
|
|
|
global gdb_prompt
|
|
|
|
|
|
|
|
|
|
if {$message == ""} {
|
|
|
|
|
set message $command
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
set inferior_matched 0
|
|
|
|
|
set gdb_matched 0
|
|
|
|
|
|
|
|
|
|
# Use an indirect spawn id list, and remove the inferior spawn id
|
|
|
|
|
# from the expected output as soon as it matches, in case
|
|
|
|
|
# $inferior_pattern happens to be a prefix of the resulting full
|
|
|
|
|
# gdb pattern below (e.g., "\r\n").
|
|
|
|
|
global gdb_test_stdio_spawn_id_list
|
|
|
|
|
set gdb_test_stdio_spawn_id_list "$inferior_spawn_id"
|
|
|
|
|
|
|
|
|
|
# Note that if $inferior_spawn_id and $gdb_spawn_id are different,
|
|
|
|
|
# then we may see gdb's output arriving before the inferior's
|
|
|
|
|
# output.
|
|
|
|
|
set res [gdb_test_multiple $command $message {
|
|
|
|
|
-i gdb_test_stdio_spawn_id_list -re "$inferior_pattern" {
|
|
|
|
|
set inferior_matched 1
|
|
|
|
|
if {!$gdb_matched} {
|
|
|
|
|
set gdb_test_stdio_spawn_id_list ""
|
|
|
|
|
exp_continue
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
-i $gdb_spawn_id -re "$gdb_pattern\r\n$gdb_prompt $" {
|
|
|
|
|
set gdb_matched 1
|
|
|
|
|
if {!$inferior_matched} {
|
|
|
|
|
exp_continue
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}]
|
|
|
|
|
if {$res == 0} {
|
|
|
|
|
pass $message
|
|
|
|
|
} else {
|
|
|
|
|
verbose -log "inferior_matched=$inferior_matched, gdb_matched=$gdb_matched"
|
|
|
|
|
}
|
|
|
|
|
return $res
|
|
|
|
|
}
|
|
|
|
|
|
gdb: Introduce 'print max-depth' feature
Introduce a new print setting max-depth which can be set with 'set
print max-depth DEPTH'. The default value of DEPTH is 20, but this
can also be set to unlimited.
When GDB is printing a value containing nested structures GDB will
stop descending at depth DEPTH. Here is a small example:
typedef struct s1 { int a; } s1;
typedef struct s2 { s1 b; } s2;
typedef struct s3 { s2 c; } s3;
typedef struct s4 { s3 d; } s4;
s4 var = { { { { 3 } } } };
The following table shows how various depth settings affect printing
of 'var':
| Depth Setting | Result of 'p var' |
|---------------+--------------------------------|
| Unlimited | $1 = {d = {c = {b = {a = 3}}}} |
| 4 | $1 = {d = {c = {b = {a = 3}}}} |
| 3 | $1 = {d = {c = {b = {...}}}} |
| 2 | $1 = {d = {c = {...}}} |
| 1 | $1 = {d = {...}} |
| 0 | $1 = {...} |
Only structures, unions, and arrays are replaced in this way, scalars
and strings are not replaced.
The replacement is counted from the level at which you print, not from
the top level of the structure. So, consider the above example and
this GDB session:
(gdb) set print max-depth 2
(gdb) p var
$1 = {d = {c = {...}}}
(gdb) p var.d
$2 = {c = {b = {...}}}
(gdb) p var.d.c
$3 = {b = {a = 3}}
Setting the max-depth to 2 doesn't prevent the user from exploring
deeper into 'var' by asking for specific sub-fields to be printed.
The motivation behind this feature is to try and give the user more
control over how much is printed when examining large, complex data
structures.
The default max-depth of 20 means that there is a change in GDB's
default behaviour. Someone printing a data structure with 20 levels
of nesting will now see '{...}' instead of their data, they would need
to adjust the max depth, or call print again naming a specific field
in order to dig deeper into their data structure. If this is
considered a problem then we could increase the default, or even make
the default unlimited.
This commit relies on the previous commit, which added a new field to
the language structure, this new field was a string that contained the
pattern that should be used when a structure/union/array is replaced
in the output, this allows languages to use a syntax that is more
appropriate, mostly this will be selecting the correct types of
bracket '(...)' or '{...}', both of which are currently in use.
This commit should have no impact on MI output, expressions are
printed through the MI using -var-create and then -var-list-children.
As each use of -var-list-children only ever displays a single level of
an expression then the max-depth setting will have no impact.
This commit also adds the max-depth mechanism to the scripting
language pretty printers following basically the same rules as for the
built in value printing.
One quirk is that when printing a value using the display hint 'map',
if the keys of the map are structs then GDB will hide the keys one
depth level after it hides the values, this ensures that GDB produces
output like this:
$1 = map_object = {[{key1}] = {...}, [{key2}] = {...}}
Instead of this less helpful output:
$1 = map_object = {[{...}] = {...}, [{...}] = {...}}
This is covered by the new tests in gdb.python/py-nested-maps.exp.
gdb/ChangeLog:
* cp-valprint.c (cp_print_value_fields): Allow an additional level
of depth when printing anonymous structs or unions.
* guile/scm-pretty-print.c (gdbscm_apply_val_pretty_printer):
Don't print either the top-level value, or the children if the
max-depth is exceeded.
(ppscm_print_children): When printing the key of a map, allow one
extra level of depth.
* python/py-prettyprint.c (gdbpy_apply_val_pretty_printer): Don't
print either the top-level value, or the children if the max-depth
is exceeded.
(print_children): When printing the key of a map, allow one extra
level of depth.
* python/py-value.c (valpy_format_string): Add max_depth keyword.
* valprint.c: (PRINT_MAX_DEPTH_DEFAULT): Define.
(user_print_options): Initialise max_depth field.
(val_print_scalar_or_string_type_p): New function.
(val_print): Check to see if the max depth has been reached.
(val_print_check_max_depth): Define new function.
(show_print_max_depth): New function.
(_initialize_valprint): Add 'print max-depth' option.
* valprint.h (struct value_print_options) <max_depth>: New field.
(val_print_check_max_depth): Declare new function.
* NEWS: Document new feature.
gdb/doc/ChangeLog:
* gdb.texinfo (Print Settings): Document 'print max-depth'.
* guile.texi (Guile Pretty Printing API): Document that 'print
max-depth' can effect the display of a values children.
* python.texi (Pretty Printing API): Likewise.
(Values From Inferior): Document max_depth keyword.
gdb/testsuite/ChangeLog:
* gdb.base/max-depth.c: New file.
* gdb.base/max-depth.exp: New file.
* gdb.python/py-nested-maps.c: New file.
* gdb.python/py-nested-maps.exp: New file.
* gdb.python/py-nested-maps.py: New file.
* gdb.python/py-format-string.exp (test_max_depth): New proc.
(test_all_common): Call test_max_depth.
* gdb.fortran/max-depth.exp: New file.
* gdb.fortran/max-depth.f90: New file.
* gdb.go/max-depth.exp: New file.
* gdb.go/max-depth.go: New file.
* gdb.modula2/max-depth.exp: New file.
* gdb.modula2/max-depth.c: New file.
* lib/gdb.exp (get_print_expr_at_depths): New proc.
2019-03-21 16:13:23 +01:00
|
|
|
|
# get_print_expr_at_depths EXP OUTPUTS
|
|
|
|
|
#
|
|
|
|
|
# Used for testing 'set print max-depth'. Prints the expression EXP
|
|
|
|
|
# with 'set print max-depth' set to various depths. OUTPUTS is a list
|
|
|
|
|
# of `n` different patterns to match at each of the depths from 0 to
|
|
|
|
|
# (`n` - 1).
|
|
|
|
|
#
|
|
|
|
|
# This proc does one final check with the max-depth set to 'unlimited'
|
|
|
|
|
# which is tested against the last pattern in the OUTPUTS list. The
|
|
|
|
|
# OUTPUTS list is therefore required to match every depth from 0 to a
|
|
|
|
|
# depth where the whole of EXP is printed with no ellipsis.
|
|
|
|
|
#
|
|
|
|
|
# This proc leaves the 'set print max-depth' set to 'unlimited'.
|
|
|
|
|
proc gdb_print_expr_at_depths {exp outputs} {
|
|
|
|
|
for { set depth 0 } { $depth <= [llength $outputs] } { incr depth } {
|
|
|
|
|
if { $depth == [llength $outputs] } {
|
|
|
|
|
set expected_result [lindex $outputs [expr [llength $outputs] - 1]]
|
|
|
|
|
set depth_string "unlimited"
|
|
|
|
|
} else {
|
|
|
|
|
set expected_result [lindex $outputs $depth]
|
|
|
|
|
set depth_string $depth
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
with_test_prefix "exp='$exp': depth=${depth_string}" {
|
|
|
|
|
gdb_test_no_output "set print max-depth ${depth_string}"
|
|
|
|
|
gdb_test "p $exp" "$expected_result"
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
1999-04-16 03:35:26 +02:00
|
|
|
|
|
2014-07-14 20:55:31 +02:00
|
|
|
|
|
|
|
|
|
# Issue a PASS and return true if evaluating CONDITION in the caller's
|
|
|
|
|
# frame returns true, and issue a FAIL and return false otherwise.
|
|
|
|
|
# MESSAGE is the pass/fail message to be printed. If MESSAGE is
|
|
|
|
|
# omitted or is empty, then the pass/fail messages use the condition
|
|
|
|
|
# string as the message.
|
|
|
|
|
|
|
|
|
|
proc gdb_assert { condition {message ""} } {
|
|
|
|
|
if { $message == ""} {
|
|
|
|
|
set message $condition
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
set res [uplevel 1 expr $condition]
|
|
|
|
|
if {!$res} {
|
|
|
|
|
fail $message
|
|
|
|
|
} else {
|
|
|
|
|
pass $message
|
|
|
|
|
}
|
|
|
|
|
return $res
|
|
|
|
|
}
|
|
|
|
|
|
1999-04-16 03:35:26 +02:00
|
|
|
|
proc gdb_reinitialize_dir { subdir } {
|
|
|
|
|
global gdb_prompt
|
|
|
|
|
|
|
|
|
|
if [is_remote host] {
|
gdb/testsuite/
* config/monitor.exp (gdb_target_cmd): Remove semicolon after
'return'.
(gdb_target_monitor, gdb_load): Likewise.
* config/sid.exp (gdb_load): Likewise.
* config/slite.exp (gdb_load): Likewise.
* config/vx.exp (gdb_start, spawn_vxgdb): Likewise.
* gdb.ada/arrayidx.exp, gdb.ada/null_array.exp: Likewise.
* gdb.arch/mips-octeon-bbit.exp (single_step): Likewise.
(single_step_until): Likewise.
* gdb.arch/powerpc-d128-regs.exp: Likewise.
* gdb.arch/system-gcore.exp: Likewise.
* gdb.base/bigcore.exp (extract_heap): Likewise.
* gdb.base/break-on-linker-gcd-function.exp: Likewise.
* gdb.base/call-ar-st.exp: Likewise.
* gdb.base/call-rt-st.exp: Likewise.
* gdb.base/call-sc.exp, gdb.base/call-strs.exp: Likewise.
* gdb.base/callfuncs.exp, gdb.base/completion.exp: Likewise.
* gdb.base/condbreak.exp, gdb.base/constvars.exp: Likewise.
* gdb.base/corefile.exp: Likewise.
* gdb.base/dbx.exp (gdb_file_cmd): Likewise.
* gdb.base/exprs.exp, gdb.base/fileio.exp: Likewise.
* gdb.base/fixsection.exp: Likewise.
* gdb.base/funcargs.exp: Likewise.
* gdb.base/gcore-buffer-overflow.exp: Likewise.
* gdb.base/gcore-relro.exp: Likewise.
* gdb.base/gcore.exp, gdb.base/gdb11530.exp: Likewise.
* gdb.base/gdb11531.exp, gdb.base/gnu-ifunc.exp: Likewise.
* gdb.base/info-os.exp, gdb.base/info-proc.exp: Likewise.
* gdb.base/interp.exp, gdb.base/langs.exp:: Likewise.
* gdb.base/list.exp: Likewise.
(set_listsize): Likewise.
* gdb.base/logical.exp, gdb.base/mips_pro.exp: Likewise.
* gdb.base/miscexprs.exp, gdb.base/nodebug.exp: Likewise.
* gdb.base/opaque.exp, gdb.base/pointers.exp: Likewise.
* gdb.base/psymtab.exp, gdb.base/ptype.exp: Likewise.
* gdb.base/relational.exp, gdb.base/scope.exp: Likewise.
* gdb.base/setvar.exp: Likewise.
(test_set): Likewise.
* gdb.base/signals.exp, gdb.base/sizeof.exp: Likewise.
* gdb.base/solib-overlap.exp: Likewise.
* gdb.base/store.exp, gdb.base/structs.exp: Likewise.
* gdb.base/structs2.exp, gdb.base/volatile.exp: Likewise.
* gdb.base/watchpoint.exp (initialize): Likewise.
(test_simple_watchpoint): Likewise.
(test_disabling_watchpoints): Likewise.
(test_watchpoint_triggered_in_syscall): Likewise.
* gdb.base/whatis.exp, gdb.cp/ambiguous.exp: Likewise.
* gdb.cp/casts.exp, gdb.cp/ctti.exp: Likewise.
* gdb.cp/namespace.exp, gdb.cp/nsdecl.exp: Likewise.
* gdb.cp/psmang.exp, gdb.dwarf2/dw2-ranges.exp: Likewise.
* gdb.hp/gdb.aCC/optimize.exp: Likewise.
* gdb.hp/gdb.aCC/watch-cmd.exp: Likewise.
* gdb.hp/gdb.base-hp/callfwmall.exp: Likewise.
* gdb.hp/gdb.base-hp/pxdb.exp: Likewise.
* gdb.hp/gdb.compat/xdb1.exp: Likewise.
* gdb.hp/gdb.compat/xdb2.exp: Likewise.
* gdb.hp/gdb.compat/xdb3.exp: Likewise.
* gdb.hp/gdb.defects/bs14602.exp: Likewise.
* gdb.hp/gdb.defects/solib-d.exp: Likewise.
* gdb.mi/gdb792.exp: Likewise.
* gdb.mi/mi-inheritance-syntax-error.exp: Likewise.
* gdb.mi/mi-logging.exp, gdb.mi/mi-var-cp.exp : Likewise.
* gdb.mi/mi-var-rtti.exp, gdb.python/py-type.exp: Likewise.
* gdb.threads/gcore-thread.exp: Likewise.
(load_core): Likewise.
* gdb.threads/pthreads.exp (all_threads_running): Likewise.
(test_startup, check_control_c): Likewise.
* gdb.threads/sigstep-threads.exp: Likewise.
* gdb.threads/thread_check.exp: Likewise.
* gdb.trace/backtrace.exp, gdb.trace/change-loc.exp: Likewise.
* gdb.trace/circ.exp (run_trace_experiment): Likewise.
(set_a_tracepoint, trace_buffer_normal): Likewise.
(gdb_trace_circular_tests): Likewise.
* gdb.trace/collection.exp: Likewise.
* gdb.trace/disconnected-tracing.exp: Likewise.
* gdb.trace/infotrace.exp: Likewise.
* gdb.trace/mi-traceframe-changed.exp: Likewise.
* gdb.trace/mi-tracepoint-changed.exp: Likewise.
* gdb.trace/mi-tsv-changed.exp (test_create_delete_modify_tsv): Likewise.
* gdb.trace/packetlen.exp, gdb.trace/passc-dyn.exp: Likewise.
* gdb.trace/pending.exp, gdb.trace/report.exp: Likewise.
* gdb.trace/stap-trace.exp: Likewise.
* gdb.trace/status-stop.exp,gdb.trace/strace.exp: Likewise.
* gdb.trace/tfind.exp, gdb.trace/trace-break.exp: Likewise.
* gdb.trace/trace-buffer-size.exp: Likewise.
* gdb.trace/tspeed.exp, gdb.trace/tsv.exp: Likewise.
* gdb.trace/unavailable.exp: Likewise.
* gdb.trace/while-dyn.exp: Likewise.
* lib/fortran.exp (set_lang_fortran): Likewise.
* lib/gdb.exp (default_gdb_version, gdb_start_cmd): Likewise.
(gdb_breakpoint, gdb_reinitialize_dir): Likewise.
(default_gdb_start, get_compiler_info): Likewise.
(gdb_compile, gdb_compile_objc, gdb_reload, gdb_init): Likewise.
(get_debug_format, setup_xfail_format): Likewise.
(rerun_to_main, gdb_skip_float_test): Likewise.
(build_id_debug_filename_get, get_remotetimeout): Likewise.
* lib/java.exp (set_lang_java): Likewise.
* lib/mi-support.exp (default_mi_gdb_start): Likewise.
(mi_gdb_reinitialize_dir, mi_gdb_target_cmd): Likewise.
(mi_gdb_file_cmd, mi_gdb_test): Likewise.
(mi_run_cmd_full, mi_expect_interrupt): Likewise.
* lib/objc.exp (set_lang_objc): Likewise.
* lib/pascal.exp (set_lang_pascal): Likewise.
* lib/prompt.exp (default_prompt_gdb_start): Likewise.
* lib/trace-support.exp (gdb_trace_setactions, gdb_tfind_test): Likewise.
(gdb_readexpr, gdb_gettpnum, gdb_find_recursion_test_baseline): Likewise.
2013-03-14 14:34:06 +01:00
|
|
|
|
return ""
|
1999-04-16 03:35:26 +02:00
|
|
|
|
}
|
|
|
|
|
send_gdb "dir\n"
|
|
|
|
|
gdb_expect 60 {
|
|
|
|
|
-re "Reinitialize source path to empty.*y or n. " {
|
2019-05-17 17:30:09 +02:00
|
|
|
|
send_gdb "y\n" answer
|
1999-04-16 03:35:26 +02:00
|
|
|
|
gdb_expect 60 {
|
|
|
|
|
-re "Source directories searched.*$gdb_prompt $" {
|
|
|
|
|
send_gdb "dir $subdir\n"
|
|
|
|
|
gdb_expect 60 {
|
|
|
|
|
-re "Source directories searched.*$gdb_prompt $" {
|
|
|
|
|
verbose "Dir set to $subdir"
|
|
|
|
|
}
|
|
|
|
|
-re "$gdb_prompt $" {
|
|
|
|
|
perror "Dir \"$subdir\" failed."
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
-re "$gdb_prompt $" {
|
|
|
|
|
perror "Dir \"$subdir\" failed."
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
-re "$gdb_prompt $" {
|
|
|
|
|
perror "Dir \"$subdir\" failed."
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#
|
|
|
|
|
# gdb_exit -- exit the GDB, killing the target program if necessary
|
|
|
|
|
#
|
|
|
|
|
proc default_gdb_exit {} {
|
|
|
|
|
global GDB
|
2008-11-11 02:23:34 +01:00
|
|
|
|
global INTERNAL_GDBFLAGS GDBFLAGS
|
1999-04-16 03:35:26 +02:00
|
|
|
|
global verbose
|
Add testing infrastruture bits for running with MI on a separate UI
With this, a specific test may can start GDB with MI on a separate UI
by using:
mi_gdb_start separate-mi-tty
In addition, it's also possible to run the whole testsuite with MI on
a separate tty, with:
make check RUNTESTFLAGS="FORCE_SEPARATE_MI_TTY=1"
gdb_main_spawn_id and mi_spawn_id are added so that tests may expect
output from either channel.
While at it, inferior_spawn_id was not being cleared when gdb exits,
unlike the other spawn ids, thus a test that starts gdb more than once
would end up using a stale spawn id.
gdb/testsuite/ChangeLog:
2016-06-21 Pedro Alves <palves@redhat.com>
* README (Testsuite Parameters): Document FORCE_SEPARATE_MI_TTY.
* lib/gdb.exp (default_gdb_exit): Clear inferior_spawn_id.
* lib/mi-support.exp (mi_uncatched_gdb_exit): Unset
gdb_main_spawn_id, mi_spawn_id, unset inferior_spawn_id.
(gdb_main_spawn_id, mi_spawn_id): Declare and
comment.
(mi_create_inferior_pty): New procedure,
factored out from default_mi_gdb_start.
(switch_gdb_spawn_id, mi_gdb_start_separate_mi_tty): New
procedures.
(default_mi_gdb_start): Call mi_gdb_start_separate_mi_tty if the
separate-mi-tty option is specified, or SEPARATE_MI_TTY is set.
Use mi_create_inferior_pty.
(mi_gdb_start): Use eval to pass down args list.
2016-06-21 02:11:55 +02:00
|
|
|
|
global gdb_spawn_id inferior_spawn_id
|
introduce parallel mode
This introduces parallel mode for the test suite.
It doesn't fully work yet in the sense that if you do a fully parallel
run, you will encounter some file-name clashes, but this has to start
somewhere, and it seemed best to add some infrastructure now, so that
you can follow along and test subsequent patches if you care to.
This patch has two parts.
First, it checks for the GDB_PARALLEL variable. If this is set (say,
on the runtest command line), then the test suite assumes "parallel
mode". In this mode, files are put into a subdirectory named after
the test. That is, for DIR/TEST.exp, the outputs are put into
./outputs/DIR/TEST/.
This first part has various follow-on changes coming in subsequent
patches. This is why the code in this patch also makes "temp" and
"cache" directories.
Second, this adds an "inotify" mode. If you have the inotifywait
command (part of inotify-tools), you can set the GDB_INOTIFY variable.
This will tell the test suite to watch for changes outside of the
allowed output directories.
This mode is useful for debugging the test suite, as it issues a
report whenever a possibly parallel-unsafe file open is done.
2013-08-13 Tom Tromey <tromey@redhat.com>
Yao Qi <yao@codesourcery.com>
* lib/cache.exp (gdb_do_cache): Handle GDB_PARALLEL.
* lib/gdb.exp: Handle GDB_PARALLEL.
(default_gdb_version): Kill inotify_pid if it exists.
(default_gdb_exit): Emit warning if the inotify log is not
empty.
(standard_output_file): Respect GDB_PARALLEL.
(standard_temp_file): Likewise.
(gdb_init): Start inotifywait if requested.
* gdbint.texinfo (Testsuite): Use @table, not @itemize.
Document GDB_PARALLEL and GDB_INOTIFY.
2013-08-13 18:12:04 +02:00
|
|
|
|
global inotify_log_file
|
1999-04-16 03:35:26 +02:00
|
|
|
|
|
2013-06-07 19:31:09 +02:00
|
|
|
|
gdb_stop_suppressing_tests
|
1999-04-16 03:35:26 +02:00
|
|
|
|
|
|
|
|
|
if ![info exists gdb_spawn_id] {
|
2013-06-07 19:31:09 +02:00
|
|
|
|
return
|
1999-04-16 03:35:26 +02:00
|
|
|
|
}
|
|
|
|
|
|
2008-11-11 02:23:34 +01:00
|
|
|
|
verbose "Quitting $GDB $INTERNAL_GDBFLAGS $GDBFLAGS"
|
1999-04-16 03:35:26 +02:00
|
|
|
|
|
introduce parallel mode
This introduces parallel mode for the test suite.
It doesn't fully work yet in the sense that if you do a fully parallel
run, you will encounter some file-name clashes, but this has to start
somewhere, and it seemed best to add some infrastructure now, so that
you can follow along and test subsequent patches if you care to.
This patch has two parts.
First, it checks for the GDB_PARALLEL variable. If this is set (say,
on the runtest command line), then the test suite assumes "parallel
mode". In this mode, files are put into a subdirectory named after
the test. That is, for DIR/TEST.exp, the outputs are put into
./outputs/DIR/TEST/.
This first part has various follow-on changes coming in subsequent
patches. This is why the code in this patch also makes "temp" and
"cache" directories.
Second, this adds an "inotify" mode. If you have the inotifywait
command (part of inotify-tools), you can set the GDB_INOTIFY variable.
This will tell the test suite to watch for changes outside of the
allowed output directories.
This mode is useful for debugging the test suite, as it issues a
report whenever a possibly parallel-unsafe file open is done.
2013-08-13 Tom Tromey <tromey@redhat.com>
Yao Qi <yao@codesourcery.com>
* lib/cache.exp (gdb_do_cache): Handle GDB_PARALLEL.
* lib/gdb.exp: Handle GDB_PARALLEL.
(default_gdb_version): Kill inotify_pid if it exists.
(default_gdb_exit): Emit warning if the inotify log is not
empty.
(standard_output_file): Respect GDB_PARALLEL.
(standard_temp_file): Likewise.
(gdb_init): Start inotifywait if requested.
* gdbint.texinfo (Testsuite): Use @table, not @itemize.
Document GDB_PARALLEL and GDB_INOTIFY.
2013-08-13 18:12:04 +02:00
|
|
|
|
if {[info exists inotify_log_file] && [file exists $inotify_log_file]} {
|
|
|
|
|
set fd [open $inotify_log_file]
|
|
|
|
|
set data [read -nonewline $fd]
|
|
|
|
|
close $fd
|
|
|
|
|
|
|
|
|
|
if {[string compare $data ""] != 0} {
|
|
|
|
|
warning "parallel-unsafe file creations noticed"
|
|
|
|
|
|
|
|
|
|
# Clear the log.
|
|
|
|
|
set fd [open $inotify_log_file w]
|
|
|
|
|
close $fd
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
1999-04-16 03:35:26 +02:00
|
|
|
|
if { [is_remote host] && [board_info host exists fileid] } {
|
2013-06-07 19:31:09 +02:00
|
|
|
|
send_gdb "quit\n"
|
1999-04-16 03:35:26 +02:00
|
|
|
|
gdb_expect 10 {
|
|
|
|
|
-re "y or n" {
|
2019-05-17 17:30:09 +02:00
|
|
|
|
send_gdb "y\n" answer
|
2013-06-07 19:31:09 +02:00
|
|
|
|
exp_continue
|
1999-04-16 03:35:26 +02:00
|
|
|
|
}
|
|
|
|
|
-re "DOSEXIT code" { }
|
|
|
|
|
default { }
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ![is_remote host] {
|
2013-06-07 19:31:09 +02:00
|
|
|
|
remote_close host
|
1999-04-16 03:35:26 +02:00
|
|
|
|
}
|
|
|
|
|
unset gdb_spawn_id
|
Add testing infrastruture bits for running with MI on a separate UI
With this, a specific test may can start GDB with MI on a separate UI
by using:
mi_gdb_start separate-mi-tty
In addition, it's also possible to run the whole testsuite with MI on
a separate tty, with:
make check RUNTESTFLAGS="FORCE_SEPARATE_MI_TTY=1"
gdb_main_spawn_id and mi_spawn_id are added so that tests may expect
output from either channel.
While at it, inferior_spawn_id was not being cleared when gdb exits,
unlike the other spawn ids, thus a test that starts gdb more than once
would end up using a stale spawn id.
gdb/testsuite/ChangeLog:
2016-06-21 Pedro Alves <palves@redhat.com>
* README (Testsuite Parameters): Document FORCE_SEPARATE_MI_TTY.
* lib/gdb.exp (default_gdb_exit): Clear inferior_spawn_id.
* lib/mi-support.exp (mi_uncatched_gdb_exit): Unset
gdb_main_spawn_id, mi_spawn_id, unset inferior_spawn_id.
(gdb_main_spawn_id, mi_spawn_id): Declare and
comment.
(mi_create_inferior_pty): New procedure,
factored out from default_mi_gdb_start.
(switch_gdb_spawn_id, mi_gdb_start_separate_mi_tty): New
procedures.
(default_mi_gdb_start): Call mi_gdb_start_separate_mi_tty if the
separate-mi-tty option is specified, or SEPARATE_MI_TTY is set.
Use mi_create_inferior_pty.
(mi_gdb_start): Use eval to pass down args list.
2016-06-21 02:11:55 +02:00
|
|
|
|
unset inferior_spawn_id
|
1999-04-16 03:35:26 +02:00
|
|
|
|
}
|
|
|
|
|
|
2004-08-29 01:55:48 +02:00
|
|
|
|
# Load a file into the debugger.
|
2004-09-10 03:04:59 +02:00
|
|
|
|
# The return value is 0 for success, -1 for failure.
|
1999-04-16 03:35:26 +02:00
|
|
|
|
#
|
2004-09-10 03:04:59 +02:00
|
|
|
|
# This procedure also set the global variable GDB_FILE_CMD_DEBUG_INFO
|
|
|
|
|
# to one of these values:
|
2004-08-29 01:55:48 +02:00
|
|
|
|
#
|
2004-09-10 03:04:59 +02:00
|
|
|
|
# debug file was loaded successfully and has debug information
|
|
|
|
|
# nodebug file was loaded successfully and has no debug information
|
2012-11-26 20:23:56 +01:00
|
|
|
|
# lzma file was loaded, .gnu_debugdata found, but no LZMA support
|
|
|
|
|
# compiled in
|
2004-09-10 03:04:59 +02:00
|
|
|
|
# fail file was not loaded
|
1999-04-16 03:35:26 +02:00
|
|
|
|
#
|
2004-09-10 03:04:59 +02:00
|
|
|
|
# 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.
|
2004-08-29 01:55:48 +02:00
|
|
|
|
#
|
2004-09-10 03:04:59 +02:00
|
|
|
|
# TODO: gdb.base/sepdebug.exp and gdb.stabs/weird.exp might be able to use
|
|
|
|
|
# this if they can get more information set.
|
2004-08-29 01:55:48 +02:00
|
|
|
|
|
1999-04-16 03:35:26 +02:00
|
|
|
|
proc gdb_file_cmd { arg } {
|
2004-08-29 01:55:48 +02:00
|
|
|
|
global gdb_prompt
|
1999-04-16 03:35:26 +02:00
|
|
|
|
global verbose
|
|
|
|
|
global GDB
|
2007-03-27 19:59:38 +02:00
|
|
|
|
global last_loaded_file
|
|
|
|
|
|
2012-10-02 19:17:45 +02:00
|
|
|
|
# Save this for the benefit of gdbserver-support.exp.
|
2007-03-27 19:59:38 +02:00
|
|
|
|
set last_loaded_file $arg
|
1999-04-16 03:35:26 +02:00
|
|
|
|
|
2004-09-10 03:04:59 +02:00
|
|
|
|
# Set whether debug info was found.
|
|
|
|
|
# Default to "fail".
|
|
|
|
|
global gdb_file_cmd_debug_info
|
|
|
|
|
set gdb_file_cmd_debug_info "fail"
|
|
|
|
|
|
1999-04-16 03:35:26 +02:00
|
|
|
|
if [is_remote host] {
|
2004-08-29 01:55:48 +02:00
|
|
|
|
set arg [remote_download host $arg]
|
1999-04-16 03:35:26 +02:00
|
|
|
|
if { $arg == "" } {
|
2004-09-10 03:04:59 +02:00
|
|
|
|
perror "download failed"
|
|
|
|
|
return -1
|
1999-04-16 03:35:26 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2006-07-24 22:38:08 +02:00
|
|
|
|
# The file command used to kill the remote target. For the benefit
|
2019-05-17 17:30:09 +02:00
|
|
|
|
# of the testsuite, preserve this behavior. Mark as optional so it doesn't
|
|
|
|
|
# get written to the stdin log.
|
|
|
|
|
send_gdb "kill\n" optional
|
2006-07-24 22:38:08 +02:00
|
|
|
|
gdb_expect 120 {
|
|
|
|
|
-re "Kill the program being debugged. .y or n. $" {
|
2019-05-17 17:30:09 +02:00
|
|
|
|
send_gdb "y\n" answer
|
2006-07-24 22:38:08 +02:00
|
|
|
|
verbose "\t\tKilling previous program being debugged"
|
|
|
|
|
exp_continue
|
|
|
|
|
}
|
|
|
|
|
-re "$gdb_prompt $" {
|
|
|
|
|
# OK.
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
1999-04-16 03:35:26 +02:00
|
|
|
|
send_gdb "file $arg\n"
|
|
|
|
|
gdb_expect 120 {
|
2018-05-19 19:25:20 +02:00
|
|
|
|
-re "Reading symbols from.*LZMA support was disabled.*$gdb_prompt $" {
|
2012-11-26 20:23:56 +01:00
|
|
|
|
verbose "\t\tLoaded $arg into $GDB; .gnu_debugdata found but no LZMA available"
|
|
|
|
|
set gdb_file_cmd_debug_info "lzma"
|
|
|
|
|
return 0
|
|
|
|
|
}
|
2018-05-19 19:25:20 +02:00
|
|
|
|
-re "Reading symbols from.*no debugging symbols found.*$gdb_prompt $" {
|
2012-10-02 19:17:45 +02:00
|
|
|
|
verbose "\t\tLoaded $arg into $GDB with no debugging symbols"
|
2004-09-10 03:04:59 +02:00
|
|
|
|
set gdb_file_cmd_debug_info "nodebug"
|
|
|
|
|
return 0
|
2004-08-29 01:55:48 +02:00
|
|
|
|
}
|
2018-05-19 19:25:20 +02:00
|
|
|
|
-re "Reading symbols from.*$gdb_prompt $" {
|
2012-10-02 19:17:45 +02:00
|
|
|
|
verbose "\t\tLoaded $arg into $GDB"
|
2004-09-10 03:04:59 +02:00
|
|
|
|
set gdb_file_cmd_debug_info "debug"
|
|
|
|
|
return 0
|
1999-04-16 03:35:26 +02:00
|
|
|
|
}
|
|
|
|
|
-re "Load new symbol table from \".*\".*y or n. $" {
|
2019-05-17 17:30:09 +02:00
|
|
|
|
send_gdb "y\n" answer
|
1999-04-16 03:35:26 +02:00
|
|
|
|
gdb_expect 120 {
|
2018-05-19 19:25:20 +02:00
|
|
|
|
-re "Reading symbols from.*$gdb_prompt $" {
|
1999-04-16 03:35:26 +02:00
|
|
|
|
verbose "\t\tLoaded $arg with new symbol table into $GDB"
|
2004-09-10 03:04:59 +02:00
|
|
|
|
set gdb_file_cmd_debug_info "debug"
|
|
|
|
|
return 0
|
1999-04-16 03:35:26 +02:00
|
|
|
|
}
|
|
|
|
|
timeout {
|
2012-10-02 19:17:45 +02:00
|
|
|
|
perror "Couldn't load $arg, other program already loaded (timeout)."
|
2004-09-10 03:04:59 +02:00
|
|
|
|
return -1
|
1999-04-16 03:35:26 +02:00
|
|
|
|
}
|
2012-10-02 19:17:45 +02:00
|
|
|
|
eof {
|
|
|
|
|
perror "Couldn't load $arg, other program already loaded (eof)."
|
|
|
|
|
return -1
|
|
|
|
|
}
|
1999-04-16 03:35:26 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
-re "No such file or directory.*$gdb_prompt $" {
|
2004-09-10 03:04:59 +02:00
|
|
|
|
perror "($arg) No such file or directory"
|
|
|
|
|
return -1
|
1999-04-16 03:35:26 +02:00
|
|
|
|
}
|
2012-09-21 22:01:12 +02:00
|
|
|
|
-re "A problem internal to GDB has been detected" {
|
2012-10-11 17:59:57 +02:00
|
|
|
|
fail "($arg) (GDB internal error)"
|
2012-09-21 22:01:12 +02:00
|
|
|
|
gdb_internal_error_resync
|
|
|
|
|
return -1
|
|
|
|
|
}
|
1999-04-16 03:35:26 +02:00
|
|
|
|
-re "$gdb_prompt $" {
|
2012-10-02 19:17:45 +02:00
|
|
|
|
perror "Couldn't load $arg into $GDB."
|
2004-09-10 03:04:59 +02:00
|
|
|
|
return -1
|
1999-04-16 03:35:26 +02:00
|
|
|
|
}
|
|
|
|
|
timeout {
|
2012-10-02 19:17:45 +02:00
|
|
|
|
perror "Couldn't load $arg into $GDB (timeout)."
|
2004-09-10 03:04:59 +02:00
|
|
|
|
return -1
|
1999-04-16 03:35:26 +02:00
|
|
|
|
}
|
|
|
|
|
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.
|
2012-10-02 19:17:45 +02:00
|
|
|
|
perror "Couldn't load $arg into $GDB (eof)."
|
2004-09-10 03:04:59 +02:00
|
|
|
|
return -1
|
1999-04-16 03:35:26 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
Canceling pagination caused by execution command from command line aborts readline/gdb
This fixes:
$ ./gdb program -ex "set height 2" -ex "start"
...
Reading symbols from /home/pedro/gdb/tests/threads...done.
---Type <return> to continue, or q <return> to quit---^CQuit << ctrl-c triggers a Quit
*type something*
readline: readline_callback_read_char() called with no handler!
Aborted
$
Usually, if an error propagates all the way to the top level, we'll
re-enable stdin, in case the command that was running was a
synchronous command. That's done in the event loop's actual loop
(event-loop.c:start_event_loop). However, if a foreground execution
command is run before the event loop starts and throws, nothing is
presently reenabling stdin, which leaves sync_execution set.
When we do start the event loop, because sync_execution is still
(mistakenly) set, display_gdb_prompt removes the readline input
callback, even though stdin is registered in the event loop. Any
input from here on results in readline aborting.
Such commands are run through catch_command_errors,
catch_command_errors_const, so add the tweak there.
gdb/
2014-07-14 Pedro Alves <palves@redhat.com>
PR gdb/17072
* main.c: Include event-top.h.
(handle_command_errors): New function.
(catch_command_errors, catch_command_errors_const): Use it.
gdb/testsuite/
2014-07-14 Pedro Alves <palves@redhat.com>
PR gdb/17072
* gdb.base/paginate-execution-startup.c: New file.
* gdb.base/paginate-execution-startup.exp: New file.
* lib/gdb.exp (pagination_prompt): New global.
(default_gdb_spawn): New procedure, factored out from
default_gdb_spawn.
(default_gdb_start): Adjust to call default_gdb_spawn.
(gdb_spawn): New procedure.
2014-07-14 20:55:31 +02:00
|
|
|
|
# Default gdb_spawn procedure.
|
|
|
|
|
|
|
|
|
|
proc default_gdb_spawn { } {
|
|
|
|
|
global use_gdb_stub
|
1999-04-16 03:35:26 +02:00
|
|
|
|
global GDB
|
2008-11-11 02:23:34 +01:00
|
|
|
|
global INTERNAL_GDBFLAGS GDBFLAGS
|
2013-06-07 19:31:09 +02:00
|
|
|
|
global gdb_spawn_id
|
1999-04-16 03:35:26 +02:00
|
|
|
|
|
2013-06-07 19:31:09 +02:00
|
|
|
|
gdb_stop_suppressing_tests
|
1999-04-16 03:35:26 +02:00
|
|
|
|
|
2011-12-03 21:20:29 +01:00
|
|
|
|
# Set the default value, it may be overriden later by specific testfile.
|
|
|
|
|
#
|
|
|
|
|
# Use `set_board_info use_gdb_stub' for the board file to flag the inferior
|
|
|
|
|
# is already started after connecting and run/attach are not supported.
|
|
|
|
|
# This is used for the "remote" protocol. After GDB starts you should
|
|
|
|
|
# check global $use_gdb_stub instead of the board as the testfile may force
|
|
|
|
|
# a specific different target protocol itself.
|
|
|
|
|
set use_gdb_stub [target_info exists use_gdb_stub]
|
|
|
|
|
|
2008-11-11 02:23:34 +01:00
|
|
|
|
verbose "Spawning $GDB $INTERNAL_GDBFLAGS $GDBFLAGS"
|
2019-05-17 17:38:02 +02:00
|
|
|
|
gdb_write_cmd_file "$GDB $INTERNAL_GDBFLAGS $GDBFLAGS"
|
1999-04-16 03:35:26 +02:00
|
|
|
|
|
|
|
|
|
if [info exists gdb_spawn_id] {
|
gdb/testsuite/
* config/monitor.exp (gdb_target_cmd): Remove semicolon after
'return'.
(gdb_target_monitor, gdb_load): Likewise.
* config/sid.exp (gdb_load): Likewise.
* config/slite.exp (gdb_load): Likewise.
* config/vx.exp (gdb_start, spawn_vxgdb): Likewise.
* gdb.ada/arrayidx.exp, gdb.ada/null_array.exp: Likewise.
* gdb.arch/mips-octeon-bbit.exp (single_step): Likewise.
(single_step_until): Likewise.
* gdb.arch/powerpc-d128-regs.exp: Likewise.
* gdb.arch/system-gcore.exp: Likewise.
* gdb.base/bigcore.exp (extract_heap): Likewise.
* gdb.base/break-on-linker-gcd-function.exp: Likewise.
* gdb.base/call-ar-st.exp: Likewise.
* gdb.base/call-rt-st.exp: Likewise.
* gdb.base/call-sc.exp, gdb.base/call-strs.exp: Likewise.
* gdb.base/callfuncs.exp, gdb.base/completion.exp: Likewise.
* gdb.base/condbreak.exp, gdb.base/constvars.exp: Likewise.
* gdb.base/corefile.exp: Likewise.
* gdb.base/dbx.exp (gdb_file_cmd): Likewise.
* gdb.base/exprs.exp, gdb.base/fileio.exp: Likewise.
* gdb.base/fixsection.exp: Likewise.
* gdb.base/funcargs.exp: Likewise.
* gdb.base/gcore-buffer-overflow.exp: Likewise.
* gdb.base/gcore-relro.exp: Likewise.
* gdb.base/gcore.exp, gdb.base/gdb11530.exp: Likewise.
* gdb.base/gdb11531.exp, gdb.base/gnu-ifunc.exp: Likewise.
* gdb.base/info-os.exp, gdb.base/info-proc.exp: Likewise.
* gdb.base/interp.exp, gdb.base/langs.exp:: Likewise.
* gdb.base/list.exp: Likewise.
(set_listsize): Likewise.
* gdb.base/logical.exp, gdb.base/mips_pro.exp: Likewise.
* gdb.base/miscexprs.exp, gdb.base/nodebug.exp: Likewise.
* gdb.base/opaque.exp, gdb.base/pointers.exp: Likewise.
* gdb.base/psymtab.exp, gdb.base/ptype.exp: Likewise.
* gdb.base/relational.exp, gdb.base/scope.exp: Likewise.
* gdb.base/setvar.exp: Likewise.
(test_set): Likewise.
* gdb.base/signals.exp, gdb.base/sizeof.exp: Likewise.
* gdb.base/solib-overlap.exp: Likewise.
* gdb.base/store.exp, gdb.base/structs.exp: Likewise.
* gdb.base/structs2.exp, gdb.base/volatile.exp: Likewise.
* gdb.base/watchpoint.exp (initialize): Likewise.
(test_simple_watchpoint): Likewise.
(test_disabling_watchpoints): Likewise.
(test_watchpoint_triggered_in_syscall): Likewise.
* gdb.base/whatis.exp, gdb.cp/ambiguous.exp: Likewise.
* gdb.cp/casts.exp, gdb.cp/ctti.exp: Likewise.
* gdb.cp/namespace.exp, gdb.cp/nsdecl.exp: Likewise.
* gdb.cp/psmang.exp, gdb.dwarf2/dw2-ranges.exp: Likewise.
* gdb.hp/gdb.aCC/optimize.exp: Likewise.
* gdb.hp/gdb.aCC/watch-cmd.exp: Likewise.
* gdb.hp/gdb.base-hp/callfwmall.exp: Likewise.
* gdb.hp/gdb.base-hp/pxdb.exp: Likewise.
* gdb.hp/gdb.compat/xdb1.exp: Likewise.
* gdb.hp/gdb.compat/xdb2.exp: Likewise.
* gdb.hp/gdb.compat/xdb3.exp: Likewise.
* gdb.hp/gdb.defects/bs14602.exp: Likewise.
* gdb.hp/gdb.defects/solib-d.exp: Likewise.
* gdb.mi/gdb792.exp: Likewise.
* gdb.mi/mi-inheritance-syntax-error.exp: Likewise.
* gdb.mi/mi-logging.exp, gdb.mi/mi-var-cp.exp : Likewise.
* gdb.mi/mi-var-rtti.exp, gdb.python/py-type.exp: Likewise.
* gdb.threads/gcore-thread.exp: Likewise.
(load_core): Likewise.
* gdb.threads/pthreads.exp (all_threads_running): Likewise.
(test_startup, check_control_c): Likewise.
* gdb.threads/sigstep-threads.exp: Likewise.
* gdb.threads/thread_check.exp: Likewise.
* gdb.trace/backtrace.exp, gdb.trace/change-loc.exp: Likewise.
* gdb.trace/circ.exp (run_trace_experiment): Likewise.
(set_a_tracepoint, trace_buffer_normal): Likewise.
(gdb_trace_circular_tests): Likewise.
* gdb.trace/collection.exp: Likewise.
* gdb.trace/disconnected-tracing.exp: Likewise.
* gdb.trace/infotrace.exp: Likewise.
* gdb.trace/mi-traceframe-changed.exp: Likewise.
* gdb.trace/mi-tracepoint-changed.exp: Likewise.
* gdb.trace/mi-tsv-changed.exp (test_create_delete_modify_tsv): Likewise.
* gdb.trace/packetlen.exp, gdb.trace/passc-dyn.exp: Likewise.
* gdb.trace/pending.exp, gdb.trace/report.exp: Likewise.
* gdb.trace/stap-trace.exp: Likewise.
* gdb.trace/status-stop.exp,gdb.trace/strace.exp: Likewise.
* gdb.trace/tfind.exp, gdb.trace/trace-break.exp: Likewise.
* gdb.trace/trace-buffer-size.exp: Likewise.
* gdb.trace/tspeed.exp, gdb.trace/tsv.exp: Likewise.
* gdb.trace/unavailable.exp: Likewise.
* gdb.trace/while-dyn.exp: Likewise.
* lib/fortran.exp (set_lang_fortran): Likewise.
* lib/gdb.exp (default_gdb_version, gdb_start_cmd): Likewise.
(gdb_breakpoint, gdb_reinitialize_dir): Likewise.
(default_gdb_start, get_compiler_info): Likewise.
(gdb_compile, gdb_compile_objc, gdb_reload, gdb_init): Likewise.
(get_debug_format, setup_xfail_format): Likewise.
(rerun_to_main, gdb_skip_float_test): Likewise.
(build_id_debug_filename_get, get_remotetimeout): Likewise.
* lib/java.exp (set_lang_java): Likewise.
* lib/mi-support.exp (default_mi_gdb_start): Likewise.
(mi_gdb_reinitialize_dir, mi_gdb_target_cmd): Likewise.
(mi_gdb_file_cmd, mi_gdb_test): Likewise.
(mi_run_cmd_full, mi_expect_interrupt): Likewise.
* lib/objc.exp (set_lang_objc): Likewise.
* lib/pascal.exp (set_lang_pascal): Likewise.
* lib/prompt.exp (default_prompt_gdb_start): Likewise.
* lib/trace-support.exp (gdb_trace_setactions, gdb_tfind_test): Likewise.
(gdb_readexpr, gdb_gettpnum, gdb_find_recursion_test_baseline): Likewise.
2013-03-14 14:34:06 +01:00
|
|
|
|
return 0
|
1999-04-16 03:35:26 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ![is_remote host] {
|
|
|
|
|
if { [which $GDB] == 0 } then {
|
|
|
|
|
perror "$GDB does not exist."
|
|
|
|
|
exit 1
|
|
|
|
|
}
|
|
|
|
|
}
|
2013-06-07 19:31:09 +02:00
|
|
|
|
set res [remote_spawn host "$GDB $INTERNAL_GDBFLAGS $GDBFLAGS [host_info gdb_opts]"]
|
1999-04-16 03:35:26 +02:00
|
|
|
|
if { $res < 0 || $res == "" } {
|
|
|
|
|
perror "Spawning $GDB failed."
|
gdb/testsuite/
* config/monitor.exp (gdb_target_cmd): Remove semicolon after
'return'.
(gdb_target_monitor, gdb_load): Likewise.
* config/sid.exp (gdb_load): Likewise.
* config/slite.exp (gdb_load): Likewise.
* config/vx.exp (gdb_start, spawn_vxgdb): Likewise.
* gdb.ada/arrayidx.exp, gdb.ada/null_array.exp: Likewise.
* gdb.arch/mips-octeon-bbit.exp (single_step): Likewise.
(single_step_until): Likewise.
* gdb.arch/powerpc-d128-regs.exp: Likewise.
* gdb.arch/system-gcore.exp: Likewise.
* gdb.base/bigcore.exp (extract_heap): Likewise.
* gdb.base/break-on-linker-gcd-function.exp: Likewise.
* gdb.base/call-ar-st.exp: Likewise.
* gdb.base/call-rt-st.exp: Likewise.
* gdb.base/call-sc.exp, gdb.base/call-strs.exp: Likewise.
* gdb.base/callfuncs.exp, gdb.base/completion.exp: Likewise.
* gdb.base/condbreak.exp, gdb.base/constvars.exp: Likewise.
* gdb.base/corefile.exp: Likewise.
* gdb.base/dbx.exp (gdb_file_cmd): Likewise.
* gdb.base/exprs.exp, gdb.base/fileio.exp: Likewise.
* gdb.base/fixsection.exp: Likewise.
* gdb.base/funcargs.exp: Likewise.
* gdb.base/gcore-buffer-overflow.exp: Likewise.
* gdb.base/gcore-relro.exp: Likewise.
* gdb.base/gcore.exp, gdb.base/gdb11530.exp: Likewise.
* gdb.base/gdb11531.exp, gdb.base/gnu-ifunc.exp: Likewise.
* gdb.base/info-os.exp, gdb.base/info-proc.exp: Likewise.
* gdb.base/interp.exp, gdb.base/langs.exp:: Likewise.
* gdb.base/list.exp: Likewise.
(set_listsize): Likewise.
* gdb.base/logical.exp, gdb.base/mips_pro.exp: Likewise.
* gdb.base/miscexprs.exp, gdb.base/nodebug.exp: Likewise.
* gdb.base/opaque.exp, gdb.base/pointers.exp: Likewise.
* gdb.base/psymtab.exp, gdb.base/ptype.exp: Likewise.
* gdb.base/relational.exp, gdb.base/scope.exp: Likewise.
* gdb.base/setvar.exp: Likewise.
(test_set): Likewise.
* gdb.base/signals.exp, gdb.base/sizeof.exp: Likewise.
* gdb.base/solib-overlap.exp: Likewise.
* gdb.base/store.exp, gdb.base/structs.exp: Likewise.
* gdb.base/structs2.exp, gdb.base/volatile.exp: Likewise.
* gdb.base/watchpoint.exp (initialize): Likewise.
(test_simple_watchpoint): Likewise.
(test_disabling_watchpoints): Likewise.
(test_watchpoint_triggered_in_syscall): Likewise.
* gdb.base/whatis.exp, gdb.cp/ambiguous.exp: Likewise.
* gdb.cp/casts.exp, gdb.cp/ctti.exp: Likewise.
* gdb.cp/namespace.exp, gdb.cp/nsdecl.exp: Likewise.
* gdb.cp/psmang.exp, gdb.dwarf2/dw2-ranges.exp: Likewise.
* gdb.hp/gdb.aCC/optimize.exp: Likewise.
* gdb.hp/gdb.aCC/watch-cmd.exp: Likewise.
* gdb.hp/gdb.base-hp/callfwmall.exp: Likewise.
* gdb.hp/gdb.base-hp/pxdb.exp: Likewise.
* gdb.hp/gdb.compat/xdb1.exp: Likewise.
* gdb.hp/gdb.compat/xdb2.exp: Likewise.
* gdb.hp/gdb.compat/xdb3.exp: Likewise.
* gdb.hp/gdb.defects/bs14602.exp: Likewise.
* gdb.hp/gdb.defects/solib-d.exp: Likewise.
* gdb.mi/gdb792.exp: Likewise.
* gdb.mi/mi-inheritance-syntax-error.exp: Likewise.
* gdb.mi/mi-logging.exp, gdb.mi/mi-var-cp.exp : Likewise.
* gdb.mi/mi-var-rtti.exp, gdb.python/py-type.exp: Likewise.
* gdb.threads/gcore-thread.exp: Likewise.
(load_core): Likewise.
* gdb.threads/pthreads.exp (all_threads_running): Likewise.
(test_startup, check_control_c): Likewise.
* gdb.threads/sigstep-threads.exp: Likewise.
* gdb.threads/thread_check.exp: Likewise.
* gdb.trace/backtrace.exp, gdb.trace/change-loc.exp: Likewise.
* gdb.trace/circ.exp (run_trace_experiment): Likewise.
(set_a_tracepoint, trace_buffer_normal): Likewise.
(gdb_trace_circular_tests): Likewise.
* gdb.trace/collection.exp: Likewise.
* gdb.trace/disconnected-tracing.exp: Likewise.
* gdb.trace/infotrace.exp: Likewise.
* gdb.trace/mi-traceframe-changed.exp: Likewise.
* gdb.trace/mi-tracepoint-changed.exp: Likewise.
* gdb.trace/mi-tsv-changed.exp (test_create_delete_modify_tsv): Likewise.
* gdb.trace/packetlen.exp, gdb.trace/passc-dyn.exp: Likewise.
* gdb.trace/pending.exp, gdb.trace/report.exp: Likewise.
* gdb.trace/stap-trace.exp: Likewise.
* gdb.trace/status-stop.exp,gdb.trace/strace.exp: Likewise.
* gdb.trace/tfind.exp, gdb.trace/trace-break.exp: Likewise.
* gdb.trace/trace-buffer-size.exp: Likewise.
* gdb.trace/tspeed.exp, gdb.trace/tsv.exp: Likewise.
* gdb.trace/unavailable.exp: Likewise.
* gdb.trace/while-dyn.exp: Likewise.
* lib/fortran.exp (set_lang_fortran): Likewise.
* lib/gdb.exp (default_gdb_version, gdb_start_cmd): Likewise.
(gdb_breakpoint, gdb_reinitialize_dir): Likewise.
(default_gdb_start, get_compiler_info): Likewise.
(gdb_compile, gdb_compile_objc, gdb_reload, gdb_init): Likewise.
(get_debug_format, setup_xfail_format): Likewise.
(rerun_to_main, gdb_skip_float_test): Likewise.
(build_id_debug_filename_get, get_remotetimeout): Likewise.
* lib/java.exp (set_lang_java): Likewise.
* lib/mi-support.exp (default_mi_gdb_start): Likewise.
(mi_gdb_reinitialize_dir, mi_gdb_target_cmd): Likewise.
(mi_gdb_file_cmd, mi_gdb_test): Likewise.
(mi_run_cmd_full, mi_expect_interrupt): Likewise.
* lib/objc.exp (set_lang_objc): Likewise.
* lib/pascal.exp (set_lang_pascal): Likewise.
* lib/prompt.exp (default_prompt_gdb_start): Likewise.
* lib/trace-support.exp (gdb_trace_setactions, gdb_tfind_test): Likewise.
(gdb_readexpr, gdb_gettpnum, gdb_find_recursion_test_baseline): Likewise.
2013-03-14 14:34:06 +01:00
|
|
|
|
return 1
|
1999-04-16 03:35:26 +02:00
|
|
|
|
}
|
Introduce gdb_interact in testsuite
gdb_interact is a small utility that we have found quite useful to debug
test cases.
Putting gdb_interact in a test suspends it and allows to interact with
gdb to inspect whatever you want. You can then type ">>>" to resume the
test execution. Of course, this is only for gdb devs. It wouldn't make
sense to leave a gdb_interact permanently in a test case.
When starting the interaction with the user, the script prints this
banner:
+------------------------------------------+
| Script interrupted, you can now interact |
| with by gdb. Type >>> to continue. |
+------------------------------------------+
Notes:
* When gdb is launched, the gdb_spawn_id variable (lib/gdb.exp) is
assigned -1. Given the name, I would expect it to contain the gdb
expect spawn id, which is needed for interact. I changed all places
that set gdb_spawn_id to -1 to set it to the actual gdb spawn id
instead.
* When entering the "interact" mode, the last (gdb) prompt is already
eaten by expect, so it doesn't show up on the terminal. Subsequent
prompts do appear though. We tried to print "(gdb)" just before the
interact to replace it. However, it could be misleading if you are
debugging an MI test case, it makes you think that you are typing in a
CLI prompt, when in reality it's MI. In the end I decided that since
the feature is for developers who know what they're doing and that one
is normally consciously using gdb_interact, the script doesn't need
to babysit the user.
* There are probably some quirks depending on where in the script
gdb_interact appears (e.g. it could interfere with following
commands and make them fail), but it works for most cases. Quirks can
always be fixed later.
The idea and original implementation was contributed by Anders
Granlund, a colleague of mine. Thanks to him.
gdb/testsuite/ChangeLog:
* gdb.base/statistics.exp: Assign spawn id to gdb_spawn_id.
* gdb.base/valgrind-db-attach.exp: Same.
* gdb.base/valgrind-infcall.exp: Same.
* lib/mi-support.exp (default_mi_gdb_start): Same.
* lib/prompt.exp (default_prompt_gdb_start): Same.
* lib/gdb.exp (default_gdb_spawn): Same.
(gdb_interact): New.
2015-01-22 20:33:04 +01:00
|
|
|
|
|
|
|
|
|
set gdb_spawn_id $res
|
Canceling pagination caused by execution command from command line aborts readline/gdb
This fixes:
$ ./gdb program -ex "set height 2" -ex "start"
...
Reading symbols from /home/pedro/gdb/tests/threads...done.
---Type <return> to continue, or q <return> to quit---^CQuit << ctrl-c triggers a Quit
*type something*
readline: readline_callback_read_char() called with no handler!
Aborted
$
Usually, if an error propagates all the way to the top level, we'll
re-enable stdin, in case the command that was running was a
synchronous command. That's done in the event loop's actual loop
(event-loop.c:start_event_loop). However, if a foreground execution
command is run before the event loop starts and throws, nothing is
presently reenabling stdin, which leaves sync_execution set.
When we do start the event loop, because sync_execution is still
(mistakenly) set, display_gdb_prompt removes the readline input
callback, even though stdin is registered in the event loop. Any
input from here on results in readline aborting.
Such commands are run through catch_command_errors,
catch_command_errors_const, so add the tweak there.
gdb/
2014-07-14 Pedro Alves <palves@redhat.com>
PR gdb/17072
* main.c: Include event-top.h.
(handle_command_errors): New function.
(catch_command_errors, catch_command_errors_const): Use it.
gdb/testsuite/
2014-07-14 Pedro Alves <palves@redhat.com>
PR gdb/17072
* gdb.base/paginate-execution-startup.c: New file.
* gdb.base/paginate-execution-startup.exp: New file.
* lib/gdb.exp (pagination_prompt): New global.
(default_gdb_spawn): New procedure, factored out from
default_gdb_spawn.
(default_gdb_start): Adjust to call default_gdb_spawn.
(gdb_spawn): New procedure.
2014-07-14 20:55:31 +02:00
|
|
|
|
return 0
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# Default gdb_start procedure.
|
|
|
|
|
|
|
|
|
|
proc default_gdb_start { } {
|
Make gdb.base/corefile.exp work on terminals with few rows
When creating a pty to spawn a subprocess (such as gdb), Expect
copies the settings of its own controlling terminal, including the
number of rows and columns. If you "make check" on a terminal with just
a few rows (e.g. 4), GDB will paginate before reaching the initial
prompt. In default_gdb_start, used by most tests, this is already
handled: if we see the pagination prompt, we sent \n to continue.
Philippe reported that gdb.base/corefile.exp didn't work in terminals
with just a few rows. This test spawns GDB by hand, because it needs to
check things before the initial prompt, which it couldn't do if it used
default_gdb_start.
In this case I think it's not safe to use the same technique as in
default_gdb_start. Even if we could send a \n if we see a pagination
prompt, we match some multiline regexes in there. So if a pagination
slips in there, it might make the regexes not match and fail the test.
It's also not possible to use -ex "set height 0" or -iex "set height 0",
it is handled after the introduction text is shown.
The simplest way I found to avoid showing the pagination completely is
to set stty_init (documented in expect's man page) to initialize gdb's
pty with a fixed number of rows.
And actually, if we set stty_init in gdb_init, it works nicely as a
general solution applicable to all tests. We can therefore remove the
solution introduced in e882ef3cfc3 ("testsuite: expect possible
pagination when starting gdb") where we matched the pagination prompt
during startup.
gdb/testsuite/ChangeLog:
* lib/gdb.exp (default_gdb_start): Don't match pagination
prompt.
(gdb_init): Set stty_init.
2019-02-07 15:22:29 +01:00
|
|
|
|
global gdb_prompt
|
Canceling pagination caused by execution command from command line aborts readline/gdb
This fixes:
$ ./gdb program -ex "set height 2" -ex "start"
...
Reading symbols from /home/pedro/gdb/tests/threads...done.
---Type <return> to continue, or q <return> to quit---^CQuit << ctrl-c triggers a Quit
*type something*
readline: readline_callback_read_char() called with no handler!
Aborted
$
Usually, if an error propagates all the way to the top level, we'll
re-enable stdin, in case the command that was running was a
synchronous command. That's done in the event loop's actual loop
(event-loop.c:start_event_loop). However, if a foreground execution
command is run before the event loop starts and throws, nothing is
presently reenabling stdin, which leaves sync_execution set.
When we do start the event loop, because sync_execution is still
(mistakenly) set, display_gdb_prompt removes the readline input
callback, even though stdin is registered in the event loop. Any
input from here on results in readline aborting.
Such commands are run through catch_command_errors,
catch_command_errors_const, so add the tweak there.
gdb/
2014-07-14 Pedro Alves <palves@redhat.com>
PR gdb/17072
* main.c: Include event-top.h.
(handle_command_errors): New function.
(catch_command_errors, catch_command_errors_const): Use it.
gdb/testsuite/
2014-07-14 Pedro Alves <palves@redhat.com>
PR gdb/17072
* gdb.base/paginate-execution-startup.c: New file.
* gdb.base/paginate-execution-startup.exp: New file.
* lib/gdb.exp (pagination_prompt): New global.
(default_gdb_spawn): New procedure, factored out from
default_gdb_spawn.
(default_gdb_start): Adjust to call default_gdb_spawn.
(gdb_spawn): New procedure.
2014-07-14 20:55:31 +02:00
|
|
|
|
global gdb_spawn_id
|
testsuite: Introduce $inferior_spawn_id
Some important tests, like gdb.base/interrupt.exp end up skipped
against gdbserver, because they depend on inferior I/O, which
gdbserver doesn't do.
This patch adds a mechanism that makes it possible to make them work.
It adds a new "inferior_spawn_id" global that is the spawn ID used for
I/O interaction with the inferior. By default, for native targets, or
remote targets that can do I/O through GDB (semi-hosting) this will be
the same as the gdb/host spawn ID. Otherwise, the board may set this
to some other spawn ID. When debugging with GDBserver, this will be
set to GDBserver's spawn ID.
Then tests can use send_inferior instead of send_gdb to send input to
the inferior, and use expect's "-i" switch to select which spawn ID to
use for matching input/output. That is, something like this will now
work:
send_inferior "echo me\n"
gdb_test_multiple "continue" "test msg" {
-i "$inferior_spawn_id" -re "echo me\r\necho\r\n" {
...
}
}
Or even:
gdb_test_multiple "continue" "test msg" {
-i "$inferior_spawn_id" -re "hello world" {
...
}
-i "$gdb_spawn_id" -re "error.*$gdb_prompt $" {
...
}
}
Of course, by default, gdb_test_multiple still matches with
$gdb_spawn_id.
gdb/testsuite/ChangeLog:
2015-04-07 Pedro Alves <palves@redhat.com>
* lib/gdb.exp (inferior_spawn_id): New global.
(gdb_test_multiple): Handle "-i". Reset the spawn id to GDB's
spawn id after processing the user code.
(default_gdb_start): Set inferior_spawn_id.
(send_inferior): New procedure.
* lib/gdbserver-support.exp (gdbserver_start): Set
inferior_spawn_id.
(close_gdbserver, gdb_exit): Unset inferior_spawn_id.
2015-04-07 19:19:30 +02:00
|
|
|
|
global inferior_spawn_id
|
Canceling pagination caused by execution command from command line aborts readline/gdb
This fixes:
$ ./gdb program -ex "set height 2" -ex "start"
...
Reading symbols from /home/pedro/gdb/tests/threads...done.
---Type <return> to continue, or q <return> to quit---^CQuit << ctrl-c triggers a Quit
*type something*
readline: readline_callback_read_char() called with no handler!
Aborted
$
Usually, if an error propagates all the way to the top level, we'll
re-enable stdin, in case the command that was running was a
synchronous command. That's done in the event loop's actual loop
(event-loop.c:start_event_loop). However, if a foreground execution
command is run before the event loop starts and throws, nothing is
presently reenabling stdin, which leaves sync_execution set.
When we do start the event loop, because sync_execution is still
(mistakenly) set, display_gdb_prompt removes the readline input
callback, even though stdin is registered in the event loop. Any
input from here on results in readline aborting.
Such commands are run through catch_command_errors,
catch_command_errors_const, so add the tweak there.
gdb/
2014-07-14 Pedro Alves <palves@redhat.com>
PR gdb/17072
* main.c: Include event-top.h.
(handle_command_errors): New function.
(catch_command_errors, catch_command_errors_const): Use it.
gdb/testsuite/
2014-07-14 Pedro Alves <palves@redhat.com>
PR gdb/17072
* gdb.base/paginate-execution-startup.c: New file.
* gdb.base/paginate-execution-startup.exp: New file.
* lib/gdb.exp (pagination_prompt): New global.
(default_gdb_spawn): New procedure, factored out from
default_gdb_spawn.
(default_gdb_start): Adjust to call default_gdb_spawn.
(gdb_spawn): New procedure.
2014-07-14 20:55:31 +02:00
|
|
|
|
|
|
|
|
|
if [info exists gdb_spawn_id] {
|
|
|
|
|
return 0
|
|
|
|
|
}
|
|
|
|
|
|
2019-05-17 17:30:09 +02:00
|
|
|
|
# Keep track of the number of times GDB has been launched.
|
|
|
|
|
global gdb_instances
|
|
|
|
|
incr gdb_instances
|
|
|
|
|
|
|
|
|
|
gdb_stdin_log_init
|
|
|
|
|
|
Canceling pagination caused by execution command from command line aborts readline/gdb
This fixes:
$ ./gdb program -ex "set height 2" -ex "start"
...
Reading symbols from /home/pedro/gdb/tests/threads...done.
---Type <return> to continue, or q <return> to quit---^CQuit << ctrl-c triggers a Quit
*type something*
readline: readline_callback_read_char() called with no handler!
Aborted
$
Usually, if an error propagates all the way to the top level, we'll
re-enable stdin, in case the command that was running was a
synchronous command. That's done in the event loop's actual loop
(event-loop.c:start_event_loop). However, if a foreground execution
command is run before the event loop starts and throws, nothing is
presently reenabling stdin, which leaves sync_execution set.
When we do start the event loop, because sync_execution is still
(mistakenly) set, display_gdb_prompt removes the readline input
callback, even though stdin is registered in the event loop. Any
input from here on results in readline aborting.
Such commands are run through catch_command_errors,
catch_command_errors_const, so add the tweak there.
gdb/
2014-07-14 Pedro Alves <palves@redhat.com>
PR gdb/17072
* main.c: Include event-top.h.
(handle_command_errors): New function.
(catch_command_errors, catch_command_errors_const): Use it.
gdb/testsuite/
2014-07-14 Pedro Alves <palves@redhat.com>
PR gdb/17072
* gdb.base/paginate-execution-startup.c: New file.
* gdb.base/paginate-execution-startup.exp: New file.
* lib/gdb.exp (pagination_prompt): New global.
(default_gdb_spawn): New procedure, factored out from
default_gdb_spawn.
(default_gdb_start): Adjust to call default_gdb_spawn.
(gdb_spawn): New procedure.
2014-07-14 20:55:31 +02:00
|
|
|
|
set res [gdb_spawn]
|
|
|
|
|
if { $res != 0} {
|
|
|
|
|
return $res
|
|
|
|
|
}
|
|
|
|
|
|
testsuite: Introduce $inferior_spawn_id
Some important tests, like gdb.base/interrupt.exp end up skipped
against gdbserver, because they depend on inferior I/O, which
gdbserver doesn't do.
This patch adds a mechanism that makes it possible to make them work.
It adds a new "inferior_spawn_id" global that is the spawn ID used for
I/O interaction with the inferior. By default, for native targets, or
remote targets that can do I/O through GDB (semi-hosting) this will be
the same as the gdb/host spawn ID. Otherwise, the board may set this
to some other spawn ID. When debugging with GDBserver, this will be
set to GDBserver's spawn ID.
Then tests can use send_inferior instead of send_gdb to send input to
the inferior, and use expect's "-i" switch to select which spawn ID to
use for matching input/output. That is, something like this will now
work:
send_inferior "echo me\n"
gdb_test_multiple "continue" "test msg" {
-i "$inferior_spawn_id" -re "echo me\r\necho\r\n" {
...
}
}
Or even:
gdb_test_multiple "continue" "test msg" {
-i "$inferior_spawn_id" -re "hello world" {
...
}
-i "$gdb_spawn_id" -re "error.*$gdb_prompt $" {
...
}
}
Of course, by default, gdb_test_multiple still matches with
$gdb_spawn_id.
gdb/testsuite/ChangeLog:
2015-04-07 Pedro Alves <palves@redhat.com>
* lib/gdb.exp (inferior_spawn_id): New global.
(gdb_test_multiple): Handle "-i". Reset the spawn id to GDB's
spawn id after processing the user code.
(default_gdb_start): Set inferior_spawn_id.
(send_inferior): New procedure.
* lib/gdbserver-support.exp (gdbserver_start): Set
inferior_spawn_id.
(close_gdbserver, gdb_exit): Unset inferior_spawn_id.
2015-04-07 19:19:30 +02:00
|
|
|
|
# Default to assuming inferior I/O is done on GDB's terminal.
|
|
|
|
|
if {![info exists inferior_spawn_id]} {
|
|
|
|
|
set inferior_spawn_id $gdb_spawn_id
|
|
|
|
|
}
|
|
|
|
|
|
Canceling pagination caused by execution command from command line aborts readline/gdb
This fixes:
$ ./gdb program -ex "set height 2" -ex "start"
...
Reading symbols from /home/pedro/gdb/tests/threads...done.
---Type <return> to continue, or q <return> to quit---^CQuit << ctrl-c triggers a Quit
*type something*
readline: readline_callback_read_char() called with no handler!
Aborted
$
Usually, if an error propagates all the way to the top level, we'll
re-enable stdin, in case the command that was running was a
synchronous command. That's done in the event loop's actual loop
(event-loop.c:start_event_loop). However, if a foreground execution
command is run before the event loop starts and throws, nothing is
presently reenabling stdin, which leaves sync_execution set.
When we do start the event loop, because sync_execution is still
(mistakenly) set, display_gdb_prompt removes the readline input
callback, even though stdin is registered in the event loop. Any
input from here on results in readline aborting.
Such commands are run through catch_command_errors,
catch_command_errors_const, so add the tweak there.
gdb/
2014-07-14 Pedro Alves <palves@redhat.com>
PR gdb/17072
* main.c: Include event-top.h.
(handle_command_errors): New function.
(catch_command_errors, catch_command_errors_const): Use it.
gdb/testsuite/
2014-07-14 Pedro Alves <palves@redhat.com>
PR gdb/17072
* gdb.base/paginate-execution-startup.c: New file.
* gdb.base/paginate-execution-startup.exp: New file.
* lib/gdb.exp (pagination_prompt): New global.
(default_gdb_spawn): New procedure, factored out from
default_gdb_spawn.
(default_gdb_start): Adjust to call default_gdb_spawn.
(gdb_spawn): New procedure.
2014-07-14 20:55:31 +02:00
|
|
|
|
# When running over NFS, particularly if running many simultaneous
|
|
|
|
|
# tests on different hosts all using the same server, things can
|
|
|
|
|
# get really slow. Give gdb at least 3 minutes to start up.
|
Make gdb.base/corefile.exp work on terminals with few rows
When creating a pty to spawn a subprocess (such as gdb), Expect
copies the settings of its own controlling terminal, including the
number of rows and columns. If you "make check" on a terminal with just
a few rows (e.g. 4), GDB will paginate before reaching the initial
prompt. In default_gdb_start, used by most tests, this is already
handled: if we see the pagination prompt, we sent \n to continue.
Philippe reported that gdb.base/corefile.exp didn't work in terminals
with just a few rows. This test spawns GDB by hand, because it needs to
check things before the initial prompt, which it couldn't do if it used
default_gdb_start.
In this case I think it's not safe to use the same technique as in
default_gdb_start. Even if we could send a \n if we see a pagination
prompt, we match some multiline regexes in there. So if a pagination
slips in there, it might make the regexes not match and fail the test.
It's also not possible to use -ex "set height 0" or -iex "set height 0",
it is handled after the introduction text is shown.
The simplest way I found to avoid showing the pagination completely is
to set stty_init (documented in expect's man page) to initialize gdb's
pty with a fixed number of rows.
And actually, if we set stty_init in gdb_init, it works nicely as a
general solution applicable to all tests. We can therefore remove the
solution introduced in e882ef3cfc3 ("testsuite: expect possible
pagination when starting gdb") where we matched the pagination prompt
during startup.
gdb/testsuite/ChangeLog:
* lib/gdb.exp (default_gdb_start): Don't match pagination
prompt.
(gdb_init): Set stty_init.
2019-02-07 15:22:29 +01:00
|
|
|
|
gdb_expect 360 {
|
|
|
|
|
-re "\[\r\n\]$gdb_prompt $" {
|
|
|
|
|
verbose "GDB initialized."
|
|
|
|
|
}
|
|
|
|
|
-re "$gdb_prompt $" {
|
|
|
|
|
perror "GDB never initialized."
|
|
|
|
|
unset gdb_spawn_id
|
|
|
|
|
return -1
|
|
|
|
|
}
|
|
|
|
|
timeout {
|
|
|
|
|
perror "(timeout) GDB never initialized after 10 seconds."
|
|
|
|
|
remote_close host
|
|
|
|
|
unset gdb_spawn_id
|
|
|
|
|
return -1
|
1999-04-16 03:35:26 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
Canceling pagination caused by execution command from command line aborts readline/gdb
This fixes:
$ ./gdb program -ex "set height 2" -ex "start"
...
Reading symbols from /home/pedro/gdb/tests/threads...done.
---Type <return> to continue, or q <return> to quit---^CQuit << ctrl-c triggers a Quit
*type something*
readline: readline_callback_read_char() called with no handler!
Aborted
$
Usually, if an error propagates all the way to the top level, we'll
re-enable stdin, in case the command that was running was a
synchronous command. That's done in the event loop's actual loop
(event-loop.c:start_event_loop). However, if a foreground execution
command is run before the event loop starts and throws, nothing is
presently reenabling stdin, which leaves sync_execution set.
When we do start the event loop, because sync_execution is still
(mistakenly) set, display_gdb_prompt removes the readline input
callback, even though stdin is registered in the event loop. Any
input from here on results in readline aborting.
Such commands are run through catch_command_errors,
catch_command_errors_const, so add the tweak there.
gdb/
2014-07-14 Pedro Alves <palves@redhat.com>
PR gdb/17072
* main.c: Include event-top.h.
(handle_command_errors): New function.
(catch_command_errors, catch_command_errors_const): Use it.
gdb/testsuite/
2014-07-14 Pedro Alves <palves@redhat.com>
PR gdb/17072
* gdb.base/paginate-execution-startup.c: New file.
* gdb.base/paginate-execution-startup.exp: New file.
* lib/gdb.exp (pagination_prompt): New global.
(default_gdb_spawn): New procedure, factored out from
default_gdb_spawn.
(default_gdb_start): Adjust to call default_gdb_spawn.
(gdb_spawn): New procedure.
2014-07-14 20:55:31 +02:00
|
|
|
|
|
1999-04-16 03:35:26 +02:00
|
|
|
|
# force the height to "unlimited", so no pagers get used
|
|
|
|
|
|
|
|
|
|
send_gdb "set height 0\n"
|
|
|
|
|
gdb_expect 10 {
|
|
|
|
|
-re "$gdb_prompt $" {
|
|
|
|
|
verbose "Setting height to 0." 2
|
|
|
|
|
}
|
|
|
|
|
timeout {
|
|
|
|
|
warning "Couldn't set the height to 0"
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
# force the width to "unlimited", so no wraparound occurs
|
|
|
|
|
send_gdb "set width 0\n"
|
|
|
|
|
gdb_expect 10 {
|
|
|
|
|
-re "$gdb_prompt $" {
|
|
|
|
|
verbose "Setting width to 0." 2
|
|
|
|
|
}
|
|
|
|
|
timeout {
|
|
|
|
|
warning "Couldn't set the width to 0."
|
|
|
|
|
}
|
|
|
|
|
}
|
2019-05-17 15:35:23 +02:00
|
|
|
|
|
|
|
|
|
gdb_debug_init
|
gdb/testsuite/
* config/monitor.exp (gdb_target_cmd): Remove semicolon after
'return'.
(gdb_target_monitor, gdb_load): Likewise.
* config/sid.exp (gdb_load): Likewise.
* config/slite.exp (gdb_load): Likewise.
* config/vx.exp (gdb_start, spawn_vxgdb): Likewise.
* gdb.ada/arrayidx.exp, gdb.ada/null_array.exp: Likewise.
* gdb.arch/mips-octeon-bbit.exp (single_step): Likewise.
(single_step_until): Likewise.
* gdb.arch/powerpc-d128-regs.exp: Likewise.
* gdb.arch/system-gcore.exp: Likewise.
* gdb.base/bigcore.exp (extract_heap): Likewise.
* gdb.base/break-on-linker-gcd-function.exp: Likewise.
* gdb.base/call-ar-st.exp: Likewise.
* gdb.base/call-rt-st.exp: Likewise.
* gdb.base/call-sc.exp, gdb.base/call-strs.exp: Likewise.
* gdb.base/callfuncs.exp, gdb.base/completion.exp: Likewise.
* gdb.base/condbreak.exp, gdb.base/constvars.exp: Likewise.
* gdb.base/corefile.exp: Likewise.
* gdb.base/dbx.exp (gdb_file_cmd): Likewise.
* gdb.base/exprs.exp, gdb.base/fileio.exp: Likewise.
* gdb.base/fixsection.exp: Likewise.
* gdb.base/funcargs.exp: Likewise.
* gdb.base/gcore-buffer-overflow.exp: Likewise.
* gdb.base/gcore-relro.exp: Likewise.
* gdb.base/gcore.exp, gdb.base/gdb11530.exp: Likewise.
* gdb.base/gdb11531.exp, gdb.base/gnu-ifunc.exp: Likewise.
* gdb.base/info-os.exp, gdb.base/info-proc.exp: Likewise.
* gdb.base/interp.exp, gdb.base/langs.exp:: Likewise.
* gdb.base/list.exp: Likewise.
(set_listsize): Likewise.
* gdb.base/logical.exp, gdb.base/mips_pro.exp: Likewise.
* gdb.base/miscexprs.exp, gdb.base/nodebug.exp: Likewise.
* gdb.base/opaque.exp, gdb.base/pointers.exp: Likewise.
* gdb.base/psymtab.exp, gdb.base/ptype.exp: Likewise.
* gdb.base/relational.exp, gdb.base/scope.exp: Likewise.
* gdb.base/setvar.exp: Likewise.
(test_set): Likewise.
* gdb.base/signals.exp, gdb.base/sizeof.exp: Likewise.
* gdb.base/solib-overlap.exp: Likewise.
* gdb.base/store.exp, gdb.base/structs.exp: Likewise.
* gdb.base/structs2.exp, gdb.base/volatile.exp: Likewise.
* gdb.base/watchpoint.exp (initialize): Likewise.
(test_simple_watchpoint): Likewise.
(test_disabling_watchpoints): Likewise.
(test_watchpoint_triggered_in_syscall): Likewise.
* gdb.base/whatis.exp, gdb.cp/ambiguous.exp: Likewise.
* gdb.cp/casts.exp, gdb.cp/ctti.exp: Likewise.
* gdb.cp/namespace.exp, gdb.cp/nsdecl.exp: Likewise.
* gdb.cp/psmang.exp, gdb.dwarf2/dw2-ranges.exp: Likewise.
* gdb.hp/gdb.aCC/optimize.exp: Likewise.
* gdb.hp/gdb.aCC/watch-cmd.exp: Likewise.
* gdb.hp/gdb.base-hp/callfwmall.exp: Likewise.
* gdb.hp/gdb.base-hp/pxdb.exp: Likewise.
* gdb.hp/gdb.compat/xdb1.exp: Likewise.
* gdb.hp/gdb.compat/xdb2.exp: Likewise.
* gdb.hp/gdb.compat/xdb3.exp: Likewise.
* gdb.hp/gdb.defects/bs14602.exp: Likewise.
* gdb.hp/gdb.defects/solib-d.exp: Likewise.
* gdb.mi/gdb792.exp: Likewise.
* gdb.mi/mi-inheritance-syntax-error.exp: Likewise.
* gdb.mi/mi-logging.exp, gdb.mi/mi-var-cp.exp : Likewise.
* gdb.mi/mi-var-rtti.exp, gdb.python/py-type.exp: Likewise.
* gdb.threads/gcore-thread.exp: Likewise.
(load_core): Likewise.
* gdb.threads/pthreads.exp (all_threads_running): Likewise.
(test_startup, check_control_c): Likewise.
* gdb.threads/sigstep-threads.exp: Likewise.
* gdb.threads/thread_check.exp: Likewise.
* gdb.trace/backtrace.exp, gdb.trace/change-loc.exp: Likewise.
* gdb.trace/circ.exp (run_trace_experiment): Likewise.
(set_a_tracepoint, trace_buffer_normal): Likewise.
(gdb_trace_circular_tests): Likewise.
* gdb.trace/collection.exp: Likewise.
* gdb.trace/disconnected-tracing.exp: Likewise.
* gdb.trace/infotrace.exp: Likewise.
* gdb.trace/mi-traceframe-changed.exp: Likewise.
* gdb.trace/mi-tracepoint-changed.exp: Likewise.
* gdb.trace/mi-tsv-changed.exp (test_create_delete_modify_tsv): Likewise.
* gdb.trace/packetlen.exp, gdb.trace/passc-dyn.exp: Likewise.
* gdb.trace/pending.exp, gdb.trace/report.exp: Likewise.
* gdb.trace/stap-trace.exp: Likewise.
* gdb.trace/status-stop.exp,gdb.trace/strace.exp: Likewise.
* gdb.trace/tfind.exp, gdb.trace/trace-break.exp: Likewise.
* gdb.trace/trace-buffer-size.exp: Likewise.
* gdb.trace/tspeed.exp, gdb.trace/tsv.exp: Likewise.
* gdb.trace/unavailable.exp: Likewise.
* gdb.trace/while-dyn.exp: Likewise.
* lib/fortran.exp (set_lang_fortran): Likewise.
* lib/gdb.exp (default_gdb_version, gdb_start_cmd): Likewise.
(gdb_breakpoint, gdb_reinitialize_dir): Likewise.
(default_gdb_start, get_compiler_info): Likewise.
(gdb_compile, gdb_compile_objc, gdb_reload, gdb_init): Likewise.
(get_debug_format, setup_xfail_format): Likewise.
(rerun_to_main, gdb_skip_float_test): Likewise.
(build_id_debug_filename_get, get_remotetimeout): Likewise.
* lib/java.exp (set_lang_java): Likewise.
* lib/mi-support.exp (default_mi_gdb_start): Likewise.
(mi_gdb_reinitialize_dir, mi_gdb_target_cmd): Likewise.
(mi_gdb_file_cmd, mi_gdb_test): Likewise.
(mi_run_cmd_full, mi_expect_interrupt): Likewise.
* lib/objc.exp (set_lang_objc): Likewise.
* lib/pascal.exp (set_lang_pascal): Likewise.
* lib/prompt.exp (default_prompt_gdb_start): Likewise.
* lib/trace-support.exp (gdb_trace_setactions, gdb_tfind_test): Likewise.
(gdb_readexpr, gdb_gettpnum, gdb_find_recursion_test_baseline): Likewise.
2013-03-14 14:34:06 +01:00
|
|
|
|
return 0
|
1999-04-16 03:35:26 +02:00
|
|
|
|
}
|
|
|
|
|
|
Introduce gdb_interact in testsuite
gdb_interact is a small utility that we have found quite useful to debug
test cases.
Putting gdb_interact in a test suspends it and allows to interact with
gdb to inspect whatever you want. You can then type ">>>" to resume the
test execution. Of course, this is only for gdb devs. It wouldn't make
sense to leave a gdb_interact permanently in a test case.
When starting the interaction with the user, the script prints this
banner:
+------------------------------------------+
| Script interrupted, you can now interact |
| with by gdb. Type >>> to continue. |
+------------------------------------------+
Notes:
* When gdb is launched, the gdb_spawn_id variable (lib/gdb.exp) is
assigned -1. Given the name, I would expect it to contain the gdb
expect spawn id, which is needed for interact. I changed all places
that set gdb_spawn_id to -1 to set it to the actual gdb spawn id
instead.
* When entering the "interact" mode, the last (gdb) prompt is already
eaten by expect, so it doesn't show up on the terminal. Subsequent
prompts do appear though. We tried to print "(gdb)" just before the
interact to replace it. However, it could be misleading if you are
debugging an MI test case, it makes you think that you are typing in a
CLI prompt, when in reality it's MI. In the end I decided that since
the feature is for developers who know what they're doing and that one
is normally consciously using gdb_interact, the script doesn't need
to babysit the user.
* There are probably some quirks depending on where in the script
gdb_interact appears (e.g. it could interfere with following
commands and make them fail), but it works for most cases. Quirks can
always be fixed later.
The idea and original implementation was contributed by Anders
Granlund, a colleague of mine. Thanks to him.
gdb/testsuite/ChangeLog:
* gdb.base/statistics.exp: Assign spawn id to gdb_spawn_id.
* gdb.base/valgrind-db-attach.exp: Same.
* gdb.base/valgrind-infcall.exp: Same.
* lib/mi-support.exp (default_mi_gdb_start): Same.
* lib/prompt.exp (default_prompt_gdb_start): Same.
* lib/gdb.exp (default_gdb_spawn): Same.
(gdb_interact): New.
2015-01-22 20:33:04 +01:00
|
|
|
|
# Utility procedure to give user control of the gdb prompt in a script. It is
|
|
|
|
|
# meant to be used for debugging test cases, and should not be left in the
|
|
|
|
|
# test cases code.
|
|
|
|
|
|
|
|
|
|
proc gdb_interact { } {
|
|
|
|
|
global gdb_spawn_id
|
|
|
|
|
set spawn_id $gdb_spawn_id
|
|
|
|
|
|
|
|
|
|
send_user "+------------------------------------------+\n"
|
|
|
|
|
send_user "| Script interrupted, you can now interact |\n"
|
|
|
|
|
send_user "| with by gdb. Type >>> to continue. |\n"
|
|
|
|
|
send_user "+------------------------------------------+\n"
|
|
|
|
|
|
|
|
|
|
interact {
|
|
|
|
|
">>>" return
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
* lib/gdb.exp (gdb_compile_test): New.
(skip_ada_tests, skip_java_tests): New.
(gdb_compile): Use gdb_compile_test for f77.
* lib/ada.exp (gdb_compile_ada): Use gdb_compile_test to record result.
* lib/java.exp (compile_java_from_source): Remove runtests check,
use gdb_compile_test to record result.
* gdb.ada/packed_array.exp, gdb.ada/fixed_points.exp,
gdb.ada/exec_changed.exp, gdb.ada/start.exp,
gdb.ada/watch_arg.exp, gdb.ada/null_record.exp,
gdb.ada/array_return.exp, gdb.ada/arrayidx.exp,
gdb.mi/mi-var-child-f.exp, gdb.fortran/types.exp,
gdb.fortran/array-element.exp, gdb.fortran/subarray.exp,
gdb.fortran/derived-type.exp, gdb.fortran/exprs.exp,
gdb.java/jmisc.exp, gdb.java/jmisc1.exp, gdb.java/jprint.exp,
gdb.java/jv-print.exp, gdb.java/jmain.exp: Add language skip,
adjust gdb_compile invocations.
2009-11-10 11:16:10 +01:00
|
|
|
|
# Examine the output of compilation to determine whether compilation
|
|
|
|
|
# failed or not. If it failed determine whether it is due to missing
|
|
|
|
|
# compiler or due to compiler error. Report pass, fail or unsupported
|
|
|
|
|
# as appropriate
|
|
|
|
|
|
|
|
|
|
proc gdb_compile_test {src output} {
|
|
|
|
|
if { $output == "" } {
|
|
|
|
|
pass "compilation [file tail $src]"
|
|
|
|
|
} elseif { [regexp {^[a-zA-Z_0-9]+: Can't find [^ ]+\.$} $output] } {
|
|
|
|
|
unsupported "compilation [file tail $src]"
|
|
|
|
|
} elseif { [regexp {.*: command not found[\r|\n]*$} $output] } {
|
|
|
|
|
unsupported "compilation [file tail $src]"
|
2010-03-19 18:59:37 +01:00
|
|
|
|
} elseif { [regexp {.*: [^\r\n]*compiler not installed[^\r\n]*[\r|\n]*$} $output] } {
|
|
|
|
|
unsupported "compilation [file tail $src]"
|
* lib/gdb.exp (gdb_compile_test): New.
(skip_ada_tests, skip_java_tests): New.
(gdb_compile): Use gdb_compile_test for f77.
* lib/ada.exp (gdb_compile_ada): Use gdb_compile_test to record result.
* lib/java.exp (compile_java_from_source): Remove runtests check,
use gdb_compile_test to record result.
* gdb.ada/packed_array.exp, gdb.ada/fixed_points.exp,
gdb.ada/exec_changed.exp, gdb.ada/start.exp,
gdb.ada/watch_arg.exp, gdb.ada/null_record.exp,
gdb.ada/array_return.exp, gdb.ada/arrayidx.exp,
gdb.mi/mi-var-child-f.exp, gdb.fortran/types.exp,
gdb.fortran/array-element.exp, gdb.fortran/subarray.exp,
gdb.fortran/derived-type.exp, gdb.fortran/exprs.exp,
gdb.java/jmisc.exp, gdb.java/jmisc1.exp, gdb.java/jprint.exp,
gdb.java/jv-print.exp, gdb.java/jmain.exp: Add language skip,
adjust gdb_compile invocations.
2009-11-10 11:16:10 +01:00
|
|
|
|
} else {
|
|
|
|
|
verbose -log "compilation failed: $output" 2
|
|
|
|
|
fail "compilation [file tail $src]"
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
1999-09-09 02:02:17 +02:00
|
|
|
|
# Return a 1 for configurations for which we don't even want to try to
|
|
|
|
|
# test C++.
|
|
|
|
|
|
|
|
|
|
proc skip_cplus_tests {} {
|
|
|
|
|
if { [istarget "h8300-*-*"] } {
|
|
|
|
|
return 1
|
|
|
|
|
}
|
revert 2007-01-11 Nathan Sidwell <nathan@codesourcery.com>
* lib/gdb.exp (gdb_compile_test): New.
(skip_ada_tests, skip_java_tests): New.
(gdb_compile): Use gdb_compile_test for f77.
* lib/ada.exp (gdb_compile_ada): Use gdb_compile_test to record result.
* lib/java.exp (compile_java_from_source): Remove runtests check,
use gdb_compile_test to record result.
* gdb.ada/packed_array.exp, gdb.ada/fixed_points.exp,
gdb.ada/exec_changed.exp, gdb.ada/start.exp,
gdb.ada/watch_arg.exp, gdb.ada/null_record.exp,
gdb.ada/array_return.exp, gdb.ada/arrayidx.exp,
gdb.mi/mi-var-child-f.exp, gdb.fortran/types.exp,
gdb.fortran/array-element.exp, gdb.fortran/subarray.exp,
gdb.fortran/derived-type.exp, gdb.fortran/exprs.exp,
gdb.java/jmisc.exp, gdb.java/jprint.exp,
gdb.java/jv-print.exp, gdb.java/jmain.exp: Add language skip,
adjust gdb_compile invocations.
2007-01-12 12:36:21 +01:00
|
|
|
|
|
2003-02-23 23:11:07 +01:00
|
|
|
|
# The C++ IO streams are too large for HC11/HC12 and are thus not
|
|
|
|
|
# available. The gdb C++ tests use them and don't compile.
|
|
|
|
|
if { [istarget "m6811-*-*"] } {
|
|
|
|
|
return 1
|
|
|
|
|
}
|
|
|
|
|
if { [istarget "m6812-*-*"] } {
|
|
|
|
|
return 1
|
|
|
|
|
}
|
1999-09-09 02:02:17 +02:00
|
|
|
|
return 0
|
|
|
|
|
}
|
|
|
|
|
|
2010-03-12 20:17:01 +01:00
|
|
|
|
# Return a 1 for configurations for which don't have both C++ and the STL.
|
|
|
|
|
|
|
|
|
|
proc skip_stl_tests {} {
|
|
|
|
|
# Symbian supports the C++ language, but the STL is missing
|
|
|
|
|
# (both headers and libraries).
|
|
|
|
|
if { [istarget "arm*-*-symbianelf*"] } {
|
|
|
|
|
return 1
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return [skip_cplus_tests]
|
|
|
|
|
}
|
|
|
|
|
|
2004-08-17 18:33:28 +02:00
|
|
|
|
# Return a 1 if I don't even want to try to test FORTRAN.
|
|
|
|
|
|
|
|
|
|
proc skip_fortran_tests {} {
|
|
|
|
|
return 0
|
|
|
|
|
}
|
|
|
|
|
|
* lib/gdb.exp (gdb_compile_test): New.
(skip_ada_tests, skip_java_tests): New.
(gdb_compile): Use gdb_compile_test for f77.
* lib/ada.exp (gdb_compile_ada): Use gdb_compile_test to record result.
* lib/java.exp (compile_java_from_source): Remove runtests check,
use gdb_compile_test to record result.
* gdb.ada/packed_array.exp, gdb.ada/fixed_points.exp,
gdb.ada/exec_changed.exp, gdb.ada/start.exp,
gdb.ada/watch_arg.exp, gdb.ada/null_record.exp,
gdb.ada/array_return.exp, gdb.ada/arrayidx.exp,
gdb.mi/mi-var-child-f.exp, gdb.fortran/types.exp,
gdb.fortran/array-element.exp, gdb.fortran/subarray.exp,
gdb.fortran/derived-type.exp, gdb.fortran/exprs.exp,
gdb.java/jmisc.exp, gdb.java/jmisc1.exp, gdb.java/jprint.exp,
gdb.java/jv-print.exp, gdb.java/jmain.exp: Add language skip,
adjust gdb_compile invocations.
2009-11-10 11:16:10 +01:00
|
|
|
|
# Return a 1 if I don't even want to try to test ada.
|
|
|
|
|
|
|
|
|
|
proc skip_ada_tests {} {
|
|
|
|
|
return 0
|
|
|
|
|
}
|
|
|
|
|
|
2012-04-25 16:07:23 +02:00
|
|
|
|
# Return a 1 if I don't even want to try to test GO.
|
|
|
|
|
|
|
|
|
|
proc skip_go_tests {} {
|
|
|
|
|
return 0
|
|
|
|
|
}
|
|
|
|
|
|
2014-01-18 17:04:36 +01:00
|
|
|
|
# Return a 1 if I don't even want to try to test D.
|
|
|
|
|
|
|
|
|
|
proc skip_d_tests {} {
|
|
|
|
|
return 0
|
|
|
|
|
}
|
|
|
|
|
|
2016-04-27 03:38:43 +02:00
|
|
|
|
# Return 1 to skip Rust tests, 0 to try them.
|
|
|
|
|
proc skip_rust_tests {} {
|
|
|
|
|
return [expr {![isnative]}]
|
|
|
|
|
}
|
|
|
|
|
|
2010-02-24 12:11:17 +01:00
|
|
|
|
# Return a 1 for configurations that do not support Python scripting.
|
2015-08-18 23:02:03 +02:00
|
|
|
|
# PROMPT_REGEXP is the expected prompt.
|
2010-02-24 12:11:17 +01:00
|
|
|
|
|
2015-08-18 23:02:03 +02:00
|
|
|
|
proc skip_python_tests_prompt { prompt_regexp } {
|
2012-12-10 22:22:21 +01:00
|
|
|
|
global gdb_py_is_py3k
|
|
|
|
|
|
|
|
|
|
gdb_test_multiple "python print ('test')" "verify python support" {
|
2015-08-18 23:02:03 +02:00
|
|
|
|
-re "not supported.*$prompt_regexp" {
|
2010-02-24 12:11:17 +01:00
|
|
|
|
unsupported "Python support is disabled."
|
|
|
|
|
return 1
|
|
|
|
|
}
|
2015-08-18 23:02:03 +02:00
|
|
|
|
-re "$prompt_regexp" {}
|
2019-07-29 11:24:04 +02:00
|
|
|
|
} "$prompt_regexp"
|
2010-02-24 12:11:17 +01:00
|
|
|
|
|
2012-12-10 22:22:21 +01:00
|
|
|
|
gdb_test_multiple "python print (sys.version_info\[0\])" "check if python 3" {
|
2015-08-18 23:02:03 +02:00
|
|
|
|
-re "3.*$prompt_regexp" {
|
2012-12-10 22:22:21 +01:00
|
|
|
|
set gdb_py_is_py3k 1
|
|
|
|
|
}
|
2015-08-18 23:02:03 +02:00
|
|
|
|
-re ".*$prompt_regexp" {
|
2012-12-10 22:22:21 +01:00
|
|
|
|
set gdb_py_is_py3k 0
|
|
|
|
|
}
|
2019-07-29 11:24:04 +02:00
|
|
|
|
} "$prompt_regexp"
|
2012-12-10 22:22:21 +01:00
|
|
|
|
|
2010-02-24 12:11:17 +01:00
|
|
|
|
return 0
|
|
|
|
|
}
|
|
|
|
|
|
2015-08-18 23:02:03 +02:00
|
|
|
|
# Return a 1 for configurations that do not support Python scripting.
|
|
|
|
|
# Note: This also sets various globals that specify which version of Python
|
|
|
|
|
# is in use. See skip_python_tests_prompt.
|
|
|
|
|
|
|
|
|
|
proc skip_python_tests {} {
|
|
|
|
|
global gdb_prompt
|
|
|
|
|
return [skip_python_tests_prompt "$gdb_prompt $"]
|
|
|
|
|
}
|
|
|
|
|
|
2007-05-16 16:21:47 +02:00
|
|
|
|
# Return a 1 if we should skip shared library tests.
|
|
|
|
|
|
|
|
|
|
proc skip_shlib_tests {} {
|
|
|
|
|
# Run the shared library tests on native systems.
|
|
|
|
|
if {[isnative]} {
|
|
|
|
|
return 0
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# An abbreviated list of remote targets where we should be able to
|
|
|
|
|
# run shared library tests.
|
|
|
|
|
if {([istarget *-*-linux*]
|
|
|
|
|
|| [istarget *-*-*bsd*]
|
|
|
|
|
|| [istarget *-*-solaris2*]
|
|
|
|
|
|| [istarget arm*-*-symbianelf*]
|
|
|
|
|
|| [istarget *-*-mingw*]
|
|
|
|
|
|| [istarget *-*-cygwin*]
|
|
|
|
|
|| [istarget *-*-pe*])} {
|
|
|
|
|
return 0
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return 1
|
|
|
|
|
}
|
|
|
|
|
|
2015-03-27 23:52:31 +01:00
|
|
|
|
# Return 1 if we should skip tui related tests.
|
|
|
|
|
|
|
|
|
|
proc skip_tui_tests {} {
|
|
|
|
|
global gdb_prompt
|
|
|
|
|
|
|
|
|
|
gdb_test_multiple "help layout" "verify tui support" {
|
|
|
|
|
-re "Undefined command: \"layout\".*$gdb_prompt $" {
|
|
|
|
|
return 1
|
|
|
|
|
}
|
|
|
|
|
-re "$gdb_prompt $" {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return 0
|
|
|
|
|
}
|
|
|
|
|
|
2012-02-21 22:55:39 +01:00
|
|
|
|
# Test files shall make sure all the test result lines in gdb.sum are
|
|
|
|
|
# unique in a test run, so that comparing the gdb.sum files of two
|
|
|
|
|
# test runs gives correct results. Test files that exercise
|
|
|
|
|
# variations of the same tests more than once, shall prefix the
|
|
|
|
|
# different test invocations with different identifying strings in
|
|
|
|
|
# order to make them unique.
|
|
|
|
|
#
|
|
|
|
|
# About test prefixes:
|
|
|
|
|
#
|
|
|
|
|
# $pf_prefix is the string that dejagnu prints after the result (FAIL,
|
|
|
|
|
# PASS, etc.), and before the test message/name in gdb.sum. E.g., the
|
|
|
|
|
# underlined substring in
|
|
|
|
|
#
|
|
|
|
|
# PASS: gdb.base/mytest.exp: some test
|
|
|
|
|
# ^^^^^^^^^^^^^^^^^^^^
|
|
|
|
|
#
|
|
|
|
|
# is $pf_prefix.
|
|
|
|
|
#
|
|
|
|
|
# The easiest way to adjust the test prefix is to append a test
|
|
|
|
|
# variation prefix to the $pf_prefix, using the with_test_prefix
|
|
|
|
|
# procedure. E.g.,
|
|
|
|
|
#
|
|
|
|
|
# proc do_tests {} {
|
|
|
|
|
# gdb_test ... ... "test foo"
|
|
|
|
|
# gdb_test ... ... "test bar"
|
|
|
|
|
#
|
2012-02-21 23:01:10 +01:00
|
|
|
|
# with_test_prefix "subvariation a" {
|
2012-02-21 22:55:39 +01:00
|
|
|
|
# gdb_test ... ... "test x"
|
|
|
|
|
# }
|
|
|
|
|
#
|
2012-02-21 23:01:10 +01:00
|
|
|
|
# with_test_prefix "subvariation b" {
|
2012-02-21 22:55:39 +01:00
|
|
|
|
# gdb_test ... ... "test x"
|
|
|
|
|
# }
|
|
|
|
|
# }
|
|
|
|
|
#
|
2012-02-21 23:01:10 +01:00
|
|
|
|
# with_test_prefix "variation1" {
|
2012-02-21 22:55:39 +01:00
|
|
|
|
# ...do setup for variation 1...
|
|
|
|
|
# do_tests
|
|
|
|
|
# }
|
|
|
|
|
#
|
2012-02-21 23:01:10 +01:00
|
|
|
|
# with_test_prefix "variation2" {
|
2012-02-21 22:55:39 +01:00
|
|
|
|
# ...do setup for variation 2...
|
|
|
|
|
# do_tests
|
|
|
|
|
# }
|
|
|
|
|
#
|
|
|
|
|
# Results in:
|
|
|
|
|
#
|
|
|
|
|
# PASS: gdb.base/mytest.exp: variation1: test foo
|
|
|
|
|
# PASS: gdb.base/mytest.exp: variation1: test bar
|
|
|
|
|
# PASS: gdb.base/mytest.exp: variation1: subvariation a: test x
|
|
|
|
|
# PASS: gdb.base/mytest.exp: variation1: subvariation b: test x
|
|
|
|
|
# PASS: gdb.base/mytest.exp: variation2: test foo
|
|
|
|
|
# PASS: gdb.base/mytest.exp: variation2: test bar
|
|
|
|
|
# PASS: gdb.base/mytest.exp: variation2: subvariation a: test x
|
|
|
|
|
# PASS: gdb.base/mytest.exp: variation2: subvariation b: test x
|
|
|
|
|
#
|
|
|
|
|
# If for some reason more flexibility is necessary, one can also
|
|
|
|
|
# manipulate the pf_prefix global directly, treating it as a string.
|
|
|
|
|
# E.g.,
|
|
|
|
|
#
|
|
|
|
|
# global pf_prefix
|
|
|
|
|
# set saved_pf_prefix
|
2012-02-21 23:01:10 +01:00
|
|
|
|
# append pf_prefix "${foo}: bar"
|
2012-02-21 22:55:39 +01:00
|
|
|
|
# ... actual tests ...
|
|
|
|
|
# set pf_prefix $saved_pf_prefix
|
|
|
|
|
#
|
|
|
|
|
|
|
|
|
|
# Run BODY in the context of the caller, with the current test prefix
|
2012-02-21 23:01:10 +01:00
|
|
|
|
# (pf_prefix) appended with one space, then PREFIX, and then a colon.
|
|
|
|
|
# Returns the result of BODY.
|
2012-02-21 22:55:39 +01:00
|
|
|
|
#
|
|
|
|
|
proc with_test_prefix { prefix body } {
|
|
|
|
|
global pf_prefix
|
|
|
|
|
|
|
|
|
|
set saved $pf_prefix
|
2012-02-21 23:01:10 +01:00
|
|
|
|
append pf_prefix " " $prefix ":"
|
2012-02-21 22:55:39 +01:00
|
|
|
|
set code [catch {uplevel 1 $body} result]
|
|
|
|
|
set pf_prefix $saved
|
|
|
|
|
|
|
|
|
|
if {$code == 1} {
|
|
|
|
|
global errorInfo errorCode
|
|
|
|
|
return -code $code -errorinfo $errorInfo -errorcode $errorCode $result
|
|
|
|
|
} else {
|
|
|
|
|
return -code $code $result
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-01-25 13:00:18 +01:00
|
|
|
|
# Wrapper for foreach that calls with_test_prefix on each iteration,
|
|
|
|
|
# including the iterator's name and current value in the prefix.
|
|
|
|
|
|
|
|
|
|
proc foreach_with_prefix {var list body} {
|
|
|
|
|
upvar 1 $var myvar
|
|
|
|
|
foreach myvar $list {
|
|
|
|
|
with_test_prefix "$var=$myvar" {
|
2019-07-03 19:05:20 +02:00
|
|
|
|
set code [catch {uplevel 1 $body} result]
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if {$code == 1} {
|
|
|
|
|
global errorInfo errorCode
|
|
|
|
|
return -code $code -errorinfo $errorInfo -errorcode $errorCode $result
|
Fix foreach_with_prefix regression
Fix a silly bug in commit a26c8de0ee93 ("Fix early return in
foreach_with_prefix").
That patch made foreach_with_prefix always return after the first
iteration, making ~10k tests disappear from test runs...
This fixes it, and as penance, adds a testcase that exercises all
kinds of different returns possible (ok, error, return, break,
continue). I've written it with regular "foreach", and then switched
to foreach_with_prefix and made sure we get the same results. I put
the testcase in a new gdb.testsuite/ subdir, since this is exercising
the testsuite harness bits. We can move this elsewhere if people
prefer a different place, but I'm going ahead in order to unbreak the
testsuite ASAP.
gdb/testsuite/ChangeLog:
2019-07-04 Pedro Alves <palves@redhat.com>
* lib/gdb.exp (foreach_with_prefix): Don't return early if
body returned ok(0), break(3) or continue(4).
* gdb.testsuite/foreach_with_prefix.exp: New file.
2019-07-04 17:45:23 +02:00
|
|
|
|
} elseif {$code == 3} {
|
|
|
|
|
break
|
|
|
|
|
} elseif {$code == 2} {
|
2019-07-03 19:05:20 +02:00
|
|
|
|
return -code $code $result
|
2016-01-25 13:00:18 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
gdb/testsuite: Introduce "proc_with_prefix"
While adding new tests to gdb.base/commands.exp, I noticed that the
file includes a bunch of individual testcases split into their own
procedures, and that none have ever been adjusted to use
with_test_prefix. Instead, each gdb_test/gdb_test_multiple/etc
invocation takes care of including the procedure name in the test
message, in order to make sure test messages are unique.
Simon convinced me that using the procedure name as prefix is not that
bad of an idea:
https://sourceware.org/ml/gdb-patches/2016-10/msg00020.html
This commit adds an IMO simpler alternative to
with_test_prefix_procname added by that patch -- a new
"proc_with_prefix" convenience proc that is meant to be used in place
of "proc", and then uses it in commands.exp. Procedures defined with
this automatically run their bodies under with_test_prefix $proc_name.
Here's a sample of the resulting gdb.sum diff:
[...]
-PASS: gdb.base/commands.exp: break factorial #3
-PASS: gdb.base/commands.exp: set value to 5 in test_command_prompt_position
-PASS: gdb.base/commands.exp: if test in test_command_prompt_position
-PASS: gdb.base/commands.exp: > OK in test_command_prompt_position
+PASS: gdb.base/commands.exp: test_command_prompt_position: break factorial
+PASS: gdb.base/commands.exp: test_command_prompt_position: set value to 5
+PASS: gdb.base/commands.exp: test_command_prompt_position: if test
+PASS: gdb.base/commands.exp: test_command_prompt_position: > OK
[...]
gdb/testsuite/ChangeLog:
2016-11-09 Pedro Alves <palves@redhat.com>
* gdb.base/commands.exp (gdbvar_simple_if_test)
(gdbvar_simple_while_test, gdbvar_complex_if_while_test)
(progvar_simple_if_test, progvar_simple_while_test)
(progvar_complex_if_while_test, if_while_breakpoint_command_test)
(infrun_breakpoint_command_test, breakpoint_command_test)
(user_defined_command_test, watchpoint_command_test)
(test_command_prompt_position, deprecated_command_test)
(bp_deleted_in_command, temporary_breakpoint_commands)
(stray_arg0_test, source_file_with_indented_comment)
(recursive_source_test, if_commands_test)
(error_clears_commands_left, redefine_hook_test)
(redefine_backtrace_test): Use proc_with_prefix.
* lib/gdb.exp (proc_with_prefix): New proc.
2016-11-09 16:45:49 +01:00
|
|
|
|
# Like TCL's native proc, but defines a procedure that wraps its body
|
|
|
|
|
# within 'with_test_prefix "$proc_name" { ... }'.
|
|
|
|
|
proc proc_with_prefix {name arguments body} {
|
|
|
|
|
# Define the advertised proc.
|
|
|
|
|
proc $name $arguments [list with_test_prefix $name $body]
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2015-06-19 03:33:26 +02:00
|
|
|
|
# Run BODY in the context of the caller. After BODY is run, the variables
|
|
|
|
|
# listed in VARS will be reset to the values they had before BODY was run.
|
|
|
|
|
#
|
|
|
|
|
# This is useful for providing a scope in which it is safe to temporarily
|
|
|
|
|
# modify global variables, e.g.
|
|
|
|
|
#
|
|
|
|
|
# global INTERNAL_GDBFLAGS
|
|
|
|
|
# global env
|
|
|
|
|
#
|
|
|
|
|
# set foo GDBHISTSIZE
|
|
|
|
|
#
|
|
|
|
|
# save_vars { INTERNAL_GDBFLAGS env($foo) env(HOME) } {
|
|
|
|
|
# append INTERNAL_GDBFLAGS " -nx"
|
|
|
|
|
# unset -nocomplain env(GDBHISTSIZE)
|
|
|
|
|
# gdb_start
|
|
|
|
|
# gdb_test ...
|
|
|
|
|
# }
|
|
|
|
|
#
|
|
|
|
|
# Here, although INTERNAL_GDBFLAGS, env(GDBHISTSIZE) and env(HOME) may be
|
|
|
|
|
# modified inside BODY, this proc guarantees that the modifications will be
|
|
|
|
|
# undone after BODY finishes executing.
|
|
|
|
|
|
|
|
|
|
proc save_vars { vars body } {
|
|
|
|
|
array set saved_scalars { }
|
|
|
|
|
array set saved_arrays { }
|
|
|
|
|
set unset_vars { }
|
|
|
|
|
|
|
|
|
|
foreach var $vars {
|
|
|
|
|
# First evaluate VAR in the context of the caller in case the variable
|
|
|
|
|
# name may be a not-yet-interpolated string like env($foo)
|
|
|
|
|
set var [uplevel 1 list $var]
|
|
|
|
|
|
|
|
|
|
if [uplevel 1 [list info exists $var]] {
|
|
|
|
|
if [uplevel 1 [list array exists $var]] {
|
|
|
|
|
set saved_arrays($var) [uplevel 1 [list array get $var]]
|
|
|
|
|
} else {
|
|
|
|
|
set saved_scalars($var) [uplevel 1 [list set $var]]
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
lappend unset_vars $var
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
set code [catch {uplevel 1 $body} result]
|
|
|
|
|
|
|
|
|
|
foreach {var value} [array get saved_scalars] {
|
|
|
|
|
uplevel 1 [list set $var $value]
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
foreach {var value} [array get saved_arrays] {
|
|
|
|
|
uplevel 1 [list unset $var]
|
|
|
|
|
uplevel 1 [list array set $var $value]
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
foreach var $unset_vars {
|
|
|
|
|
uplevel 1 [list unset -nocomplain $var]
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if {$code == 1} {
|
|
|
|
|
global errorInfo errorCode
|
|
|
|
|
return -code $code -errorinfo $errorInfo -errorcode $errorCode $result
|
|
|
|
|
} else {
|
|
|
|
|
return -code $code $result
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
Make gdbserver work with filename-only binaries
Simon mentioned on IRC that, after the startup-with-shell feature has
been implemented on gdbserver, it is not possible to specify a
filename-only binary, like:
$ gdbserver :1234 a.out
/bin/bash: line 0: exec: a.out: not found
During startup program exited with code 127.
Exiting
This happens on systems where the current directory "." is not listed
in the PATH environment variable. Although including "." in the PATH
variable is a possible workaround, this can be considered a regression
because before startup-with-shell it was possible to use only the
filename (due to reason that gdbserver used "exec*" directly).
The idea of the patch is to verify if the program path provided by the
user (or by the remote protocol) contains a directory separator
character. If it doesn't, it means we're dealing with a filename-only
binary, so we call "gdb_abspath" to properly expand it and transform
it into a full path. Otherwise, we leave the program path untouched.
This mimicks the behaviour seen on GDB (look at "openp" and
"attach_inferior", for example).
I am also submitting a testcase which exercises the scenario described
above. This test requires gdbserver to be executed in a different CWD
than the original, so I also created a helper function, "with_cwd" (on
testsuite/lib/gdb.exp), which takes care of cd'ing into and out of the
specified dir.
Built and regtested on BuildBot, without regressions.
gdb/ChangeLog:
2018-02-28 Sergio Durigan Junior <sergiodj@redhat.com>
Simon Marchi <simon.marchi@polymtl.ca>
* common/common-utils.c: Include "sys/stat.h".
(is_regular_file): Move here from "source.c"; change return
type to "bool".
* common/common-utils.h (is_regular_file): New prototype.
* common/pathstuff.c (contains_dir_separator): New function.
* common/pathstuff.h (contains_dir_separator): New prototype.
* source.c: Don't include "sys/stat.h".
(is_regular_file): Move to "common/common-utils.c".
gdb/gdbserver/ChangeLog:
2018-02-28 Sergio Durigan Junior <sergiodj@redhat.com>
* server.c: Include "filenames.h" and "pathstuff.h".
(program_name): Delete variable.
(program_path): New anonymous class.
(get_exec_wrapper): Use "program_path" instead of
"program_name".
(handle_v_run): Likewise.
(captured_main): Likewise.
(process_serial_event): Likewise.
gdb/testsuite/ChangeLog:
2018-02-28 Sergio Durigan Junior <sergiodj@redhat.com>
* gdb.server/abspath.exp: New file.
* lib/gdb.exp (with_cwd): New procedure.
2018-02-10 00:54:41 +01:00
|
|
|
|
# Run tests in BODY with the current working directory (CWD) set to
|
|
|
|
|
# DIR. When BODY is finished, restore the original CWD. Return the
|
|
|
|
|
# result of BODY.
|
|
|
|
|
#
|
|
|
|
|
# This procedure doesn't check if DIR is a valid directory, so you
|
|
|
|
|
# have to make sure of that.
|
|
|
|
|
|
|
|
|
|
proc with_cwd { dir body } {
|
|
|
|
|
set saved_dir [pwd]
|
|
|
|
|
verbose -log "Switching to directory $dir (saved CWD: $saved_dir)."
|
|
|
|
|
cd $dir
|
|
|
|
|
|
|
|
|
|
set code [catch {uplevel 1 $body} result]
|
|
|
|
|
|
|
|
|
|
verbose -log "Switching back to $saved_dir."
|
|
|
|
|
cd $saved_dir
|
|
|
|
|
|
|
|
|
|
if {$code == 1} {
|
|
|
|
|
global errorInfo errorCode
|
|
|
|
|
return -code $code -errorinfo $errorInfo -errorcode $errorCode $result
|
|
|
|
|
} else {
|
|
|
|
|
return -code $code $result
|
|
|
|
|
}
|
|
|
|
|
}
|
2015-06-19 03:33:26 +02:00
|
|
|
|
|
2013-08-26 16:09:12 +02:00
|
|
|
|
# Run tests in BODY with GDB prompt and variable $gdb_prompt set to
|
|
|
|
|
# PROMPT. When BODY is finished, restore GDB prompt and variable
|
|
|
|
|
# $gdb_prompt.
|
|
|
|
|
# Returns the result of BODY.
|
2014-09-14 00:52:15 +02:00
|
|
|
|
#
|
|
|
|
|
# Notes:
|
|
|
|
|
#
|
|
|
|
|
# 1) If you want to use, for example, "(foo)" as the prompt you must pass it
|
|
|
|
|
# as "(foo)", and not the regexp form "\(foo\)" (expressed as "\\(foo\\)" in
|
|
|
|
|
# TCL). PROMPT is internally converted to a suitable regexp for matching.
|
|
|
|
|
# We do the conversion from "(foo)" to "\(foo\)" here for a few reasons:
|
|
|
|
|
# a) It's more intuitive for callers to pass the plain text form.
|
|
|
|
|
# b) We need two forms of the prompt:
|
|
|
|
|
# - a regexp to use in output matching,
|
|
|
|
|
# - a value to pass to the "set prompt" command.
|
|
|
|
|
# c) It's easier to convert the plain text form to its regexp form.
|
|
|
|
|
#
|
|
|
|
|
# 2) Don't add a trailing space, we do that here.
|
2013-08-26 16:09:12 +02:00
|
|
|
|
|
|
|
|
|
proc with_gdb_prompt { prompt body } {
|
|
|
|
|
global gdb_prompt
|
|
|
|
|
|
2014-09-14 00:52:15 +02:00
|
|
|
|
# Convert "(foo)" to "\(foo\)".
|
|
|
|
|
# We don't use string_to_regexp because while it works today it's not
|
|
|
|
|
# clear it will work tomorrow: the value we need must work as both a
|
|
|
|
|
# regexp *and* as the argument to the "set prompt" command, at least until
|
|
|
|
|
# we start recording both forms separately instead of just $gdb_prompt.
|
|
|
|
|
# The testsuite is pretty-much hardwired to interpret $gdb_prompt as the
|
|
|
|
|
# regexp form.
|
|
|
|
|
regsub -all {[]*+.|()^$\[\\]} $prompt {\\&} prompt
|
|
|
|
|
|
2013-08-26 16:09:12 +02:00
|
|
|
|
set saved $gdb_prompt
|
|
|
|
|
|
2014-09-14 00:52:15 +02:00
|
|
|
|
verbose -log "Setting gdb prompt to \"$prompt \"."
|
2013-08-26 16:09:12 +02:00
|
|
|
|
set gdb_prompt $prompt
|
|
|
|
|
gdb_test_no_output "set prompt $prompt " ""
|
|
|
|
|
|
|
|
|
|
set code [catch {uplevel 1 $body} result]
|
|
|
|
|
|
2014-09-14 00:52:15 +02:00
|
|
|
|
verbose -log "Restoring gdb prompt to \"$saved \"."
|
2013-08-26 16:09:12 +02:00
|
|
|
|
set gdb_prompt $saved
|
|
|
|
|
gdb_test_no_output "set prompt $saved " ""
|
|
|
|
|
|
|
|
|
|
if {$code == 1} {
|
|
|
|
|
global errorInfo errorCode
|
|
|
|
|
return -code $code -errorinfo $errorInfo -errorcode $errorCode $result
|
|
|
|
|
} else {
|
|
|
|
|
return -code $code $result
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
[testsuite] Set target-charset to ascii
Hi,
We find gdb.base/printcmds.exp fails a lot on windows host, like this,
p ctable1[163]
$204 = 163 '£'
(gdb) FAIL: gdb.base/printcmds.exp: p ctable1[163]
however, on linux host,
p ctable1[163]
$205 = 163 '\243'
(gdb) PASS: gdb.base/printcmds.exp: p ctable1[163]
The printing related code is in valprint.c:print_wchar,
if (gdb_iswprint (w) && (!need_escape || (!gdb_iswdigit (w)
&& w != LCST ('8')
&& w != LCST ('9'))))
{
gdb_wchar_t wchar = w;
if (w == gdb_btowc (quoter) || w == LCST ('\\'))
obstack_grow_wstr (output, LCST ("\\"));
obstack_grow (output, &wchar, sizeof (gdb_wchar_t));
}
else
{
// print W in hex or octal digits
}
When I debug gdb on different hosts, I find
on windows host, gdb_iswprint (iswprint) returns true if 'w' is 163.
However, on linux host, iswprint returns false if 'w' is 163. Looks
this difference is caused by the charset. On Linux host,
the target-charset is ANSI_X3.4-1968, while on windows host, the
target-charset is CP1252.
We can see how target-charset affects the output. On linux host,
(gdb) set target-charset ASCII
(gdb) p ctable1[163]
$1 = 163 '\243'
(gdb) set target-charset CP1252
(gdb) p ctable1[163]
$2 = 163 '£'
we can print the pound sign too, and it shows target-charset does
affect the output.
This patch is to set target-charset temporarily to ASCII for some
charset-sensitive tests. Tested on arm-none-eabi and
powerpc-linux-gnu on mingw32 host. More than one hundred fails are
fixed.
gdb/testsuite:
2014-04-17 Yao Qi <yao@codesourcery.com>
* lib/gdb.exp (with_target_charset): New proc.
* gdb.base/printcmds.exp (test_print_all_chars): Wrap tests with
with_target_charset.
(test_print_strings): Likewise.
(test_repeat_bytes): Likewise.
* gdb.base/setvar.exp: Set target-charset to ASCII temporarily
for some tests.
2014-03-24 04:26:06 +01:00
|
|
|
|
# Run tests in BODY with target-charset setting to TARGET_CHARSET. When
|
|
|
|
|
# BODY is finished, restore target-charset.
|
|
|
|
|
|
|
|
|
|
proc with_target_charset { target_charset body } {
|
|
|
|
|
global gdb_prompt
|
|
|
|
|
|
|
|
|
|
set saved ""
|
|
|
|
|
gdb_test_multiple "show target-charset" "" {
|
|
|
|
|
-re "The target character set is \".*; currently (.*)\"\..*$gdb_prompt " {
|
|
|
|
|
set saved $expect_out(1,string)
|
|
|
|
|
}
|
|
|
|
|
-re "The target character set is \"(.*)\".*$gdb_prompt " {
|
|
|
|
|
set saved $expect_out(1,string)
|
|
|
|
|
}
|
|
|
|
|
-re ".*$gdb_prompt " {
|
|
|
|
|
fail "get target-charset"
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
gdb_test_no_output "set target-charset $target_charset" ""
|
|
|
|
|
|
|
|
|
|
set code [catch {uplevel 1 $body} result]
|
|
|
|
|
|
|
|
|
|
gdb_test_no_output "set target-charset $saved" ""
|
|
|
|
|
|
|
|
|
|
if {$code == 1} {
|
|
|
|
|
global errorInfo errorCode
|
|
|
|
|
return -code $code -errorinfo $errorInfo -errorcode $errorCode $result
|
|
|
|
|
} else {
|
|
|
|
|
return -code $code $result
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-06-21 02:11:57 +02:00
|
|
|
|
# Switch the default spawn id to SPAWN_ID, so that gdb_test,
|
|
|
|
|
# mi_gdb_test etc. default to using it.
|
|
|
|
|
|
|
|
|
|
proc switch_gdb_spawn_id {spawn_id} {
|
|
|
|
|
global gdb_spawn_id
|
|
|
|
|
global board board_info
|
|
|
|
|
|
|
|
|
|
set gdb_spawn_id $spawn_id
|
|
|
|
|
set board [host_info name]
|
|
|
|
|
set board_info($board,fileid) $spawn_id
|
|
|
|
|
}
|
|
|
|
|
|
new-ui command: gdb internal errors if input is already pending
I noticed that if input is already pending on the new-ui TTY, gdb
internal-errors.
E.g., create /dev/pts/2, and type anything there (even just <return>
is sufficient).
Now start GDB creating a new UI on that TTY, while at the same time,
running a synchronous execution command. Something like:
$ gdb program -ex "new-ui console /dev/pts/2" -ex "start"
Back on /dev/pts/2, we get:
(gdb) .../src/gdb/event-top.c:360: internal-error: double prompt
A problem internal to GDB has been detected,
further debugging may prove unreliable.
While the main UI was waiting for "start" to finish, gdb kepts pumping
events, including the input fd of the extra console. The problem is
that stdin_event_handler doesn't restore the current UI back to what
it was, assuming that it's only ever called from the top level event
loop. However, in this case, it's being called from the nested event
loop from within maybe_wait_sync_command_done.
When finally the "start" command is done, we reach the code that
prints the prompt in the main UI, just before starting the main event
loop. Since now the current UI is pointing at the extra console (by
mistake), we find ourselves printing a double prompt on the extra
console. This is caught by the assertion that fails, as shown above.
Since other event handlers also don't restore the UI (e.g., signal
event handlers), I think it's better if whatever is pumping events to
take care to restore the UI, if it cares. That's what this patch
does. New test included.
gdb/ChangeLog:
2016-09-06 Pedro Alves <palves@redhat.com>
* top.c (wait_sync_command_done): Don't assume current_ui doesn't
change across events. Restore the current UI before returning.
(gdb_readline_wrapper): Restore the current UI before returning.
gdb/testsuite/ChangeLog:
2016-09-06 Pedro Alves <palves@redhat.com>
* gdb.base/new-ui-pending-input.c: New file.
* gdb.base/new-ui-pending-input.exp: New file.
* gdb.exp (clear_gdb_spawn_id): New procedure.
(with_spawn_id): Check whether gdb_spawn_id exists before
referencing it. If gdb_spawn_id didn't exist on entry, clear it
on exit.
2016-09-07 00:29:25 +02:00
|
|
|
|
# Clear the default spawn id.
|
|
|
|
|
|
|
|
|
|
proc clear_gdb_spawn_id {} {
|
|
|
|
|
global gdb_spawn_id
|
|
|
|
|
global board board_info
|
|
|
|
|
|
|
|
|
|
unset -nocomplain gdb_spawn_id
|
|
|
|
|
set board [host_info name]
|
|
|
|
|
unset -nocomplain board_info($board,fileid)
|
|
|
|
|
}
|
|
|
|
|
|
2016-06-21 02:11:57 +02:00
|
|
|
|
# Run BODY with SPAWN_ID as current spawn id.
|
|
|
|
|
|
|
|
|
|
proc with_spawn_id { spawn_id body } {
|
|
|
|
|
global gdb_spawn_id
|
|
|
|
|
|
new-ui command: gdb internal errors if input is already pending
I noticed that if input is already pending on the new-ui TTY, gdb
internal-errors.
E.g., create /dev/pts/2, and type anything there (even just <return>
is sufficient).
Now start GDB creating a new UI on that TTY, while at the same time,
running a synchronous execution command. Something like:
$ gdb program -ex "new-ui console /dev/pts/2" -ex "start"
Back on /dev/pts/2, we get:
(gdb) .../src/gdb/event-top.c:360: internal-error: double prompt
A problem internal to GDB has been detected,
further debugging may prove unreliable.
While the main UI was waiting for "start" to finish, gdb kepts pumping
events, including the input fd of the extra console. The problem is
that stdin_event_handler doesn't restore the current UI back to what
it was, assuming that it's only ever called from the top level event
loop. However, in this case, it's being called from the nested event
loop from within maybe_wait_sync_command_done.
When finally the "start" command is done, we reach the code that
prints the prompt in the main UI, just before starting the main event
loop. Since now the current UI is pointing at the extra console (by
mistake), we find ourselves printing a double prompt on the extra
console. This is caught by the assertion that fails, as shown above.
Since other event handlers also don't restore the UI (e.g., signal
event handlers), I think it's better if whatever is pumping events to
take care to restore the UI, if it cares. That's what this patch
does. New test included.
gdb/ChangeLog:
2016-09-06 Pedro Alves <palves@redhat.com>
* top.c (wait_sync_command_done): Don't assume current_ui doesn't
change across events. Restore the current UI before returning.
(gdb_readline_wrapper): Restore the current UI before returning.
gdb/testsuite/ChangeLog:
2016-09-06 Pedro Alves <palves@redhat.com>
* gdb.base/new-ui-pending-input.c: New file.
* gdb.base/new-ui-pending-input.exp: New file.
* gdb.exp (clear_gdb_spawn_id): New procedure.
(with_spawn_id): Check whether gdb_spawn_id exists before
referencing it. If gdb_spawn_id didn't exist on entry, clear it
on exit.
2016-09-07 00:29:25 +02:00
|
|
|
|
if [info exists gdb_spawn_id] {
|
|
|
|
|
set saved_spawn_id $gdb_spawn_id
|
|
|
|
|
}
|
|
|
|
|
|
2016-06-21 02:11:57 +02:00
|
|
|
|
switch_gdb_spawn_id $spawn_id
|
|
|
|
|
|
|
|
|
|
set code [catch {uplevel 1 $body} result]
|
|
|
|
|
|
new-ui command: gdb internal errors if input is already pending
I noticed that if input is already pending on the new-ui TTY, gdb
internal-errors.
E.g., create /dev/pts/2, and type anything there (even just <return>
is sufficient).
Now start GDB creating a new UI on that TTY, while at the same time,
running a synchronous execution command. Something like:
$ gdb program -ex "new-ui console /dev/pts/2" -ex "start"
Back on /dev/pts/2, we get:
(gdb) .../src/gdb/event-top.c:360: internal-error: double prompt
A problem internal to GDB has been detected,
further debugging may prove unreliable.
While the main UI was waiting for "start" to finish, gdb kepts pumping
events, including the input fd of the extra console. The problem is
that stdin_event_handler doesn't restore the current UI back to what
it was, assuming that it's only ever called from the top level event
loop. However, in this case, it's being called from the nested event
loop from within maybe_wait_sync_command_done.
When finally the "start" command is done, we reach the code that
prints the prompt in the main UI, just before starting the main event
loop. Since now the current UI is pointing at the extra console (by
mistake), we find ourselves printing a double prompt on the extra
console. This is caught by the assertion that fails, as shown above.
Since other event handlers also don't restore the UI (e.g., signal
event handlers), I think it's better if whatever is pumping events to
take care to restore the UI, if it cares. That's what this patch
does. New test included.
gdb/ChangeLog:
2016-09-06 Pedro Alves <palves@redhat.com>
* top.c (wait_sync_command_done): Don't assume current_ui doesn't
change across events. Restore the current UI before returning.
(gdb_readline_wrapper): Restore the current UI before returning.
gdb/testsuite/ChangeLog:
2016-09-06 Pedro Alves <palves@redhat.com>
* gdb.base/new-ui-pending-input.c: New file.
* gdb.base/new-ui-pending-input.exp: New file.
* gdb.exp (clear_gdb_spawn_id): New procedure.
(with_spawn_id): Check whether gdb_spawn_id exists before
referencing it. If gdb_spawn_id didn't exist on entry, clear it
on exit.
2016-09-07 00:29:25 +02:00
|
|
|
|
if [info exists saved_spawn_id] {
|
|
|
|
|
switch_gdb_spawn_id $saved_spawn_id
|
|
|
|
|
} else {
|
|
|
|
|
clear_gdb_spawn_id
|
|
|
|
|
}
|
2016-06-21 02:11:57 +02:00
|
|
|
|
|
|
|
|
|
if {$code == 1} {
|
|
|
|
|
global errorInfo errorCode
|
|
|
|
|
return -code $code -errorinfo $errorInfo -errorcode $errorCode $result
|
|
|
|
|
} else {
|
|
|
|
|
return -code $code $result
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2015-04-15 13:46:58 +02:00
|
|
|
|
# Select the largest timeout from all the timeouts:
|
|
|
|
|
# - the local "timeout" variable of the scope two levels above,
|
|
|
|
|
# - the global "timeout" variable,
|
|
|
|
|
# - the board variable "gdb,timeout".
|
|
|
|
|
|
|
|
|
|
proc get_largest_timeout {} {
|
|
|
|
|
upvar #0 timeout gtimeout
|
|
|
|
|
upvar 2 timeout timeout
|
|
|
|
|
|
|
|
|
|
set tmt 0
|
|
|
|
|
if [info exists timeout] {
|
|
|
|
|
set tmt $timeout
|
|
|
|
|
}
|
|
|
|
|
if { [info exists gtimeout] && $gtimeout > $tmt } {
|
|
|
|
|
set tmt $gtimeout
|
|
|
|
|
}
|
|
|
|
|
if { [target_info exists gdb,timeout]
|
|
|
|
|
&& [target_info gdb,timeout] > $tmt } {
|
|
|
|
|
set tmt [target_info gdb,timeout]
|
|
|
|
|
}
|
|
|
|
|
if { $tmt == 0 } {
|
|
|
|
|
# Eeeeew.
|
|
|
|
|
set tmt 60
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return $tmt
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# Run tests in BODY with timeout increased by factor of FACTOR. When
|
|
|
|
|
# BODY is finished, restore timeout.
|
|
|
|
|
|
|
|
|
|
proc with_timeout_factor { factor body } {
|
|
|
|
|
global timeout
|
|
|
|
|
|
|
|
|
|
set savedtimeout $timeout
|
|
|
|
|
|
|
|
|
|
set timeout [expr [get_largest_timeout] * $factor]
|
|
|
|
|
set code [catch {uplevel 1 $body} result]
|
|
|
|
|
|
|
|
|
|
set timeout $savedtimeout
|
|
|
|
|
if {$code == 1} {
|
|
|
|
|
global errorInfo errorCode
|
|
|
|
|
return -code $code -errorinfo $errorInfo -errorcode $errorCode $result
|
|
|
|
|
} else {
|
|
|
|
|
return -code $code $result
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2019-08-05 15:41:04 +02:00
|
|
|
|
# Run BODY with timeout factor FACTOR if check-read1 is used.
|
|
|
|
|
|
|
|
|
|
proc with_read1_timeout_factor { factor body } {
|
|
|
|
|
if { [info exists ::env(READ1)] == 1 && $::env(READ1) == 1 } {
|
|
|
|
|
# Use timeout factor
|
|
|
|
|
} else {
|
|
|
|
|
# Reset timeout factor
|
|
|
|
|
set factor 1
|
|
|
|
|
}
|
|
|
|
|
return [uplevel [list with_timeout_factor $factor $body]]
|
|
|
|
|
}
|
|
|
|
|
|
2011-05-30 04:20:16 +02:00
|
|
|
|
# Return 1 if _Complex types are supported, otherwise, return 0.
|
|
|
|
|
|
2013-08-13 17:55:52 +02:00
|
|
|
|
gdb_caching_proc support_complex_tests {
|
2016-10-05 18:04:31 +02:00
|
|
|
|
|
|
|
|
|
if { [gdb_skip_float_test] } {
|
|
|
|
|
# If floating point is not supported, _Complex is not
|
|
|
|
|
# supported.
|
|
|
|
|
return 0
|
|
|
|
|
}
|
|
|
|
|
|
2018-09-12 12:52:09 +02:00
|
|
|
|
# Compile a test program containing _Complex types.
|
2011-05-30 04:20:16 +02:00
|
|
|
|
|
2018-09-12 12:52:09 +02:00
|
|
|
|
return [gdb_can_simple_compile complex {
|
2013-09-24 11:52:27 +02:00
|
|
|
|
int main() {
|
|
|
|
|
_Complex float cf;
|
|
|
|
|
_Complex double cd;
|
|
|
|
|
_Complex long double cld;
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
2018-09-12 12:52:09 +02:00
|
|
|
|
} executable]
|
2011-05-30 04:20:16 +02:00
|
|
|
|
}
|
|
|
|
|
|
2015-06-24 15:53:03 +02:00
|
|
|
|
# Return 1 if GDB can get a type for siginfo from the target, otherwise
|
|
|
|
|
# return 0.
|
|
|
|
|
|
|
|
|
|
proc supports_get_siginfo_type {} {
|
2015-06-24 15:53:03 +02:00
|
|
|
|
if { [istarget "*-*-linux*"] } {
|
2015-06-24 15:53:03 +02:00
|
|
|
|
return 1
|
|
|
|
|
} else {
|
|
|
|
|
return 0
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2015-09-16 16:51:36 +02:00
|
|
|
|
# Return 1 if the target supports hardware single stepping.
|
2011-09-18 04:36:27 +02:00
|
|
|
|
|
2015-09-16 16:51:36 +02:00
|
|
|
|
proc can_hardware_single_step {} {
|
2011-09-18 04:36:27 +02:00
|
|
|
|
|
2011-10-24 15:51:20 +02:00
|
|
|
|
if { [istarget "arm*-*-*"] || [istarget "mips*-*-*"]
|
2014-03-26 10:44:14 +01:00
|
|
|
|
|| [istarget "tic6x-*-*"] || [istarget "sparc*-*-linux*"]
|
|
|
|
|
|| [istarget "nios2-*-*"] } {
|
2011-09-18 04:36:27 +02:00
|
|
|
|
return 0
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return 1
|
|
|
|
|
}
|
|
|
|
|
|
2015-09-16 16:51:36 +02:00
|
|
|
|
# Return 1 if target hardware or OS supports single stepping to signal
|
|
|
|
|
# handler, otherwise, return 0.
|
|
|
|
|
|
|
|
|
|
proc can_single_step_to_signal_handler {} {
|
|
|
|
|
# Targets don't have hardware single step. On these targets, when
|
|
|
|
|
# a signal is delivered during software single step, gdb is unable
|
|
|
|
|
# to determine the next instruction addresses, because start of signal
|
|
|
|
|
# handler is one of them.
|
|
|
|
|
return [can_hardware_single_step]
|
|
|
|
|
}
|
|
|
|
|
|
2011-11-08 09:23:49 +01:00
|
|
|
|
# Return 1 if target supports process record, otherwise return 0.
|
|
|
|
|
|
|
|
|
|
proc supports_process_record {} {
|
|
|
|
|
|
|
|
|
|
if [target_info exists gdb,use_precord] {
|
|
|
|
|
return [target_info gdb,use_precord]
|
|
|
|
|
}
|
|
|
|
|
|
2014-01-09 11:59:55 +01:00
|
|
|
|
if { [istarget "arm*-*-linux*"] || [istarget "x86_64-*-linux*"]
|
2015-01-17 07:30:33 +01:00
|
|
|
|
|| [istarget "i\[34567\]86-*-linux*"]
|
2015-05-11 13:10:56 +02:00
|
|
|
|
|| [istarget "aarch64*-*-linux*"]
|
2015-11-02 17:16:07 +01:00
|
|
|
|
|| [istarget "powerpc*-*-linux*"]
|
|
|
|
|
|| [istarget "s390*-*-linux*"] } {
|
2011-11-08 09:23:49 +01:00
|
|
|
|
return 1
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return 0
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# Return 1 if target supports reverse debugging, otherwise return 0.
|
|
|
|
|
|
|
|
|
|
proc supports_reverse {} {
|
|
|
|
|
|
|
|
|
|
if [target_info exists gdb,can_reverse] {
|
|
|
|
|
return [target_info gdb,can_reverse]
|
|
|
|
|
}
|
|
|
|
|
|
2014-01-09 11:59:55 +01:00
|
|
|
|
if { [istarget "arm*-*-linux*"] || [istarget "x86_64-*-linux*"]
|
2015-01-17 07:30:33 +01:00
|
|
|
|
|| [istarget "i\[34567\]86-*-linux*"]
|
2015-05-11 13:10:56 +02:00
|
|
|
|
|| [istarget "aarch64*-*-linux*"]
|
2015-11-02 17:16:07 +01:00
|
|
|
|
|| [istarget "powerpc*-*-linux*"]
|
|
|
|
|
|| [istarget "s390*-*-linux*"] } {
|
2011-11-08 09:23:49 +01:00
|
|
|
|
return 1
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return 0
|
|
|
|
|
}
|
|
|
|
|
|
2014-03-19 03:16:35 +01:00
|
|
|
|
# Return 1 if readline library is used.
|
|
|
|
|
|
|
|
|
|
proc readline_is_used { } {
|
|
|
|
|
global gdb_prompt
|
|
|
|
|
|
|
|
|
|
gdb_test_multiple "show editing" "" {
|
|
|
|
|
-re ".*Editing of command lines as they are typed is on\..*$gdb_prompt $" {
|
|
|
|
|
return 1
|
|
|
|
|
}
|
|
|
|
|
-re ".*$gdb_prompt $" {
|
|
|
|
|
return 0
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2013-07-17 11:40:12 +02:00
|
|
|
|
# Return 1 if target is ELF.
|
|
|
|
|
gdb_caching_proc is_elf_target {
|
|
|
|
|
set me "is_elf_target"
|
|
|
|
|
|
2018-09-05 11:11:32 +02:00
|
|
|
|
set src { int foo () {return 0;} }
|
|
|
|
|
if {![gdb_simple_compile elf_target $src]} {
|
|
|
|
|
return 0
|
2013-07-17 11:40:12 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
set fp_obj [open $obj "r"]
|
|
|
|
|
fconfigure $fp_obj -translation binary
|
|
|
|
|
set data [read $fp_obj]
|
|
|
|
|
close $fp_obj
|
|
|
|
|
|
|
|
|
|
file delete $obj
|
|
|
|
|
|
|
|
|
|
set ELFMAG "\u007FELF"
|
|
|
|
|
|
|
|
|
|
if {[string compare -length 4 $data $ELFMAG] != 0} {
|
|
|
|
|
verbose "$me: returning 0" 2
|
|
|
|
|
return 0
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
verbose "$me: returning 1" 2
|
|
|
|
|
return 1
|
|
|
|
|
}
|
|
|
|
|
|
2014-08-07 10:09:38 +02:00
|
|
|
|
# Return 1 if the memory at address zero is readable.
|
|
|
|
|
|
|
|
|
|
gdb_caching_proc is_address_zero_readable {
|
|
|
|
|
global gdb_prompt
|
|
|
|
|
|
|
|
|
|
set ret 0
|
|
|
|
|
gdb_test_multiple "x 0" "" {
|
|
|
|
|
-re "Cannot access memory at address 0x0.*$gdb_prompt $" {
|
|
|
|
|
set ret 0
|
|
|
|
|
}
|
|
|
|
|
-re ".*$gdb_prompt $" {
|
|
|
|
|
set ret 1
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return $ret
|
|
|
|
|
}
|
|
|
|
|
|
2013-09-25 05:46:10 +02:00
|
|
|
|
# Produce source file NAME and write SOURCES into it.
|
|
|
|
|
|
|
|
|
|
proc gdb_produce_source { name sources } {
|
|
|
|
|
set index 0
|
|
|
|
|
set f [open $name "w"]
|
|
|
|
|
|
|
|
|
|
puts $f $sources
|
|
|
|
|
close $f
|
|
|
|
|
}
|
|
|
|
|
|
2010-07-12 19:33:15 +02:00
|
|
|
|
# Return 1 if target is ILP32.
|
|
|
|
|
# This cannot be decided simply from looking at the target string,
|
|
|
|
|
# as it might depend on externally passed compiler options like -m64.
|
2013-08-13 17:55:52 +02:00
|
|
|
|
gdb_caching_proc is_ilp32_target {
|
2018-09-12 12:52:09 +02:00
|
|
|
|
return [gdb_can_simple_compile is_ilp32_target {
|
2013-09-24 11:52:27 +02:00
|
|
|
|
int dummy[sizeof (int) == 4
|
|
|
|
|
&& sizeof (void *) == 4
|
|
|
|
|
&& sizeof (long) == 4 ? 1 : -1];
|
2018-09-12 12:52:09 +02:00
|
|
|
|
}]
|
2010-07-12 19:33:15 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# Return 1 if target is LP64.
|
|
|
|
|
# This cannot be decided simply from looking at the target string,
|
|
|
|
|
# as it might depend on externally passed compiler options like -m64.
|
2013-08-13 17:55:52 +02:00
|
|
|
|
gdb_caching_proc is_lp64_target {
|
2018-09-12 12:52:09 +02:00
|
|
|
|
return [gdb_can_simple_compile is_lp64_target {
|
2013-09-24 11:52:27 +02:00
|
|
|
|
int dummy[sizeof (int) == 4
|
|
|
|
|
&& sizeof (void *) == 8
|
|
|
|
|
&& sizeof (long) == 8 ? 1 : -1];
|
2018-09-12 12:52:09 +02:00
|
|
|
|
}]
|
2010-07-12 19:33:15 +02:00
|
|
|
|
}
|
|
|
|
|
|
2013-08-22 16:01:04 +02:00
|
|
|
|
# Return 1 if target has 64 bit addresses.
|
|
|
|
|
# This cannot be decided simply from looking at the target string,
|
|
|
|
|
# as it might depend on externally passed compiler options like -m64.
|
|
|
|
|
gdb_caching_proc is_64_target {
|
2018-09-12 12:52:09 +02:00
|
|
|
|
return [gdb_can_simple_compile is_64_target {
|
2013-09-24 11:52:27 +02:00
|
|
|
|
int function(void) { return 3; }
|
|
|
|
|
int dummy[sizeof (&function) == 8 ? 1 : -1];
|
2018-09-12 12:52:09 +02:00
|
|
|
|
}]
|
2013-08-22 16:01:04 +02:00
|
|
|
|
}
|
|
|
|
|
|
2011-09-08 19:40:54 +02:00
|
|
|
|
# Return 1 if target has x86_64 registers - either amd64 or x32.
|
|
|
|
|
# x32 target identifies as x86_64-*-linux*, therefore it cannot be determined
|
|
|
|
|
# just from the target string.
|
2013-08-13 17:55:52 +02:00
|
|
|
|
gdb_caching_proc is_amd64_regs_target {
|
2011-09-29 17:17:50 +02:00
|
|
|
|
if {![istarget "x86_64-*-*"] && ![istarget "i?86-*"]} {
|
2011-09-08 19:40:54 +02:00
|
|
|
|
return 0
|
|
|
|
|
}
|
|
|
|
|
|
2018-09-26 15:28:28 +02:00
|
|
|
|
return [gdb_can_simple_compile is_amd64_regs_target {
|
|
|
|
|
int main (void) {
|
|
|
|
|
asm ("incq %rax");
|
|
|
|
|
asm ("incq %r15");
|
2011-09-08 19:40:54 +02:00
|
|
|
|
|
2018-09-26 15:28:28 +02:00
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
}]
|
2011-09-08 19:40:54 +02:00
|
|
|
|
}
|
|
|
|
|
|
2011-05-13 19:17:22 +02:00
|
|
|
|
# Return 1 if this target is an x86 or x86-64 with -m32.
|
|
|
|
|
proc is_x86_like_target {} {
|
2011-09-29 17:17:50 +02:00
|
|
|
|
if {![istarget "x86_64-*-*"] && ![istarget i?86-*]} {
|
2011-05-13 19:17:22 +02:00
|
|
|
|
return 0
|
|
|
|
|
}
|
2011-09-08 19:40:54 +02:00
|
|
|
|
return [expr [is_ilp32_target] && ![is_amd64_regs_target]]
|
2011-05-13 19:17:22 +02:00
|
|
|
|
}
|
|
|
|
|
|
2015-07-07 17:58:19 +02:00
|
|
|
|
# Return 1 if this target is an arm or aarch32 on aarch64.
|
|
|
|
|
|
|
|
|
|
gdb_caching_proc is_aarch32_target {
|
|
|
|
|
if { [istarget "arm*-*-*"] } {
|
|
|
|
|
return 1
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if { ![istarget "aarch64*-*-*"] } {
|
|
|
|
|
return 0
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
set list {}
|
|
|
|
|
foreach reg \
|
|
|
|
|
{r0 r1 r2 r3} {
|
|
|
|
|
lappend list "\tmov $reg, $reg"
|
|
|
|
|
}
|
|
|
|
|
|
2018-09-12 12:52:09 +02:00
|
|
|
|
return [gdb_can_simple_compile aarch32 [join $list \n]]
|
2015-07-07 17:58:19 +02:00
|
|
|
|
}
|
|
|
|
|
|
2015-07-07 17:58:20 +02:00
|
|
|
|
# Return 1 if this target is an aarch64, either lp64 or ilp32.
|
|
|
|
|
|
|
|
|
|
proc is_aarch64_target {} {
|
|
|
|
|
if { ![istarget "aarch64*-*-*"] } {
|
|
|
|
|
return 0
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return [expr ![is_aarch32_target]]
|
|
|
|
|
}
|
|
|
|
|
|
2011-06-23 09:46:13 +02:00
|
|
|
|
# Return 1 if displaced stepping is supported on target, otherwise, return 0.
|
|
|
|
|
proc support_displaced_stepping {} {
|
|
|
|
|
|
|
|
|
|
if { [istarget "x86_64-*-linux*"] || [istarget "i\[34567\]86-*-linux*"]
|
|
|
|
|
|| [istarget "arm*-*-linux*"] || [istarget "powerpc-*-linux*"]
|
2015-10-12 12:28:38 +02:00
|
|
|
|
|| [istarget "powerpc64-*-linux*"] || [istarget "s390*-*-*"]
|
|
|
|
|
|| [istarget "aarch64*-*-linux*"] } {
|
2011-06-23 09:46:13 +02:00
|
|
|
|
return 1
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return 0
|
|
|
|
|
}
|
|
|
|
|
|
2005-05-03 02:41:49 +02:00
|
|
|
|
# Run a test on the target to see if it supports vmx hardware. Return 0 if so,
|
|
|
|
|
# 1 if it does not. Based on 'check_vmx_hw_available' from the GCC testsuite.
|
|
|
|
|
|
2013-08-13 17:55:52 +02:00
|
|
|
|
gdb_caching_proc skip_altivec_tests {
|
2011-03-07 17:03:04 +01:00
|
|
|
|
global srcdir subdir gdb_prompt inferior_exited_re
|
2005-05-03 02:41:49 +02:00
|
|
|
|
|
|
|
|
|
set me "skip_altivec_tests"
|
|
|
|
|
|
|
|
|
|
# Some simulators are known to not support VMX instructions.
|
|
|
|
|
if { [istarget powerpc-*-eabi] || [istarget powerpc*-*-eabispe] } {
|
|
|
|
|
verbose "$me: target known to not support VMX, returning 1" 2
|
2013-08-13 17:55:52 +02:00
|
|
|
|
return 1
|
2005-05-03 02:41:49 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# Make sure we have a compiler that understands altivec.
|
2012-06-21 22:46:25 +02:00
|
|
|
|
if [get_compiler_info] {
|
2005-05-03 02:41:49 +02:00
|
|
|
|
warning "Could not get compiler info"
|
|
|
|
|
return 1
|
|
|
|
|
}
|
|
|
|
|
if [test_compiler_info gcc*] {
|
2018-09-05 11:11:32 +02:00
|
|
|
|
set compile_flags "additional_flags=-maltivec"
|
2005-05-03 02:41:49 +02:00
|
|
|
|
} elseif [test_compiler_info xlc*] {
|
2018-09-05 11:11:32 +02:00
|
|
|
|
set compile_flags "additional_flags=-qaltivec"
|
2005-05-03 02:41:49 +02:00
|
|
|
|
} else {
|
|
|
|
|
verbose "Could not compile with altivec support, returning 1" 2
|
|
|
|
|
return 1
|
|
|
|
|
}
|
|
|
|
|
|
2018-09-05 11:11:32 +02:00
|
|
|
|
# Compile a test program containing VMX instructions.
|
|
|
|
|
set src {
|
2013-09-24 11:52:27 +02:00
|
|
|
|
int main() {
|
|
|
|
|
#ifdef __MACH__
|
|
|
|
|
asm volatile ("vor v0,v0,v0");
|
|
|
|
|
#else
|
|
|
|
|
asm volatile ("vor 0,0,0");
|
|
|
|
|
#endif
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
2018-09-05 11:11:32 +02:00
|
|
|
|
if {![gdb_simple_compile $me $src executable $compile_flags]} {
|
2013-08-13 17:55:52 +02:00
|
|
|
|
return 1
|
2005-05-03 02:41:49 +02:00
|
|
|
|
}
|
|
|
|
|
|
2018-09-05 11:11:32 +02:00
|
|
|
|
# Compilation succeeded so now run it via gdb.
|
2005-05-03 02:41:49 +02:00
|
|
|
|
|
|
|
|
|
gdb_exit
|
|
|
|
|
gdb_start
|
|
|
|
|
gdb_reinitialize_dir $srcdir/$subdir
|
2018-09-05 11:11:32 +02:00
|
|
|
|
gdb_load "$obj"
|
2005-05-03 02:41:49 +02:00
|
|
|
|
gdb_run_cmd
|
|
|
|
|
gdb_expect {
|
|
|
|
|
-re ".*Illegal instruction.*${gdb_prompt} $" {
|
|
|
|
|
verbose -log "\n$me altivec hardware not detected"
|
2013-08-13 17:55:52 +02:00
|
|
|
|
set skip_vmx_tests 1
|
2005-05-03 02:41:49 +02:00
|
|
|
|
}
|
2011-03-07 17:03:04 +01:00
|
|
|
|
-re ".*$inferior_exited_re normally.*${gdb_prompt} $" {
|
2005-05-03 02:41:49 +02:00
|
|
|
|
verbose -log "\n$me: altivec hardware detected"
|
2013-08-13 17:55:52 +02:00
|
|
|
|
set skip_vmx_tests 0
|
2005-05-03 02:41:49 +02:00
|
|
|
|
}
|
|
|
|
|
default {
|
|
|
|
|
warning "\n$me: default case taken"
|
2013-08-13 17:55:52 +02:00
|
|
|
|
set skip_vmx_tests 1
|
2005-05-03 02:41:49 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
gdb_exit
|
2018-09-05 11:11:32 +02:00
|
|
|
|
remote_file build delete $obj
|
2005-05-03 02:41:49 +02:00
|
|
|
|
|
2013-08-13 17:55:52 +02:00
|
|
|
|
verbose "$me: returning $skip_vmx_tests" 2
|
|
|
|
|
return $skip_vmx_tests
|
2005-05-03 02:41:49 +02:00
|
|
|
|
}
|
|
|
|
|
|
2008-08-15 17:18:34 +02:00
|
|
|
|
# Run a test on the target to see if it supports vmx hardware. Return 0 if so,
|
|
|
|
|
# 1 if it does not. Based on 'check_vmx_hw_available' from the GCC testsuite.
|
|
|
|
|
|
2013-08-13 17:55:52 +02:00
|
|
|
|
gdb_caching_proc skip_vsx_tests {
|
2011-03-07 17:03:04 +01:00
|
|
|
|
global srcdir subdir gdb_prompt inferior_exited_re
|
2008-08-15 17:18:34 +02:00
|
|
|
|
|
|
|
|
|
set me "skip_vsx_tests"
|
|
|
|
|
|
|
|
|
|
# Some simulators are known to not support Altivec instructions, so
|
|
|
|
|
# they won't support VSX instructions as well.
|
|
|
|
|
if { [istarget powerpc-*-eabi] || [istarget powerpc*-*-eabispe] } {
|
|
|
|
|
verbose "$me: target known to not support VSX, returning 1" 2
|
2013-08-13 17:55:52 +02:00
|
|
|
|
return 1
|
2008-08-15 17:18:34 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# Make sure we have a compiler that understands altivec.
|
2012-06-21 22:46:25 +02:00
|
|
|
|
if [get_compiler_info] {
|
2008-08-15 17:18:34 +02:00
|
|
|
|
warning "Could not get compiler info"
|
|
|
|
|
return 1
|
|
|
|
|
}
|
|
|
|
|
if [test_compiler_info gcc*] {
|
2018-09-05 11:11:32 +02:00
|
|
|
|
set compile_flags "additional_flags=-mvsx"
|
2008-08-15 17:18:34 +02:00
|
|
|
|
} elseif [test_compiler_info xlc*] {
|
2018-09-05 11:11:32 +02:00
|
|
|
|
set compile_flags "additional_flags=-qasm=gcc"
|
2008-08-15 17:18:34 +02:00
|
|
|
|
} else {
|
|
|
|
|
verbose "Could not compile with vsx support, returning 1" 2
|
|
|
|
|
return 1
|
|
|
|
|
}
|
|
|
|
|
|
2018-09-05 11:11:32 +02:00
|
|
|
|
# Compile a test program containing VSX instructions.
|
|
|
|
|
set src {
|
2013-09-24 11:52:27 +02:00
|
|
|
|
int main() {
|
|
|
|
|
double a[2] = { 1.0, 2.0 };
|
|
|
|
|
#ifdef __MACH__
|
|
|
|
|
asm volatile ("lxvd2x v0,v0,%[addr]" : : [addr] "r" (a));
|
|
|
|
|
#else
|
|
|
|
|
asm volatile ("lxvd2x 0,0,%[addr]" : : [addr] "r" (a));
|
|
|
|
|
#endif
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
2018-09-05 11:11:32 +02:00
|
|
|
|
if {![gdb_simple_compile $me $src executable $compile_flags]} {
|
2013-08-13 17:55:52 +02:00
|
|
|
|
return 1
|
2008-08-15 17:18:34 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# No error message, compilation succeeded so now run it via gdb.
|
|
|
|
|
|
|
|
|
|
gdb_exit
|
|
|
|
|
gdb_start
|
|
|
|
|
gdb_reinitialize_dir $srcdir/$subdir
|
2018-09-05 11:11:32 +02:00
|
|
|
|
gdb_load "$obj"
|
2008-08-15 17:18:34 +02:00
|
|
|
|
gdb_run_cmd
|
|
|
|
|
gdb_expect {
|
|
|
|
|
-re ".*Illegal instruction.*${gdb_prompt} $" {
|
|
|
|
|
verbose -log "\n$me VSX hardware not detected"
|
2013-08-13 17:55:52 +02:00
|
|
|
|
set skip_vsx_tests 1
|
2008-08-15 17:18:34 +02:00
|
|
|
|
}
|
2011-03-07 17:03:04 +01:00
|
|
|
|
-re ".*$inferior_exited_re normally.*${gdb_prompt} $" {
|
2008-08-15 17:18:34 +02:00
|
|
|
|
verbose -log "\n$me: VSX hardware detected"
|
2013-08-13 17:55:52 +02:00
|
|
|
|
set skip_vsx_tests 0
|
2008-08-15 17:18:34 +02:00
|
|
|
|
}
|
|
|
|
|
default {
|
|
|
|
|
warning "\n$me: default case taken"
|
2013-08-13 17:55:52 +02:00
|
|
|
|
set skip_vsx_tests 1
|
2008-08-15 17:18:34 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
gdb_exit
|
2018-09-05 11:11:32 +02:00
|
|
|
|
remote_file build delete $obj
|
2008-08-15 17:18:34 +02:00
|
|
|
|
|
2013-08-13 17:55:52 +02:00
|
|
|
|
verbose "$me: returning $skip_vsx_tests" 2
|
|
|
|
|
return $skip_vsx_tests
|
2008-08-15 17:18:34 +02:00
|
|
|
|
}
|
|
|
|
|
|
2014-03-19 13:49:58 +01:00
|
|
|
|
# Run a test on the target to see if it supports TSX hardware. Return 0 if so,
|
|
|
|
|
# 1 if it does not. Based on 'check_vmx_hw_available' from the GCC testsuite.
|
|
|
|
|
|
|
|
|
|
gdb_caching_proc skip_tsx_tests {
|
|
|
|
|
global srcdir subdir gdb_prompt inferior_exited_re
|
|
|
|
|
|
|
|
|
|
set me "skip_tsx_tests"
|
|
|
|
|
|
2018-09-05 11:11:32 +02:00
|
|
|
|
# Compile a test program.
|
|
|
|
|
set src {
|
|
|
|
|
int main() {
|
|
|
|
|
asm volatile ("xbegin .L0");
|
|
|
|
|
asm volatile ("xend");
|
|
|
|
|
asm volatile (".L0: nop");
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
2014-03-19 13:49:58 +01:00
|
|
|
|
}
|
2018-09-05 11:11:32 +02:00
|
|
|
|
if {![gdb_simple_compile $me $src executable]} {
|
2014-03-19 13:49:58 +01:00
|
|
|
|
return 1
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# No error message, compilation succeeded so now run it via gdb.
|
|
|
|
|
|
|
|
|
|
gdb_exit
|
|
|
|
|
gdb_start
|
|
|
|
|
gdb_reinitialize_dir $srcdir/$subdir
|
2018-09-05 11:11:32 +02:00
|
|
|
|
gdb_load "$obj"
|
2014-03-19 13:49:58 +01:00
|
|
|
|
gdb_run_cmd
|
|
|
|
|
gdb_expect {
|
|
|
|
|
-re ".*Illegal instruction.*${gdb_prompt} $" {
|
|
|
|
|
verbose -log "$me: TSX hardware not detected."
|
|
|
|
|
set skip_tsx_tests 1
|
|
|
|
|
}
|
|
|
|
|
-re ".*$inferior_exited_re normally.*${gdb_prompt} $" {
|
|
|
|
|
verbose -log "$me: TSX hardware detected."
|
|
|
|
|
set skip_tsx_tests 0
|
|
|
|
|
}
|
|
|
|
|
default {
|
|
|
|
|
warning "\n$me: default case taken."
|
|
|
|
|
set skip_tsx_tests 1
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
gdb_exit
|
2018-09-05 11:11:32 +02:00
|
|
|
|
remote_file build delete $obj
|
2014-03-19 13:49:58 +01:00
|
|
|
|
|
|
|
|
|
verbose "$me: returning $skip_tsx_tests" 2
|
|
|
|
|
return $skip_tsx_tests
|
|
|
|
|
}
|
|
|
|
|
|
2013-03-11 09:59:00 +01:00
|
|
|
|
# Run a test on the target to see if it supports btrace hardware. Return 0 if so,
|
|
|
|
|
# 1 if it does not. Based on 'check_vmx_hw_available' from the GCC testsuite.
|
|
|
|
|
|
2013-08-22 15:59:55 +02:00
|
|
|
|
gdb_caching_proc skip_btrace_tests {
|
2013-03-11 09:59:00 +01:00
|
|
|
|
global srcdir subdir gdb_prompt inferior_exited_re
|
|
|
|
|
|
|
|
|
|
set me "skip_btrace_tests"
|
|
|
|
|
if { ![istarget "i?86-*-*"] && ![istarget "x86_64-*-*"] } {
|
|
|
|
|
verbose "$me: target does not support btrace, returning 1" 2
|
2013-08-22 15:59:55 +02:00
|
|
|
|
return 1
|
2013-03-11 09:59:00 +01:00
|
|
|
|
}
|
|
|
|
|
|
2018-09-05 11:11:32 +02:00
|
|
|
|
# Compile a test program.
|
|
|
|
|
set src { int main() { return 0; } }
|
|
|
|
|
if {![gdb_simple_compile $me $src executable]} {
|
2019-11-18 19:08:50 +01:00
|
|
|
|
return 1
|
2013-03-11 09:59:00 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# No error message, compilation succeeded so now run it via gdb.
|
|
|
|
|
|
2013-08-22 15:59:55 +02:00
|
|
|
|
gdb_exit
|
|
|
|
|
gdb_start
|
|
|
|
|
gdb_reinitialize_dir $srcdir/$subdir
|
2018-09-05 11:11:32 +02:00
|
|
|
|
gdb_load $obj
|
2013-03-11 09:59:00 +01:00
|
|
|
|
if ![runto_main] {
|
2013-08-22 15:59:55 +02:00
|
|
|
|
return 1
|
2013-03-11 09:59:00 +01:00
|
|
|
|
}
|
|
|
|
|
# In case of an unexpected output, we return 2 as a fail value.
|
2013-08-22 15:59:55 +02:00
|
|
|
|
set skip_btrace_tests 2
|
2013-03-11 09:59:00 +01:00
|
|
|
|
gdb_test_multiple "record btrace" "check btrace support" {
|
|
|
|
|
-re "You can't do that when your target is.*\r\n$gdb_prompt $" {
|
2013-08-22 15:59:55 +02:00
|
|
|
|
set skip_btrace_tests 1
|
2013-03-11 09:59:00 +01:00
|
|
|
|
}
|
|
|
|
|
-re "Target does not support branch tracing.*\r\n$gdb_prompt $" {
|
2013-08-22 15:59:55 +02:00
|
|
|
|
set skip_btrace_tests 1
|
2013-03-11 09:59:00 +01:00
|
|
|
|
}
|
|
|
|
|
-re "Could not enable branch tracing.*\r\n$gdb_prompt $" {
|
2013-08-22 15:59:55 +02:00
|
|
|
|
set skip_btrace_tests 1
|
2013-03-11 09:59:00 +01:00
|
|
|
|
}
|
|
|
|
|
-re "^record btrace\r\n$gdb_prompt $" {
|
2013-08-22 15:59:55 +02:00
|
|
|
|
set skip_btrace_tests 0
|
2013-03-11 09:59:00 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
gdb_exit
|
2018-09-05 11:11:32 +02:00
|
|
|
|
remote_file build delete $obj
|
2013-03-11 09:59:00 +01:00
|
|
|
|
|
2013-08-22 15:59:55 +02:00
|
|
|
|
verbose "$me: returning $skip_btrace_tests" 2
|
|
|
|
|
return $skip_btrace_tests
|
2013-03-11 09:59:00 +01:00
|
|
|
|
}
|
|
|
|
|
|
2014-03-19 13:49:58 +01:00
|
|
|
|
# Run a test on the target to see if it supports btrace pt hardware.
|
|
|
|
|
# Return 0 if so, 1 if it does not. Based on 'check_vmx_hw_available'
|
|
|
|
|
# from the GCC testsuite.
|
|
|
|
|
|
|
|
|
|
gdb_caching_proc skip_btrace_pt_tests {
|
|
|
|
|
global srcdir subdir gdb_prompt inferior_exited_re
|
|
|
|
|
|
|
|
|
|
set me "skip_btrace_tests"
|
|
|
|
|
if { ![istarget "i?86-*-*"] && ![istarget "x86_64-*-*"] } {
|
|
|
|
|
verbose "$me: target does not support btrace, returning 1" 2
|
|
|
|
|
return 1
|
|
|
|
|
}
|
|
|
|
|
|
2018-09-05 11:11:32 +02:00
|
|
|
|
# Compile a test program.
|
|
|
|
|
set src { int main() { return 0; } }
|
|
|
|
|
if {![gdb_simple_compile $me $src executable]} {
|
2019-11-18 19:08:50 +01:00
|
|
|
|
return 1
|
2014-03-19 13:49:58 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# No error message, compilation succeeded so now run it via gdb.
|
|
|
|
|
|
|
|
|
|
gdb_exit
|
|
|
|
|
gdb_start
|
|
|
|
|
gdb_reinitialize_dir $srcdir/$subdir
|
2018-09-05 11:11:32 +02:00
|
|
|
|
gdb_load $obj
|
2014-03-19 13:49:58 +01:00
|
|
|
|
if ![runto_main] {
|
|
|
|
|
return 1
|
|
|
|
|
}
|
|
|
|
|
# In case of an unexpected output, we return 2 as a fail value.
|
|
|
|
|
set skip_btrace_tests 2
|
2018-02-08 14:35:44 +01:00
|
|
|
|
gdb_test_multiple "record btrace pt" "check btrace pt support" {
|
2014-03-19 13:49:58 +01:00
|
|
|
|
-re "You can't do that when your target is.*\r\n$gdb_prompt $" {
|
|
|
|
|
set skip_btrace_tests 1
|
|
|
|
|
}
|
|
|
|
|
-re "Target does not support branch tracing.*\r\n$gdb_prompt $" {
|
|
|
|
|
set skip_btrace_tests 1
|
|
|
|
|
}
|
|
|
|
|
-re "Could not enable branch tracing.*\r\n$gdb_prompt $" {
|
|
|
|
|
set skip_btrace_tests 1
|
|
|
|
|
}
|
2018-02-08 14:35:44 +01:00
|
|
|
|
-re "support was disabled at compile time.*\r\n$gdb_prompt $" {
|
2015-11-19 14:33:41 +01:00
|
|
|
|
set skip_btrace_tests 1
|
|
|
|
|
}
|
2014-03-19 13:49:58 +01:00
|
|
|
|
-re "^record btrace pt\r\n$gdb_prompt $" {
|
|
|
|
|
set skip_btrace_tests 0
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
gdb_exit
|
2018-09-05 11:11:32 +02:00
|
|
|
|
remote_file build delete $obj
|
2014-03-19 13:49:58 +01:00
|
|
|
|
|
|
|
|
|
verbose "$me: returning $skip_btrace_tests" 2
|
|
|
|
|
return $skip_btrace_tests
|
|
|
|
|
}
|
|
|
|
|
|
2018-08-24 11:33:10 +02:00
|
|
|
|
# Run a test on the target to see if it supports Aarch64 SVE hardware.
|
|
|
|
|
# Return 0 if so, 1 if it does not. Note this causes a restart of GDB.
|
|
|
|
|
|
|
|
|
|
gdb_caching_proc skip_aarch64_sve_tests {
|
|
|
|
|
global srcdir subdir gdb_prompt inferior_exited_re
|
|
|
|
|
|
|
|
|
|
set me "skip_aarch64_sve_tests"
|
|
|
|
|
|
|
|
|
|
if { ![is_aarch64_target]} {
|
|
|
|
|
return 1
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
set compile_flags "{additional_flags=-march=armv8-a+sve}"
|
|
|
|
|
|
|
|
|
|
# Compile a test program containing SVE instructions.
|
|
|
|
|
set src {
|
|
|
|
|
int main() {
|
|
|
|
|
asm volatile ("ptrue p0.b");
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if {![gdb_simple_compile $me $src executable $compile_flags]} {
|
|
|
|
|
return 1
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# Compilation succeeded so now run it via gdb.
|
|
|
|
|
clean_restart $obj
|
|
|
|
|
gdb_run_cmd
|
|
|
|
|
gdb_expect {
|
|
|
|
|
-re ".*Illegal instruction.*${gdb_prompt} $" {
|
|
|
|
|
verbose -log "\n$me sve hardware not detected"
|
|
|
|
|
set skip_sve_tests 1
|
|
|
|
|
}
|
|
|
|
|
-re ".*$inferior_exited_re normally.*${gdb_prompt} $" {
|
|
|
|
|
verbose -log "\n$me: sve hardware detected"
|
|
|
|
|
set skip_sve_tests 0
|
|
|
|
|
}
|
|
|
|
|
default {
|
|
|
|
|
warning "\n$me: default case taken"
|
|
|
|
|
set skip_sve_tests 1
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
gdb_exit
|
|
|
|
|
remote_file build delete $obj
|
|
|
|
|
|
|
|
|
|
verbose "$me: returning $skip_sve_tests" 2
|
|
|
|
|
return $skip_sve_tests
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2018-04-20 21:40:29 +02:00
|
|
|
|
# A helper that compiles a test case to see if __int128 is supported.
|
|
|
|
|
proc gdb_int128_helper {lang} {
|
2018-09-12 12:52:09 +02:00
|
|
|
|
return [gdb_can_simple_compile "i128-for-$lang" {
|
2018-04-20 21:40:29 +02:00
|
|
|
|
__int128 x;
|
|
|
|
|
int main() { return 0; }
|
2018-09-12 12:52:09 +02:00
|
|
|
|
} executable $lang]
|
2018-04-20 21:40:29 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# Return true if the C compiler understands the __int128 type.
|
|
|
|
|
gdb_caching_proc has_int128_c {
|
|
|
|
|
return [gdb_int128_helper c]
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# Return true if the C++ compiler understands the __int128 type.
|
|
|
|
|
gdb_caching_proc has_int128_cxx {
|
|
|
|
|
return [gdb_int128_helper c++]
|
|
|
|
|
}
|
|
|
|
|
|
2018-10-03 18:16:53 +02:00
|
|
|
|
# Return true if the IFUNC feature is unsupported.
|
|
|
|
|
gdb_caching_proc skip_ifunc_tests {
|
|
|
|
|
if [gdb_can_simple_compile ifunc {
|
|
|
|
|
extern void f_ ();
|
|
|
|
|
typedef void F (void);
|
|
|
|
|
F* g (void) { return &f_; }
|
|
|
|
|
void f () __attribute__ ((ifunc ("g")));
|
|
|
|
|
} object] {
|
|
|
|
|
return 0
|
|
|
|
|
} else {
|
|
|
|
|
return 1
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
gdb/
* NEWS: Document inlined function support.
* Makefile.in (SFILES): Add inline-frame.c.
(COMMON_OBS): Add inline-frame.o.
* block.c (contained_in): Rewrite to use lexical nesting.
(block_linkage_function): Skip inlined function blocks.
(block_inlined_p): New.
* block.h (struct block): Update comment.
(block_inlined_p): New prototype.
* blockframe.c (get_frame_block): Handle inlined functions.
(get_frame_function): Do not use block_linkage_function.
(block_innermost_frame): Use get_frame_block and contained_in.
* breakpoint.c (watchpoint_check): Remove extra reinit_frame_cache.
Skip over inlined functions. Simplify epilogue check.
(bpstat_check_breakpoint_conditions): Use get_stack_frame_id.
Update comments.
(set_momentary_breakpoint): Only accept non-inlined frames.
(watch_command_1): Use frame_unwind_caller_pc and
frame_unwind_caller_id instead of get_prev_frame.
(until_break_command): Likewise. Use get_stack_frame_id.
* buildsym.c (end_symtab): Set SYMBOL_SYMTAB for block functions.
* dwarf2loc.c (dwarf_expr_frame_base): Use block_linkage_function.
* dwarf2read.c (process_die): Handle DW_TAG_inlined_subroutine.
(read_func_scope, new_symbol): Likewise. Handle arguments specially
for inlined functions without call site information.
(inherit_abstract_dies): Allow tag mismatch for inlined subroutines.
(die_specification): Treat DW_AT_abstract_origin as a specification.
(read_type_die): Handle DW_TAG_inlined_subroutine.
* frame-unwind.c (frame_unwind_init): Add inline_frame_unwind.
* frame.c (fprint_frame_id): Print inline depth.
(fprint_frame_type): Handle INLINE_FRAME and SENTINEL_FRAME.
(skip_inlined_frames, get_stack_frame_id): New.
(frame_unwind_caller_id): Use skip_inlined_frames.
(frame_id_inlined_p): New.
(frame_id_eq): Make the logic match the comments. Add inline_depth
check.
(frame_id_inner): Handle inlined functions.
(frame_unwind_pc): New function, copied from frame_unwind_caller_pc.
(frame_unwind_caller_pc): Use skip_inlined_frames and frame_unwind_pc.
(get_prev_frame_1): Check for inline frames. Split out frame
allocation to get_prev_frame_raw.
(get_prev_frame_raw): New function.
(get_prev_frame): Handle inline frames.
(get_frame_pc): Use frame_unwind_pc.
(get_frame_address_in_block): Skip inlined frames on both sides.
(pc_notcurrent): Delete.
(find_frame_sal): Rewrite to handle inline call sites. Use
get_frame_address_in_block.
(deprecated_update_frame_pc_hack): Make static.
* frame.h: Update comments.
(struct frame_id): Add inline_depth.
(enum frame_type): Add INLINE_FRAME.
(frame_id_inlined_p, get_stack_frame_id): New prototypes.
* gdbthread.h (struct thread_info): Add step_stack_frame_id field.
* infcmd.c (set_step_frame): New function.
(step_once): Use set_step_frame. Handle inlined functions.
(until_next_command): Use set_step_frame.
(finish_backward), finish_forward): Use get_stack_frame_id.
(finish_command): Support inlined functions.
* inferior.h (set_step_info): New prototype.
* infrun.c (RESUME_ALL): Use minus_one_ptid.
(clear_proceed_status): Clear step_stack_frame_id.
(init_wait_for_inferior): Call clear_inline_frame_state.
(init_execution_control_state): Make static.
(set_step_info): New function.
(init_thread_stepping_state): Do not set the symtab or line here.
(stepped_in_from): New function.
(handle_inferior_event): Handle inlined functions. Use set_step_info.
(insert_step_resume_breakpoint_at_frame): Use get_stack_frame_id.
(struct inferior_status): Add step_stack_frame_id.
(save_inferior_status, restore_inferior_status): Save and restore
step_stack_frame_id.
* inline-frame.c, inline-frame.h: New files.
* minsyms.c (prim_record_minimal_symbol_and_info): Use XCALLOC.
* regcache.c (regcache_write_pc): Call reinit_frame_cache.
* s390-tdep.c (s390_prologue_frame_unwind_cache): Handle INLINE_FRAME.
* stack.c (frame_show_address): New.
(print_frame_info, print_frame): Use it.
(find_frame_funname): Use get_frame_function. Handle inlined blocks.
(frame_info): Mark inlined functions.
(backtrace_command_1): Use get_current_user_frame.
(print_frame_local_vars, print_frame_label_vars): Update comments.
(return_command): Refuse inlined functions.
* symtab.c (lookup_symbol_aux_local): Stop at inlined function
boundaries.
(find_function_start_sal): Avoid inlined functions.
(completion_list_add_fields): New function.
(default_make_symbol_completion_list): Use it. Use block_static_block
and block_global_block. Check for inlined functions.
(skip_prologue_using_sal): Avoid line number comparison across
inlining.
* symtab.h (struct symbol): Add is_inlined.
(SYMBOL_INLINED): New.
* target.c (target_resume): Call clear_inline_frame_state.
* valops.c (value_of_variable): Check block_inlined_p.
gdb/doc/
* gdb.texinfo (Debugging Optimized Code): New chapter.
(Compiling for Debugging): Reference it. Move some
text to the new section.
gdb/testsuite/
* gdb.base/break.exp: Add an XFAIL for gcc/36748.
* gdb.cp/annota2.exp: Accept frames-invalid in more places.
* gdb.opt/Makefile.in (EXECUTABLES): Update.
* gdb.opt/clobbered-registers-O2.exp: Update to GPL v3.
* gdb.opt/inline-bt.c, gdb.opt/inline-bt.exp,
gdb.opt/inline-cmds.c, gdb.opt/inline-cmds.exp,
gdb.opt/inline-locals.c, gdb.opt/inline-locals.exp,
gdb.opt/inline-markers.c: New files.
* lib/gdb.exp (skip_inline_frame_tests): New function.
(skip_inline_var_tests): New function.
2009-06-28 02:20:24 +02:00
|
|
|
|
# Return whether we should skip tests for showing inlined functions in
|
|
|
|
|
# backtraces. Requires get_compiler_info and get_debug_format.
|
|
|
|
|
|
|
|
|
|
proc skip_inline_frame_tests {} {
|
|
|
|
|
# GDB only recognizes inlining information in DWARF 2 (DWARF 3).
|
|
|
|
|
if { ! [test_debug_format "DWARF 2"] } {
|
|
|
|
|
return 1
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# GCC before 4.1 does not emit DW_AT_call_file / DW_AT_call_line.
|
|
|
|
|
if { ([test_compiler_info "gcc-2-*"]
|
|
|
|
|
|| [test_compiler_info "gcc-3-*"]
|
|
|
|
|
|| [test_compiler_info "gcc-4-0-*"]) } {
|
|
|
|
|
return 1
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return 0
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# Return whether we should skip tests for showing variables from
|
|
|
|
|
# inlined functions. Requires get_compiler_info and get_debug_format.
|
|
|
|
|
|
|
|
|
|
proc skip_inline_var_tests {} {
|
|
|
|
|
# GDB only recognizes inlining information in DWARF 2 (DWARF 3).
|
|
|
|
|
if { ! [test_debug_format "DWARF 2"] } {
|
|
|
|
|
return 1
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return 0
|
|
|
|
|
}
|
|
|
|
|
|
2011-02-21 15:57:38 +01:00
|
|
|
|
# Return a 1 if we should skip tests that require hardware breakpoints
|
|
|
|
|
|
|
|
|
|
proc skip_hw_breakpoint_tests {} {
|
|
|
|
|
# Skip tests if requested by the board (note that no_hardware_watchpoints
|
|
|
|
|
# disables both watchpoints and breakpoints)
|
|
|
|
|
if { [target_info exists gdb,no_hardware_watchpoints]} {
|
|
|
|
|
return 1
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# These targets support hardware breakpoints natively
|
|
|
|
|
if { [istarget "i?86-*-*"]
|
|
|
|
|
|| [istarget "x86_64-*-*"]
|
2011-02-21 16:03:38 +01:00
|
|
|
|
|| [istarget "ia64-*-*"]
|
2015-06-22 14:41:33 +02:00
|
|
|
|
|| [istarget "arm*-*-*"]
|
2016-09-16 19:25:55 +02:00
|
|
|
|
|| [istarget "aarch64*-*-*"]
|
|
|
|
|
|| [istarget "s390*-*-*"] } {
|
2011-02-21 15:57:38 +01:00
|
|
|
|
return 0
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return 1
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# Return a 1 if we should skip tests that require hardware watchpoints
|
|
|
|
|
|
|
|
|
|
proc skip_hw_watchpoint_tests {} {
|
|
|
|
|
# Skip tests if requested by the board
|
|
|
|
|
if { [target_info exists gdb,no_hardware_watchpoints]} {
|
|
|
|
|
return 1
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# These targets support hardware watchpoints natively
|
|
|
|
|
if { [istarget "i?86-*-*"]
|
|
|
|
|
|| [istarget "x86_64-*-*"]
|
|
|
|
|
|| [istarget "ia64-*-*"]
|
2011-02-21 16:03:38 +01:00
|
|
|
|
|| [istarget "arm*-*-*"]
|
2015-06-22 14:41:33 +02:00
|
|
|
|
|| [istarget "aarch64*-*-*"]
|
2011-02-21 15:57:38 +01:00
|
|
|
|
|| [istarget "powerpc*-*-linux*"]
|
|
|
|
|
|| [istarget "s390*-*-*"] } {
|
|
|
|
|
return 0
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return 1
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# Return a 1 if we should skip tests that require *multiple* hardware
|
|
|
|
|
# watchpoints to be active at the same time
|
|
|
|
|
|
|
|
|
|
proc skip_hw_watchpoint_multi_tests {} {
|
|
|
|
|
if { [skip_hw_watchpoint_tests] } {
|
|
|
|
|
return 1
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# These targets support just a single hardware watchpoint
|
2011-02-21 16:03:38 +01:00
|
|
|
|
if { [istarget "arm*-*-*"]
|
|
|
|
|
|| [istarget "powerpc*-*-linux*"] } {
|
2011-02-21 15:57:38 +01:00
|
|
|
|
return 1
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return 0
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# Return a 1 if we should skip tests that require read/access watchpoints
|
|
|
|
|
|
|
|
|
|
proc skip_hw_watchpoint_access_tests {} {
|
|
|
|
|
if { [skip_hw_watchpoint_tests] } {
|
|
|
|
|
return 1
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# These targets support just write watchpoints
|
|
|
|
|
if { [istarget "s390*-*-*"] } {
|
|
|
|
|
return 1
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return 0
|
|
|
|
|
}
|
|
|
|
|
|
2012-08-22 16:27:49 +02:00
|
|
|
|
# Return 1 if we should skip tests that require the runtime unwinder
|
|
|
|
|
# hook. This must be invoked while gdb is running, after shared
|
|
|
|
|
# libraries have been loaded. This is needed because otherwise a
|
|
|
|
|
# shared libgcc won't be visible.
|
|
|
|
|
|
|
|
|
|
proc skip_unwinder_tests {} {
|
|
|
|
|
global gdb_prompt
|
|
|
|
|
|
2012-08-24 17:26:23 +02:00
|
|
|
|
set ok 0
|
2012-08-22 16:27:49 +02:00
|
|
|
|
gdb_test_multiple "print _Unwind_DebugHook" "check for unwinder hook" {
|
|
|
|
|
-re "= .*no debug info.*_Unwind_DebugHook.*\r\n$gdb_prompt $" {
|
|
|
|
|
}
|
|
|
|
|
-re "= .*_Unwind_DebugHook.*\r\n$gdb_prompt $" {
|
2012-08-24 17:26:23 +02:00
|
|
|
|
set ok 1
|
2012-08-22 16:27:49 +02:00
|
|
|
|
}
|
|
|
|
|
-re "No symbol .* in current context.\r\n$gdb_prompt $" {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if {!$ok} {
|
|
|
|
|
gdb_test_multiple "info probe" "check for stap probe in unwinder" {
|
|
|
|
|
-re ".*libgcc.*unwind.*\r\n$gdb_prompt $" {
|
|
|
|
|
set ok 1
|
|
|
|
|
}
|
|
|
|
|
-re "\r\n$gdb_prompt $" {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return $ok
|
|
|
|
|
}
|
|
|
|
|
|
2019-08-26 18:48:02 +02:00
|
|
|
|
# Return 1 if we should skip tests that require the libstdc++ stap
|
2013-04-15 20:09:02 +02:00
|
|
|
|
# probes. This must be invoked while gdb is running, after shared
|
2019-07-25 18:39:31 +02:00
|
|
|
|
# libraries have been loaded. PROMPT_REGEXP is the expected prompt.
|
2013-04-15 20:09:02 +02:00
|
|
|
|
|
2019-07-25 18:39:31 +02:00
|
|
|
|
proc skip_libstdcxx_probe_tests_prompt { prompt_regexp } {
|
2019-08-26 18:48:02 +02:00
|
|
|
|
set supported 0
|
2013-04-15 20:09:02 +02:00
|
|
|
|
gdb_test_multiple "info probe" "check for stap probe in libstdc++" {
|
2019-07-25 18:39:31 +02:00
|
|
|
|
-re ".*libstdcxx.*catch.*\r\n$prompt_regexp" {
|
2019-08-26 18:48:02 +02:00
|
|
|
|
set supported 1
|
2013-04-15 20:09:02 +02:00
|
|
|
|
}
|
2019-07-25 18:39:31 +02:00
|
|
|
|
-re "\r\n$prompt_regexp" {
|
2013-04-15 20:09:02 +02:00
|
|
|
|
}
|
2019-07-29 14:11:13 +02:00
|
|
|
|
} "$prompt_regexp"
|
2019-08-26 18:48:02 +02:00
|
|
|
|
set skip [expr !$supported]
|
|
|
|
|
return $skip
|
2013-04-15 20:09:02 +02:00
|
|
|
|
}
|
|
|
|
|
|
2019-07-25 18:39:31 +02:00
|
|
|
|
# As skip_libstdcxx_probe_tests_prompt, with gdb_prompt.
|
|
|
|
|
|
|
|
|
|
proc skip_libstdcxx_probe_tests {} {
|
|
|
|
|
global gdb_prompt
|
|
|
|
|
return [skip_libstdcxx_probe_tests_prompt "$gdb_prompt $"]
|
|
|
|
|
}
|
|
|
|
|
|
the "compile" command
This final patch adds the new "compile" command and subcommands, and
all the machinery needed to make it work.
A shared library supplied by gcc is used for all communications with
gcc. Types and most aspects of symbols are provided directly by gdb
to the compiler using this library.
gdb provides some information about the user's code using plain text.
Macros are emitted this way, and DWARF location expressions (and
bounds for VLA) are compiled to C code.
This hybrid approach was taken because, on the one hand, it is better
to provide global declarations and such on demand; but on the other
hand, for local variables, translating DWARF location expressions to C
was much simpler than exporting a full compiler API to gdb -- the same
result, only easier to implement, understand, and debug.
In the ordinary mode, the user's expression is wrapped in a dummy
function. After compilation, gdb inserts the resulting object code
into the inferior, then calls this function.
Access to local variables is provided by noting which registers are
used by location expressions, and passing a structure of register
values into the function. Writes to registers are supported by
copying out these values after the function returns.
This approach was taken so that we could eventually implement other
more interesting features based on this same infrastructure; for
example, we're planning to investigate inferior-side breakpoint
conditions.
gdb/ChangeLog
2014-12-12 Phil Muldoon <pmuldoon@redhat.com>
Jan Kratochvil <jan.kratochvil@redhat.com>
Tom Tromey <tromey@redhat.com>
* NEWS: Update.
* symtab.h (struct symbol_computed_ops) <generate_c_location>: New
field.
* p-lang.c (pascal_language_defn): Update.
* opencl-lang.c (opencl_language_defn): Update.
* objc-lang.c (objc_language_defn): Update.
* m2-lang.c (m2_language_defn): Update.
* language.h (struct language_defn) <la_get_compile_instance,
la_compute_program>: New fields.
* language.c (unknown_language_defn, auto_language_defn)
(local_language_defn): Update.
* jv-lang.c (java_language_defn): Update.
* go-lang.c (go_language_defn): Update.
* f-lang.c (f_language_defn): Update.
* dwarf2loc.h (dwarf2_compile_property_to_c): Declare.
* dwarf2loc.c (dwarf2_compile_property_to_c)
(locexpr_generate_c_location, loclist_generate_c_location): New
functions.
(dwarf2_locexpr_funcs, dwarf2_loclist_funcs): Update.
* defs.h (enum compile_i_scope_types): New.
(enum command_control_type) <compile_control>: New constant.
(struct command_line) <control_u>: New field.
* d-lang.c (d_language_defn): Update.
* compile/compile.c: New file.
* compile/compile-c-support.c: New file.
* compile/compile-c-symbols.c: New file.
* compile/compile-c-types.c: New file.
* compile/compile.h: New file.
* compile/compile-internal.h: New file.
* compile/compile-loc2c.c: New file.
* compile/compile-object-load.c: New file.
* compile/compile-object-load.h: New file.
* compile/compile-object-run.c: New file.
* compile/compile-object-run.h: New file.
* cli/cli-script.c (multi_line_command_p, print_command_lines)
(execute_control_command, process_next_line)
(recurse_read_control_structure): Handle compile_control.
* c-lang.h (c_get_compile_context, c_compute_program): Declare.
* c-lang.c (c_language_defn, cplus_language_defn)
(asm_language_defn, minimal_language_defn): Update.
* ada-lang.c (ada_language_defn): Update.
* Makefile.in (SUBDIR_GCC_COMPILE_OBS, SUBDIR_GCC_COMPILE_SRCS):
New variables.
(SFILES): Add SUBDIR_GCC_COMPILE_SRCS.
(HFILES_NO_SRCDIR): Add compile.h.
(COMMON_OBS): Add SUBDIR_GCC_COMPILE_OBS.
(INIT_FILES): Add SUBDIR_GCC_COMPILE_SRCS.
(compile.o, compile-c-types.o, compile-c-symbols.o)
(compile-object-load.o, compile-object-run.o, compile-loc2c.o)
(compile-c-support.o): New targets.
gdb/doc/ChangeLog
2014-12-12 Phil Muldoon <pmuldoon@redhat.com>
Jan Kratochvil <jan.kratochvil@redhat.com>
* gdb.texinfo (Altering): Update.
(Compiling and Injecting Code): New node.
gdb/testsuite/ChangeLog
2014-12-12 Phil Muldoon <pmuldoon@redhat.com>
Jan Kratochvil <jan.kratochvil@redhat.com>
Tom Tromey <tromey@redhat.com>
* configure.ac: Add gdb.compile/.
* configure: Regenerate.
* gdb.compile/Makefile.in: New file.
* gdb.compile/compile-ops.exp: New file.
* gdb.compile/compile-ops.c: New file.
* gdb.compile/compile-tls.c: New file.
* gdb.compile/compile-tls.exp: New file.
* gdb.compile/compile-constvar.S: New file.
* gdb.compile/compile-constvar.c: New file.
* gdb.compile/compile-mod.c: New file.
* gdb.compile/compile-nodebug.c: New file.
* gdb.compile/compile-setjmp-mod.c: New file.
* gdb.compile/compile-setjmp.c: New file.
* gdb.compile/compile-setjmp.exp: New file.
* gdb.compile/compile-shlib.c: New file.
* gdb.compile/compile.c: New file.
* gdb.compile/compile.exp: New file.
* lib/gdb.exp (skip_compile_feature_tests): New proc.
2014-05-14 22:35:45 +02:00
|
|
|
|
# Return 1 if we should skip tests of the "compile" feature.
|
|
|
|
|
# This must be invoked after the inferior has been started.
|
|
|
|
|
|
|
|
|
|
proc skip_compile_feature_tests {} {
|
|
|
|
|
global gdb_prompt
|
|
|
|
|
|
|
|
|
|
set result 0
|
|
|
|
|
gdb_test_multiple "compile code -- ;" "check for working compile command" {
|
|
|
|
|
"Could not load libcc1.*\r\n$gdb_prompt $" {
|
|
|
|
|
set result 1
|
|
|
|
|
}
|
2014-12-17 20:09:02 +01:00
|
|
|
|
-re "Command not supported on this host\\..*\r\n$gdb_prompt $" {
|
|
|
|
|
set result 1
|
|
|
|
|
}
|
the "compile" command
This final patch adds the new "compile" command and subcommands, and
all the machinery needed to make it work.
A shared library supplied by gcc is used for all communications with
gcc. Types and most aspects of symbols are provided directly by gdb
to the compiler using this library.
gdb provides some information about the user's code using plain text.
Macros are emitted this way, and DWARF location expressions (and
bounds for VLA) are compiled to C code.
This hybrid approach was taken because, on the one hand, it is better
to provide global declarations and such on demand; but on the other
hand, for local variables, translating DWARF location expressions to C
was much simpler than exporting a full compiler API to gdb -- the same
result, only easier to implement, understand, and debug.
In the ordinary mode, the user's expression is wrapped in a dummy
function. After compilation, gdb inserts the resulting object code
into the inferior, then calls this function.
Access to local variables is provided by noting which registers are
used by location expressions, and passing a structure of register
values into the function. Writes to registers are supported by
copying out these values after the function returns.
This approach was taken so that we could eventually implement other
more interesting features based on this same infrastructure; for
example, we're planning to investigate inferior-side breakpoint
conditions.
gdb/ChangeLog
2014-12-12 Phil Muldoon <pmuldoon@redhat.com>
Jan Kratochvil <jan.kratochvil@redhat.com>
Tom Tromey <tromey@redhat.com>
* NEWS: Update.
* symtab.h (struct symbol_computed_ops) <generate_c_location>: New
field.
* p-lang.c (pascal_language_defn): Update.
* opencl-lang.c (opencl_language_defn): Update.
* objc-lang.c (objc_language_defn): Update.
* m2-lang.c (m2_language_defn): Update.
* language.h (struct language_defn) <la_get_compile_instance,
la_compute_program>: New fields.
* language.c (unknown_language_defn, auto_language_defn)
(local_language_defn): Update.
* jv-lang.c (java_language_defn): Update.
* go-lang.c (go_language_defn): Update.
* f-lang.c (f_language_defn): Update.
* dwarf2loc.h (dwarf2_compile_property_to_c): Declare.
* dwarf2loc.c (dwarf2_compile_property_to_c)
(locexpr_generate_c_location, loclist_generate_c_location): New
functions.
(dwarf2_locexpr_funcs, dwarf2_loclist_funcs): Update.
* defs.h (enum compile_i_scope_types): New.
(enum command_control_type) <compile_control>: New constant.
(struct command_line) <control_u>: New field.
* d-lang.c (d_language_defn): Update.
* compile/compile.c: New file.
* compile/compile-c-support.c: New file.
* compile/compile-c-symbols.c: New file.
* compile/compile-c-types.c: New file.
* compile/compile.h: New file.
* compile/compile-internal.h: New file.
* compile/compile-loc2c.c: New file.
* compile/compile-object-load.c: New file.
* compile/compile-object-load.h: New file.
* compile/compile-object-run.c: New file.
* compile/compile-object-run.h: New file.
* cli/cli-script.c (multi_line_command_p, print_command_lines)
(execute_control_command, process_next_line)
(recurse_read_control_structure): Handle compile_control.
* c-lang.h (c_get_compile_context, c_compute_program): Declare.
* c-lang.c (c_language_defn, cplus_language_defn)
(asm_language_defn, minimal_language_defn): Update.
* ada-lang.c (ada_language_defn): Update.
* Makefile.in (SUBDIR_GCC_COMPILE_OBS, SUBDIR_GCC_COMPILE_SRCS):
New variables.
(SFILES): Add SUBDIR_GCC_COMPILE_SRCS.
(HFILES_NO_SRCDIR): Add compile.h.
(COMMON_OBS): Add SUBDIR_GCC_COMPILE_OBS.
(INIT_FILES): Add SUBDIR_GCC_COMPILE_SRCS.
(compile.o, compile-c-types.o, compile-c-symbols.o)
(compile-object-load.o, compile-object-run.o, compile-loc2c.o)
(compile-c-support.o): New targets.
gdb/doc/ChangeLog
2014-12-12 Phil Muldoon <pmuldoon@redhat.com>
Jan Kratochvil <jan.kratochvil@redhat.com>
* gdb.texinfo (Altering): Update.
(Compiling and Injecting Code): New node.
gdb/testsuite/ChangeLog
2014-12-12 Phil Muldoon <pmuldoon@redhat.com>
Jan Kratochvil <jan.kratochvil@redhat.com>
Tom Tromey <tromey@redhat.com>
* configure.ac: Add gdb.compile/.
* configure: Regenerate.
* gdb.compile/Makefile.in: New file.
* gdb.compile/compile-ops.exp: New file.
* gdb.compile/compile-ops.c: New file.
* gdb.compile/compile-tls.c: New file.
* gdb.compile/compile-tls.exp: New file.
* gdb.compile/compile-constvar.S: New file.
* gdb.compile/compile-constvar.c: New file.
* gdb.compile/compile-mod.c: New file.
* gdb.compile/compile-nodebug.c: New file.
* gdb.compile/compile-setjmp-mod.c: New file.
* gdb.compile/compile-setjmp.c: New file.
* gdb.compile/compile-setjmp.exp: New file.
* gdb.compile/compile-shlib.c: New file.
* gdb.compile/compile.c: New file.
* gdb.compile/compile.exp: New file.
* lib/gdb.exp (skip_compile_feature_tests): New proc.
2014-05-14 22:35:45 +02:00
|
|
|
|
-re "\r\n$gdb_prompt $" {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return $result
|
|
|
|
|
}
|
|
|
|
|
|
2018-02-26 20:30:43 +01:00
|
|
|
|
# Helper for gdb_is_target_* procs. TARGET_NAME is the name of the target
|
|
|
|
|
# we're looking for (used to build the test name). TARGET_STACK_REGEXP
|
|
|
|
|
# is a regexp that will match the output of "maint print target-stack" if
|
2018-02-28 14:58:25 +01:00
|
|
|
|
# the target in question is currently pushed. PROMPT_REGEXP is a regexp
|
|
|
|
|
# matching the expected prompt after the command output.
|
Don't suppress errors inserting/removing hardware breakpoints in shared
libraries.
As explained in
https://sourceware.org/ml/gdb-patches/2008-08/msg00361.html, after a
shared library was unloaded, we can no longer insert or remove
breakpoints into/from its (no longer present) code segment. That'll
fail with memory errors. However, that concern does not apply to
hardware breakpoints. By definition, hardware breakpoints are
implemented using a mechanism that is not dependent on being able to
modify the target's memory. Usually, by setting up CPU debug
registers. IOW, we should be able to set hw breakpoints in an
unmapped address. We don't seem to have a test that exercises that,
so this patch adds one.
I noticed the error supression because of a related issue -- the
target_insert_hw_breakpoint/target_remove_hw_breakpoint interfaces
don't really distinguish "not supported" from "error" return, and so
remote.c returns -1 in both cases. This results in hardware
breakpoints set in shared libraries silently ending up pending forever
even though the target doesn't actually support hw breakpoints.
(gdb) set breakpoint always-inserted on
(gdb) set remote Z-packet off
(gdb) info breakpoints
No breakpoints or watchpoints.
(gdb) hbreak shrfunc
Hardware assisted breakpoint 3 at 0x7ffff7dfb657: file ../../../src/gdb/testsuite/gdb.base/hbreak-in-shr-unsupported-shr.c, line 21.
(gdb) info break
Num Type Disp Enb Address What
3 hw breakpoint keep y <PENDING> shrfunc
After the patch we get the expected:
(gdb) hbreak shrfunc
Hardware assisted breakpoint 3 at 0x7ffff7dfb657: file ../../../src/gdb/testsuite/gdb.base/hbreak-in-shr-unsupported-shr.c, line 21.
Warning:
Cannot insert hardware breakpoint 3.
Could not insert hardware breakpoints:
You may have requested too many hardware breakpoints/watchpoints.
(gdb) info break
Num Type Disp Enb Address What
3 hw breakpoint keep y 0x00007ffff7dfb657 in shrfunc at ../../../src/gdb/testsuite/gdb.base/hbreak-in-shr-unsupported-shr.c:21
(HW breakpoints set in the main executable, when the target doesn't
support HW breakpoints always resulted in the latter output.)
We probably should improve the insert/remove interface to return a
different error code for unsupported. But I chose to fix the error
supression first, as it's a deeper and wider issue.
Tested on x86_64 Fedora 17, native and gdbserver.
gdb/
2014-04-23 Pedro Alves <palves@redhat.com>
* breakpoint.c (insert_bp_location, remove_breakpoint_1): If
the breakpoint is set in a shared library, only suppress
errors for software breakpoints, not hardware breakpoints.
gdb/testsuite/
2014-04-23 Pedro Alves <palves@redhat.com>
* gdb.base/hbreak-in-shr-unsupported-shr.c: New file.
* gdb.base/hbreak-in-shr-unsupported.c: New file.
* gdb.base/hbreak-in-shr-unsupported.exp: New file.
* gdb.base/hbreak-unmapped.c: New file.
* gdb.base/hbreak-unmapped.exp: New file.
* gdb.trace/qtro.exp (gdb_is_target_remote): Move ...
* lib/gdb.exp (gdb_is_target_remote): ... here.
2014-04-23 16:06:47 +02:00
|
|
|
|
|
2018-02-28 14:58:25 +01:00
|
|
|
|
proc gdb_is_target_1 { target_name target_stack_regexp prompt_regexp } {
|
2018-02-26 20:30:43 +01:00
|
|
|
|
set test "probe for target ${target_name}"
|
Don't suppress errors inserting/removing hardware breakpoints in shared
libraries.
As explained in
https://sourceware.org/ml/gdb-patches/2008-08/msg00361.html, after a
shared library was unloaded, we can no longer insert or remove
breakpoints into/from its (no longer present) code segment. That'll
fail with memory errors. However, that concern does not apply to
hardware breakpoints. By definition, hardware breakpoints are
implemented using a mechanism that is not dependent on being able to
modify the target's memory. Usually, by setting up CPU debug
registers. IOW, we should be able to set hw breakpoints in an
unmapped address. We don't seem to have a test that exercises that,
so this patch adds one.
I noticed the error supression because of a related issue -- the
target_insert_hw_breakpoint/target_remove_hw_breakpoint interfaces
don't really distinguish "not supported" from "error" return, and so
remote.c returns -1 in both cases. This results in hardware
breakpoints set in shared libraries silently ending up pending forever
even though the target doesn't actually support hw breakpoints.
(gdb) set breakpoint always-inserted on
(gdb) set remote Z-packet off
(gdb) info breakpoints
No breakpoints or watchpoints.
(gdb) hbreak shrfunc
Hardware assisted breakpoint 3 at 0x7ffff7dfb657: file ../../../src/gdb/testsuite/gdb.base/hbreak-in-shr-unsupported-shr.c, line 21.
(gdb) info break
Num Type Disp Enb Address What
3 hw breakpoint keep y <PENDING> shrfunc
After the patch we get the expected:
(gdb) hbreak shrfunc
Hardware assisted breakpoint 3 at 0x7ffff7dfb657: file ../../../src/gdb/testsuite/gdb.base/hbreak-in-shr-unsupported-shr.c, line 21.
Warning:
Cannot insert hardware breakpoint 3.
Could not insert hardware breakpoints:
You may have requested too many hardware breakpoints/watchpoints.
(gdb) info break
Num Type Disp Enb Address What
3 hw breakpoint keep y 0x00007ffff7dfb657 in shrfunc at ../../../src/gdb/testsuite/gdb.base/hbreak-in-shr-unsupported-shr.c:21
(HW breakpoints set in the main executable, when the target doesn't
support HW breakpoints always resulted in the latter output.)
We probably should improve the insert/remove interface to return a
different error code for unsupported. But I chose to fix the error
supression first, as it's a deeper and wider issue.
Tested on x86_64 Fedora 17, native and gdbserver.
gdb/
2014-04-23 Pedro Alves <palves@redhat.com>
* breakpoint.c (insert_bp_location, remove_breakpoint_1): If
the breakpoint is set in a shared library, only suppress
errors for software breakpoints, not hardware breakpoints.
gdb/testsuite/
2014-04-23 Pedro Alves <palves@redhat.com>
* gdb.base/hbreak-in-shr-unsupported-shr.c: New file.
* gdb.base/hbreak-in-shr-unsupported.c: New file.
* gdb.base/hbreak-in-shr-unsupported.exp: New file.
* gdb.base/hbreak-unmapped.c: New file.
* gdb.base/hbreak-unmapped.exp: New file.
* gdb.trace/qtro.exp (gdb_is_target_remote): Move ...
* lib/gdb.exp (gdb_is_target_remote): ... here.
2014-04-23 16:06:47 +02:00
|
|
|
|
gdb_test_multiple "maint print target-stack" $test {
|
2018-02-26 20:30:43 +01:00
|
|
|
|
-re "${target_stack_regexp}${prompt_regexp}" {
|
Don't suppress errors inserting/removing hardware breakpoints in shared
libraries.
As explained in
https://sourceware.org/ml/gdb-patches/2008-08/msg00361.html, after a
shared library was unloaded, we can no longer insert or remove
breakpoints into/from its (no longer present) code segment. That'll
fail with memory errors. However, that concern does not apply to
hardware breakpoints. By definition, hardware breakpoints are
implemented using a mechanism that is not dependent on being able to
modify the target's memory. Usually, by setting up CPU debug
registers. IOW, we should be able to set hw breakpoints in an
unmapped address. We don't seem to have a test that exercises that,
so this patch adds one.
I noticed the error supression because of a related issue -- the
target_insert_hw_breakpoint/target_remove_hw_breakpoint interfaces
don't really distinguish "not supported" from "error" return, and so
remote.c returns -1 in both cases. This results in hardware
breakpoints set in shared libraries silently ending up pending forever
even though the target doesn't actually support hw breakpoints.
(gdb) set breakpoint always-inserted on
(gdb) set remote Z-packet off
(gdb) info breakpoints
No breakpoints or watchpoints.
(gdb) hbreak shrfunc
Hardware assisted breakpoint 3 at 0x7ffff7dfb657: file ../../../src/gdb/testsuite/gdb.base/hbreak-in-shr-unsupported-shr.c, line 21.
(gdb) info break
Num Type Disp Enb Address What
3 hw breakpoint keep y <PENDING> shrfunc
After the patch we get the expected:
(gdb) hbreak shrfunc
Hardware assisted breakpoint 3 at 0x7ffff7dfb657: file ../../../src/gdb/testsuite/gdb.base/hbreak-in-shr-unsupported-shr.c, line 21.
Warning:
Cannot insert hardware breakpoint 3.
Could not insert hardware breakpoints:
You may have requested too many hardware breakpoints/watchpoints.
(gdb) info break
Num Type Disp Enb Address What
3 hw breakpoint keep y 0x00007ffff7dfb657 in shrfunc at ../../../src/gdb/testsuite/gdb.base/hbreak-in-shr-unsupported-shr.c:21
(HW breakpoints set in the main executable, when the target doesn't
support HW breakpoints always resulted in the latter output.)
We probably should improve the insert/remove interface to return a
different error code for unsupported. But I chose to fix the error
supression first, as it's a deeper and wider issue.
Tested on x86_64 Fedora 17, native and gdbserver.
gdb/
2014-04-23 Pedro Alves <palves@redhat.com>
* breakpoint.c (insert_bp_location, remove_breakpoint_1): If
the breakpoint is set in a shared library, only suppress
errors for software breakpoints, not hardware breakpoints.
gdb/testsuite/
2014-04-23 Pedro Alves <palves@redhat.com>
* gdb.base/hbreak-in-shr-unsupported-shr.c: New file.
* gdb.base/hbreak-in-shr-unsupported.c: New file.
* gdb.base/hbreak-in-shr-unsupported.exp: New file.
* gdb.base/hbreak-unmapped.c: New file.
* gdb.base/hbreak-unmapped.exp: New file.
* gdb.trace/qtro.exp (gdb_is_target_remote): Move ...
* lib/gdb.exp (gdb_is_target_remote): ... here.
2014-04-23 16:06:47 +02:00
|
|
|
|
pass $test
|
|
|
|
|
return 1
|
|
|
|
|
}
|
2015-11-30 17:05:12 +01:00
|
|
|
|
-re "$prompt_regexp" {
|
Don't suppress errors inserting/removing hardware breakpoints in shared
libraries.
As explained in
https://sourceware.org/ml/gdb-patches/2008-08/msg00361.html, after a
shared library was unloaded, we can no longer insert or remove
breakpoints into/from its (no longer present) code segment. That'll
fail with memory errors. However, that concern does not apply to
hardware breakpoints. By definition, hardware breakpoints are
implemented using a mechanism that is not dependent on being able to
modify the target's memory. Usually, by setting up CPU debug
registers. IOW, we should be able to set hw breakpoints in an
unmapped address. We don't seem to have a test that exercises that,
so this patch adds one.
I noticed the error supression because of a related issue -- the
target_insert_hw_breakpoint/target_remove_hw_breakpoint interfaces
don't really distinguish "not supported" from "error" return, and so
remote.c returns -1 in both cases. This results in hardware
breakpoints set in shared libraries silently ending up pending forever
even though the target doesn't actually support hw breakpoints.
(gdb) set breakpoint always-inserted on
(gdb) set remote Z-packet off
(gdb) info breakpoints
No breakpoints or watchpoints.
(gdb) hbreak shrfunc
Hardware assisted breakpoint 3 at 0x7ffff7dfb657: file ../../../src/gdb/testsuite/gdb.base/hbreak-in-shr-unsupported-shr.c, line 21.
(gdb) info break
Num Type Disp Enb Address What
3 hw breakpoint keep y <PENDING> shrfunc
After the patch we get the expected:
(gdb) hbreak shrfunc
Hardware assisted breakpoint 3 at 0x7ffff7dfb657: file ../../../src/gdb/testsuite/gdb.base/hbreak-in-shr-unsupported-shr.c, line 21.
Warning:
Cannot insert hardware breakpoint 3.
Could not insert hardware breakpoints:
You may have requested too many hardware breakpoints/watchpoints.
(gdb) info break
Num Type Disp Enb Address What
3 hw breakpoint keep y 0x00007ffff7dfb657 in shrfunc at ../../../src/gdb/testsuite/gdb.base/hbreak-in-shr-unsupported-shr.c:21
(HW breakpoints set in the main executable, when the target doesn't
support HW breakpoints always resulted in the latter output.)
We probably should improve the insert/remove interface to return a
different error code for unsupported. But I chose to fix the error
supression first, as it's a deeper and wider issue.
Tested on x86_64 Fedora 17, native and gdbserver.
gdb/
2014-04-23 Pedro Alves <palves@redhat.com>
* breakpoint.c (insert_bp_location, remove_breakpoint_1): If
the breakpoint is set in a shared library, only suppress
errors for software breakpoints, not hardware breakpoints.
gdb/testsuite/
2014-04-23 Pedro Alves <palves@redhat.com>
* gdb.base/hbreak-in-shr-unsupported-shr.c: New file.
* gdb.base/hbreak-in-shr-unsupported.c: New file.
* gdb.base/hbreak-in-shr-unsupported.exp: New file.
* gdb.base/hbreak-unmapped.c: New file.
* gdb.base/hbreak-unmapped.exp: New file.
* gdb.trace/qtro.exp (gdb_is_target_remote): Move ...
* lib/gdb.exp (gdb_is_target_remote): ... here.
2014-04-23 16:06:47 +02:00
|
|
|
|
pass $test
|
|
|
|
|
}
|
2019-07-29 14:11:13 +02:00
|
|
|
|
} "$prompt_regexp"
|
Don't suppress errors inserting/removing hardware breakpoints in shared
libraries.
As explained in
https://sourceware.org/ml/gdb-patches/2008-08/msg00361.html, after a
shared library was unloaded, we can no longer insert or remove
breakpoints into/from its (no longer present) code segment. That'll
fail with memory errors. However, that concern does not apply to
hardware breakpoints. By definition, hardware breakpoints are
implemented using a mechanism that is not dependent on being able to
modify the target's memory. Usually, by setting up CPU debug
registers. IOW, we should be able to set hw breakpoints in an
unmapped address. We don't seem to have a test that exercises that,
so this patch adds one.
I noticed the error supression because of a related issue -- the
target_insert_hw_breakpoint/target_remove_hw_breakpoint interfaces
don't really distinguish "not supported" from "error" return, and so
remote.c returns -1 in both cases. This results in hardware
breakpoints set in shared libraries silently ending up pending forever
even though the target doesn't actually support hw breakpoints.
(gdb) set breakpoint always-inserted on
(gdb) set remote Z-packet off
(gdb) info breakpoints
No breakpoints or watchpoints.
(gdb) hbreak shrfunc
Hardware assisted breakpoint 3 at 0x7ffff7dfb657: file ../../../src/gdb/testsuite/gdb.base/hbreak-in-shr-unsupported-shr.c, line 21.
(gdb) info break
Num Type Disp Enb Address What
3 hw breakpoint keep y <PENDING> shrfunc
After the patch we get the expected:
(gdb) hbreak shrfunc
Hardware assisted breakpoint 3 at 0x7ffff7dfb657: file ../../../src/gdb/testsuite/gdb.base/hbreak-in-shr-unsupported-shr.c, line 21.
Warning:
Cannot insert hardware breakpoint 3.
Could not insert hardware breakpoints:
You may have requested too many hardware breakpoints/watchpoints.
(gdb) info break
Num Type Disp Enb Address What
3 hw breakpoint keep y 0x00007ffff7dfb657 in shrfunc at ../../../src/gdb/testsuite/gdb.base/hbreak-in-shr-unsupported-shr.c:21
(HW breakpoints set in the main executable, when the target doesn't
support HW breakpoints always resulted in the latter output.)
We probably should improve the insert/remove interface to return a
different error code for unsupported. But I chose to fix the error
supression first, as it's a deeper and wider issue.
Tested on x86_64 Fedora 17, native and gdbserver.
gdb/
2014-04-23 Pedro Alves <palves@redhat.com>
* breakpoint.c (insert_bp_location, remove_breakpoint_1): If
the breakpoint is set in a shared library, only suppress
errors for software breakpoints, not hardware breakpoints.
gdb/testsuite/
2014-04-23 Pedro Alves <palves@redhat.com>
* gdb.base/hbreak-in-shr-unsupported-shr.c: New file.
* gdb.base/hbreak-in-shr-unsupported.c: New file.
* gdb.base/hbreak-in-shr-unsupported.exp: New file.
* gdb.base/hbreak-unmapped.c: New file.
* gdb.base/hbreak-unmapped.exp: New file.
* gdb.trace/qtro.exp (gdb_is_target_remote): Move ...
* lib/gdb.exp (gdb_is_target_remote): ... here.
2014-04-23 16:06:47 +02:00
|
|
|
|
return 0
|
|
|
|
|
}
|
|
|
|
|
|
2018-02-28 14:58:25 +01:00
|
|
|
|
# Helper for gdb_is_target_remote where the expected prompt is variable.
|
|
|
|
|
|
|
|
|
|
proc gdb_is_target_remote_prompt { prompt_regexp } {
|
|
|
|
|
return [gdb_is_target_1 "remote" ".*emote serial target in gdb-specific protocol.*" $prompt_regexp]
|
|
|
|
|
}
|
|
|
|
|
|
2015-11-30 17:05:12 +01:00
|
|
|
|
# Check whether we're testing with the remote or extended-remote
|
|
|
|
|
# targets.
|
|
|
|
|
|
2018-02-26 20:30:43 +01:00
|
|
|
|
proc gdb_is_target_remote { } {
|
2018-02-28 14:58:25 +01:00
|
|
|
|
global gdb_prompt
|
|
|
|
|
|
|
|
|
|
return [gdb_is_target_remote_prompt "$gdb_prompt $"]
|
2018-02-26 20:30:43 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# Check whether we're testing with the native target.
|
2015-11-30 17:05:12 +01:00
|
|
|
|
|
2018-02-26 20:30:43 +01:00
|
|
|
|
proc gdb_is_target_native { } {
|
2018-02-28 14:58:25 +01:00
|
|
|
|
global gdb_prompt
|
|
|
|
|
|
|
|
|
|
return [gdb_is_target_1 "native" ".*native \\(Native process\\).*" "$gdb_prompt $"]
|
2015-11-30 17:05:12 +01:00
|
|
|
|
}
|
|
|
|
|
|
2016-05-04 15:27:19 +02:00
|
|
|
|
# Return the effective value of use_gdb_stub.
|
|
|
|
|
#
|
|
|
|
|
# If the use_gdb_stub global has been set (it is set when the gdb process is
|
|
|
|
|
# spawned), return that. Otherwise, return the value of the use_gdb_stub
|
|
|
|
|
# property from the board file.
|
|
|
|
|
#
|
|
|
|
|
# This is the preferred way of checking use_gdb_stub, since it allows to check
|
|
|
|
|
# the value before the gdb has been spawned and it will return the correct value
|
|
|
|
|
# even when it was overriden by the test.
|
|
|
|
|
|
|
|
|
|
proc use_gdb_stub {} {
|
|
|
|
|
global use_gdb_stub
|
|
|
|
|
|
|
|
|
|
if [info exists use_gdb_stub] {
|
|
|
|
|
return $use_gdb_stub
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return [target_info exists use_gdb_stub]
|
|
|
|
|
}
|
|
|
|
|
|
2014-12-10 21:12:17 +01:00
|
|
|
|
# Return 1 if the current remote target is an instance of our GDBserver, 0
|
|
|
|
|
# otherwise. Return -1 if there was an error and we can't tell.
|
|
|
|
|
|
|
|
|
|
gdb_caching_proc target_is_gdbserver {
|
|
|
|
|
global gdb_prompt
|
|
|
|
|
|
|
|
|
|
set is_gdbserver -1
|
2016-12-01 21:40:05 +01:00
|
|
|
|
set test "probing for GDBserver"
|
2014-12-10 21:12:17 +01:00
|
|
|
|
|
|
|
|
|
gdb_test_multiple "monitor help" $test {
|
|
|
|
|
-re "The following monitor commands are supported.*Quit GDBserver.*$gdb_prompt $" {
|
|
|
|
|
set is_gdbserver 1
|
|
|
|
|
}
|
|
|
|
|
-re "$gdb_prompt $" {
|
|
|
|
|
set is_gdbserver 0
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if { $is_gdbserver == -1 } {
|
|
|
|
|
verbose -log "Unable to tell whether we are using GDBserver or not."
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return $is_gdbserver
|
|
|
|
|
}
|
|
|
|
|
|
2015-07-25 00:32:45 +02:00
|
|
|
|
# N.B. compiler_info is intended to be local to this file.
|
|
|
|
|
# Call test_compiler_info with no arguments to fetch its value.
|
|
|
|
|
# Yes, this is counterintuitive when there's get_compiler_info,
|
|
|
|
|
# but that's the current API.
|
|
|
|
|
if [info exists compiler_info] {
|
|
|
|
|
unset compiler_info
|
|
|
|
|
}
|
|
|
|
|
|
2004-01-24 22:59:03 +01:00
|
|
|
|
set gcc_compiled 0
|
|
|
|
|
|
|
|
|
|
# Figure out what compiler I am using.
|
2015-07-25 00:32:45 +02:00
|
|
|
|
# The result is cached so only the first invocation runs the compiler.
|
2004-01-24 22:59:03 +01:00
|
|
|
|
#
|
2012-06-21 22:46:25 +02:00
|
|
|
|
# ARG can be empty or "C++". If empty, "C" is assumed.
|
2004-01-24 22:59:03 +01:00
|
|
|
|
#
|
|
|
|
|
# There are several ways to do this, with various problems.
|
|
|
|
|
#
|
|
|
|
|
# [ gdb_compile -E $ifile -o $binfile.ci ]
|
|
|
|
|
# source $binfile.ci
|
|
|
|
|
#
|
|
|
|
|
# Single Unix Spec v3 says that "-E -o ..." together are not
|
|
|
|
|
# specified. And in fact, the native compiler on hp-ux 11 (among
|
|
|
|
|
# others) does not work with "-E -o ...". Most targets used to do
|
|
|
|
|
# this, and it mostly worked, because it works with gcc.
|
|
|
|
|
#
|
|
|
|
|
# [ catch "exec $compiler -E $ifile > $binfile.ci" exec_output ]
|
|
|
|
|
# source $binfile.ci
|
|
|
|
|
#
|
|
|
|
|
# This avoids the problem with -E and -o together. This almost works
|
|
|
|
|
# if the build machine is the same as the host machine, which is
|
|
|
|
|
# usually true of the targets which are not gcc. But this code does
|
|
|
|
|
# not figure which compiler to call, and it always ends up using the C
|
Delete IRIX support
This does most of the mechanical removal. IOW, the easy part.
This doesn't touch procfs.c as that'd be a harder excision,
potentially affecting Solaris.
mips-tdep.c is left alone. E.g., I didn't delete the GDB_OSABI_IRIX
enum value, nor references to it in mips-tdep.c. Some comments
mentioning IRIX ABIs may still be relevant and I wouldn't know what to
do with them. in That can always be done on a separate pass,
preferably by someone who can test on MIPS.
I didn't remove a reference to IRIX in testsuite/lib/future.exp, as I
believe that code is imported from DejaGNU.
Built and tested on x86_64 Fedora 20, with --enable-targets=all.
Tested that building for --target=mips-sgi-irix6 on x86_64 Fedora 20
fails with:
checking for default auto-load directory... $debugdir:$datadir/auto-load
checking for default auto-load safe-path... $debugdir:$datadir/auto-load
*** Configuration mips-sgi-irix6 is obsolete.
*** Support has been REMOVED.
make[1]: *** [configure-gdb] Error 1
make[1]: Leaving directory `/home/pedro/gdb/mygit/build-irix'
make: *** [all] Error 2
gdb/
2014-10-10 Pedro Alves <palves@redhat.com>
* Makefile.in (ALL_TARGET_OBS): Remove mips-irix-tdep.o and solib-irix.o.
(ALLDEPFILES): Remove mips-irix-tdep.c and solib-irix.c.
(HFILES_NO_SRCDIR): Remove solib-irix.h.
* NEWS: Mention that support for mips-sgi-irix5* mips-sgi-irix6*
and been removed.
* config/mips/irix5.mh, config/mips/irix6.mh: Delete files.
* configure.ac: Remove references to IRIX.
* configure.host: Add *-*-irix* to the obsolete hosts section.
Remove all other references to irix.
* irix5-nat.c, mips-irix-tdep.c, solib-irix.c, solib-irix.h:
Delete files.
gdb/testsuite/
2014-10-10 Pedro Alves <palves@redhat.com>
* gdb.base/bigcore.exp: Remove references to IRIX.
* gdb.base/funcargs.exp: Likewise.
* gdb.base/interrupt.exp: Likewise.
* gdb.base/mips_pro.exp: Likewise.
* gdb.base/nodebug.exp: Likewise.
* gdb.base/setvar.exp: Likewise.
* lib/gdb.exp (gdb_compile_shlib): Remove mips-sgi-irix* case.
2014-10-10 19:18:52 +02:00
|
|
|
|
# compiler. Not good for setting hp_aCC_compiler. Target
|
|
|
|
|
# hppa*-*-hpux* used to do this.
|
2004-01-24 22:59:03 +01:00
|
|
|
|
#
|
|
|
|
|
# [ gdb_compile -E $ifile > $binfile.ci ]
|
|
|
|
|
# source $binfile.ci
|
|
|
|
|
#
|
|
|
|
|
# dejagnu target_compile says that it supports output redirection,
|
|
|
|
|
# but the code is completely different from the normal path and I
|
|
|
|
|
# don't want to sweep the mines from that path. So I didn't even try
|
|
|
|
|
# this.
|
|
|
|
|
#
|
|
|
|
|
# set cppout [ gdb_compile $ifile "" preprocess $args quiet ]
|
|
|
|
|
# eval $cppout
|
|
|
|
|
#
|
|
|
|
|
# I actually do this for all targets now. gdb_compile runs the right
|
|
|
|
|
# compiler, and TCL captures the output, and I eval the output.
|
|
|
|
|
#
|
|
|
|
|
# Unfortunately, expect logs the output of the command as it goes by,
|
|
|
|
|
# and dejagnu helpfully prints a second copy of it right afterwards.
|
|
|
|
|
# So I turn off expect logging for a moment.
|
|
|
|
|
#
|
|
|
|
|
# [ gdb_compile $ifile $ciexe_file executable $args ]
|
|
|
|
|
# [ remote_exec $ciexe_file ]
|
|
|
|
|
# [ source $ci_file.out ]
|
|
|
|
|
#
|
|
|
|
|
# I could give up on -E and just do this.
|
|
|
|
|
# I didn't get desperate enough to try this.
|
|
|
|
|
#
|
|
|
|
|
# -- chastain 2004-01-06
|
2003-11-17 16:00:20 +01:00
|
|
|
|
|
2012-06-21 22:46:25 +02:00
|
|
|
|
proc get_compiler_info {{arg ""}} {
|
2004-01-24 22:59:03 +01:00
|
|
|
|
# For compiler.c and compiler.cc
|
1999-04-16 03:35:26 +02:00
|
|
|
|
global srcdir
|
2004-01-24 22:59:03 +01:00
|
|
|
|
|
|
|
|
|
# I am going to play with the log to keep noise out.
|
|
|
|
|
global outdir
|
|
|
|
|
global tool
|
|
|
|
|
|
|
|
|
|
# These come from compiler.c or compiler.cc
|
2003-11-17 16:00:20 +01:00
|
|
|
|
global compiler_info
|
2004-06-14 17:29:30 +02:00
|
|
|
|
|
|
|
|
|
# Legacy global data symbols.
|
2004-01-24 22:59:03 +01:00
|
|
|
|
global gcc_compiled
|
1999-04-16 03:35:26 +02:00
|
|
|
|
|
2015-07-25 00:32:45 +02:00
|
|
|
|
if [info exists compiler_info] {
|
|
|
|
|
# Already computed.
|
|
|
|
|
return 0
|
|
|
|
|
}
|
|
|
|
|
|
2004-01-24 22:59:03 +01:00
|
|
|
|
# Choose which file to preprocess.
|
|
|
|
|
set ifile "${srcdir}/lib/compiler.c"
|
2012-06-21 22:46:25 +02:00
|
|
|
|
if { $arg == "c++" } {
|
2004-01-24 22:59:03 +01:00
|
|
|
|
set ifile "${srcdir}/lib/compiler.cc"
|
1999-04-16 03:35:26 +02:00
|
|
|
|
}
|
1999-06-28 18:06:02 +02:00
|
|
|
|
|
2004-01-24 22:59:03 +01:00
|
|
|
|
# Run $ifile through the right preprocessor.
|
|
|
|
|
# Toggle gdb.log to keep the compiler output out of the log.
|
2013-08-22 21:09:35 +02:00
|
|
|
|
set saved_log [log_file -info]
|
2004-01-24 22:59:03 +01:00
|
|
|
|
log_file
|
2009-04-22 21:46:19 +02:00
|
|
|
|
if [is_remote host] {
|
|
|
|
|
# We have to use -E and -o together, despite the comments
|
|
|
|
|
# above, because of how DejaGnu handles remote host testing.
|
|
|
|
|
set ppout "$outdir/compiler.i"
|
2019-01-21 11:43:53 +01:00
|
|
|
|
gdb_compile "${ifile}" "$ppout" preprocess [list "$arg" quiet getting_compiler_info]
|
2009-04-22 21:46:19 +02:00
|
|
|
|
set file [open $ppout r]
|
|
|
|
|
set cppout [read $file]
|
|
|
|
|
close $file
|
|
|
|
|
} else {
|
2019-01-21 11:43:53 +01:00
|
|
|
|
set cppout [ gdb_compile "${ifile}" "" preprocess [list "$arg" quiet getting_compiler_info] ]
|
2009-04-22 21:46:19 +02:00
|
|
|
|
}
|
2013-08-22 21:09:35 +02:00
|
|
|
|
eval log_file $saved_log
|
2004-01-24 22:59:03 +01:00
|
|
|
|
|
2004-06-14 17:29:30 +02:00
|
|
|
|
# Eval the output.
|
|
|
|
|
set unknown 0
|
2004-01-24 22:59:03 +01:00
|
|
|
|
foreach cppline [ split "$cppout" "\n" ] {
|
2004-06-14 17:29:30 +02:00
|
|
|
|
if { [ regexp "^#" "$cppline" ] } {
|
|
|
|
|
# line marker
|
|
|
|
|
} elseif { [ regexp "^\[\n\r\t \]*$" "$cppline" ] } {
|
|
|
|
|
# blank line
|
|
|
|
|
} elseif { [ regexp "^\[\n\r\t \]*set\[\n\r\t \]" "$cppline" ] } {
|
|
|
|
|
# eval this line
|
|
|
|
|
verbose "get_compiler_info: $cppline" 2
|
|
|
|
|
eval "$cppline"
|
|
|
|
|
} else {
|
|
|
|
|
# unknown line
|
|
|
|
|
verbose -log "get_compiler_info: $cppline"
|
|
|
|
|
set unknown 1
|
2004-01-24 22:59:03 +01:00
|
|
|
|
}
|
1999-06-28 18:06:02 +02:00
|
|
|
|
}
|
2004-06-14 17:29:30 +02:00
|
|
|
|
|
2015-07-25 00:32:45 +02:00
|
|
|
|
# Set to unknown if for some reason compiler_info didn't get defined.
|
|
|
|
|
if ![info exists compiler_info] {
|
|
|
|
|
verbose -log "get_compiler_info: compiler_info not provided"
|
|
|
|
|
set compiler_info "unknown"
|
|
|
|
|
}
|
|
|
|
|
# Also set to unknown compiler if any diagnostics happened.
|
2004-06-14 17:29:30 +02:00
|
|
|
|
if { $unknown } {
|
2015-07-25 00:32:45 +02:00
|
|
|
|
verbose -log "get_compiler_info: got unexpected diagnostics"
|
2004-06-14 17:29:30 +02:00
|
|
|
|
set compiler_info "unknown"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# Set the legacy symbols.
|
2016-10-20 21:58:54 +02:00
|
|
|
|
set gcc_compiled 0
|
|
|
|
|
regexp "^gcc-(\[0-9\]+)-" "$compiler_info" matchall gcc_compiled
|
2004-06-14 17:29:30 +02:00
|
|
|
|
|
|
|
|
|
# Log what happened.
|
2004-01-24 22:59:03 +01:00
|
|
|
|
verbose -log "get_compiler_info: $compiler_info"
|
1999-06-28 18:06:02 +02:00
|
|
|
|
|
|
|
|
|
# Most compilers will evaluate comparisons and other boolean
|
|
|
|
|
# operations to 0 or 1.
|
|
|
|
|
uplevel \#0 { set true 1 }
|
|
|
|
|
uplevel \#0 { set false 0 }
|
|
|
|
|
|
gdb/testsuite/
* config/monitor.exp (gdb_target_cmd): Remove semicolon after
'return'.
(gdb_target_monitor, gdb_load): Likewise.
* config/sid.exp (gdb_load): Likewise.
* config/slite.exp (gdb_load): Likewise.
* config/vx.exp (gdb_start, spawn_vxgdb): Likewise.
* gdb.ada/arrayidx.exp, gdb.ada/null_array.exp: Likewise.
* gdb.arch/mips-octeon-bbit.exp (single_step): Likewise.
(single_step_until): Likewise.
* gdb.arch/powerpc-d128-regs.exp: Likewise.
* gdb.arch/system-gcore.exp: Likewise.
* gdb.base/bigcore.exp (extract_heap): Likewise.
* gdb.base/break-on-linker-gcd-function.exp: Likewise.
* gdb.base/call-ar-st.exp: Likewise.
* gdb.base/call-rt-st.exp: Likewise.
* gdb.base/call-sc.exp, gdb.base/call-strs.exp: Likewise.
* gdb.base/callfuncs.exp, gdb.base/completion.exp: Likewise.
* gdb.base/condbreak.exp, gdb.base/constvars.exp: Likewise.
* gdb.base/corefile.exp: Likewise.
* gdb.base/dbx.exp (gdb_file_cmd): Likewise.
* gdb.base/exprs.exp, gdb.base/fileio.exp: Likewise.
* gdb.base/fixsection.exp: Likewise.
* gdb.base/funcargs.exp: Likewise.
* gdb.base/gcore-buffer-overflow.exp: Likewise.
* gdb.base/gcore-relro.exp: Likewise.
* gdb.base/gcore.exp, gdb.base/gdb11530.exp: Likewise.
* gdb.base/gdb11531.exp, gdb.base/gnu-ifunc.exp: Likewise.
* gdb.base/info-os.exp, gdb.base/info-proc.exp: Likewise.
* gdb.base/interp.exp, gdb.base/langs.exp:: Likewise.
* gdb.base/list.exp: Likewise.
(set_listsize): Likewise.
* gdb.base/logical.exp, gdb.base/mips_pro.exp: Likewise.
* gdb.base/miscexprs.exp, gdb.base/nodebug.exp: Likewise.
* gdb.base/opaque.exp, gdb.base/pointers.exp: Likewise.
* gdb.base/psymtab.exp, gdb.base/ptype.exp: Likewise.
* gdb.base/relational.exp, gdb.base/scope.exp: Likewise.
* gdb.base/setvar.exp: Likewise.
(test_set): Likewise.
* gdb.base/signals.exp, gdb.base/sizeof.exp: Likewise.
* gdb.base/solib-overlap.exp: Likewise.
* gdb.base/store.exp, gdb.base/structs.exp: Likewise.
* gdb.base/structs2.exp, gdb.base/volatile.exp: Likewise.
* gdb.base/watchpoint.exp (initialize): Likewise.
(test_simple_watchpoint): Likewise.
(test_disabling_watchpoints): Likewise.
(test_watchpoint_triggered_in_syscall): Likewise.
* gdb.base/whatis.exp, gdb.cp/ambiguous.exp: Likewise.
* gdb.cp/casts.exp, gdb.cp/ctti.exp: Likewise.
* gdb.cp/namespace.exp, gdb.cp/nsdecl.exp: Likewise.
* gdb.cp/psmang.exp, gdb.dwarf2/dw2-ranges.exp: Likewise.
* gdb.hp/gdb.aCC/optimize.exp: Likewise.
* gdb.hp/gdb.aCC/watch-cmd.exp: Likewise.
* gdb.hp/gdb.base-hp/callfwmall.exp: Likewise.
* gdb.hp/gdb.base-hp/pxdb.exp: Likewise.
* gdb.hp/gdb.compat/xdb1.exp: Likewise.
* gdb.hp/gdb.compat/xdb2.exp: Likewise.
* gdb.hp/gdb.compat/xdb3.exp: Likewise.
* gdb.hp/gdb.defects/bs14602.exp: Likewise.
* gdb.hp/gdb.defects/solib-d.exp: Likewise.
* gdb.mi/gdb792.exp: Likewise.
* gdb.mi/mi-inheritance-syntax-error.exp: Likewise.
* gdb.mi/mi-logging.exp, gdb.mi/mi-var-cp.exp : Likewise.
* gdb.mi/mi-var-rtti.exp, gdb.python/py-type.exp: Likewise.
* gdb.threads/gcore-thread.exp: Likewise.
(load_core): Likewise.
* gdb.threads/pthreads.exp (all_threads_running): Likewise.
(test_startup, check_control_c): Likewise.
* gdb.threads/sigstep-threads.exp: Likewise.
* gdb.threads/thread_check.exp: Likewise.
* gdb.trace/backtrace.exp, gdb.trace/change-loc.exp: Likewise.
* gdb.trace/circ.exp (run_trace_experiment): Likewise.
(set_a_tracepoint, trace_buffer_normal): Likewise.
(gdb_trace_circular_tests): Likewise.
* gdb.trace/collection.exp: Likewise.
* gdb.trace/disconnected-tracing.exp: Likewise.
* gdb.trace/infotrace.exp: Likewise.
* gdb.trace/mi-traceframe-changed.exp: Likewise.
* gdb.trace/mi-tracepoint-changed.exp: Likewise.
* gdb.trace/mi-tsv-changed.exp (test_create_delete_modify_tsv): Likewise.
* gdb.trace/packetlen.exp, gdb.trace/passc-dyn.exp: Likewise.
* gdb.trace/pending.exp, gdb.trace/report.exp: Likewise.
* gdb.trace/stap-trace.exp: Likewise.
* gdb.trace/status-stop.exp,gdb.trace/strace.exp: Likewise.
* gdb.trace/tfind.exp, gdb.trace/trace-break.exp: Likewise.
* gdb.trace/trace-buffer-size.exp: Likewise.
* gdb.trace/tspeed.exp, gdb.trace/tsv.exp: Likewise.
* gdb.trace/unavailable.exp: Likewise.
* gdb.trace/while-dyn.exp: Likewise.
* lib/fortran.exp (set_lang_fortran): Likewise.
* lib/gdb.exp (default_gdb_version, gdb_start_cmd): Likewise.
(gdb_breakpoint, gdb_reinitialize_dir): Likewise.
(default_gdb_start, get_compiler_info): Likewise.
(gdb_compile, gdb_compile_objc, gdb_reload, gdb_init): Likewise.
(get_debug_format, setup_xfail_format): Likewise.
(rerun_to_main, gdb_skip_float_test): Likewise.
(build_id_debug_filename_get, get_remotetimeout): Likewise.
* lib/java.exp (set_lang_java): Likewise.
* lib/mi-support.exp (default_mi_gdb_start): Likewise.
(mi_gdb_reinitialize_dir, mi_gdb_target_cmd): Likewise.
(mi_gdb_file_cmd, mi_gdb_test): Likewise.
(mi_run_cmd_full, mi_expect_interrupt): Likewise.
* lib/objc.exp (set_lang_objc): Likewise.
* lib/pascal.exp (set_lang_pascal): Likewise.
* lib/prompt.exp (default_prompt_gdb_start): Likewise.
* lib/trace-support.exp (gdb_trace_setactions, gdb_tfind_test): Likewise.
(gdb_readexpr, gdb_gettpnum, gdb_find_recursion_test_baseline): Likewise.
2013-03-14 14:34:06 +01:00
|
|
|
|
return 0
|
1999-04-16 03:35:26 +02:00
|
|
|
|
}
|
|
|
|
|
|
2015-07-25 00:32:45 +02:00
|
|
|
|
# Return the compiler_info string if no arg is provided.
|
|
|
|
|
# Otherwise the argument is a glob-style expression to match against
|
|
|
|
|
# compiler_info.
|
|
|
|
|
|
2005-04-12 22:14:35 +02:00
|
|
|
|
proc test_compiler_info { {compiler ""} } {
|
2003-11-17 16:00:20 +01:00
|
|
|
|
global compiler_info
|
2015-07-25 00:32:45 +02:00
|
|
|
|
get_compiler_info
|
2005-04-06 23:38:48 +02:00
|
|
|
|
|
2015-07-25 00:32:45 +02:00
|
|
|
|
# If no arg, return the compiler_info string.
|
|
|
|
|
if [string match "" $compiler] {
|
|
|
|
|
return $compiler_info
|
|
|
|
|
}
|
2005-04-06 23:38:48 +02:00
|
|
|
|
|
2003-11-17 16:00:20 +01:00
|
|
|
|
return [string match $compiler $compiler_info]
|
|
|
|
|
}
|
|
|
|
|
|
2009-11-13 23:51:59 +01:00
|
|
|
|
proc current_target_name { } {
|
|
|
|
|
global target_info
|
|
|
|
|
if [info exists target_info(target,name)] {
|
|
|
|
|
set answer $target_info(target,name)
|
|
|
|
|
} else {
|
|
|
|
|
set answer ""
|
|
|
|
|
}
|
|
|
|
|
return $answer
|
|
|
|
|
}
|
|
|
|
|
|
2002-05-07 02:45:46 +02:00
|
|
|
|
set gdb_wrapper_initialized 0
|
2009-11-13 23:51:59 +01:00
|
|
|
|
set gdb_wrapper_target ""
|
2002-05-07 02:45:46 +02:00
|
|
|
|
|
|
|
|
|
proc gdb_wrapper_init { args } {
|
2013-06-07 19:31:09 +02:00
|
|
|
|
global gdb_wrapper_initialized
|
|
|
|
|
global gdb_wrapper_file
|
|
|
|
|
global gdb_wrapper_flags
|
2009-11-13 23:51:59 +01:00
|
|
|
|
global gdb_wrapper_target
|
2002-05-07 02:45:46 +02:00
|
|
|
|
|
|
|
|
|
if { $gdb_wrapper_initialized == 1 } { return; }
|
|
|
|
|
|
|
|
|
|
if {[target_info exists needs_status_wrapper] && \
|
2002-05-23 23:25:42 +02:00
|
|
|
|
[target_info needs_status_wrapper] != "0"} {
|
2013-06-07 19:31:09 +02:00
|
|
|
|
set result [build_wrapper "testglue.o"]
|
2002-05-07 02:45:46 +02:00
|
|
|
|
if { $result != "" } {
|
2013-06-07 19:31:09 +02:00
|
|
|
|
set gdb_wrapper_file [lindex $result 0]
|
|
|
|
|
set gdb_wrapper_flags [lindex $result 1]
|
2002-05-07 02:45:46 +02:00
|
|
|
|
} else {
|
|
|
|
|
warning "Status wrapper failed to build."
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
set gdb_wrapper_initialized 1
|
2009-11-13 23:51:59 +01:00
|
|
|
|
set gdb_wrapper_target [current_target_name]
|
2002-05-07 02:45:46 +02:00
|
|
|
|
}
|
|
|
|
|
|
2017-08-14 20:31:09 +02:00
|
|
|
|
# Determine options that we always want to pass to the compiler.
|
|
|
|
|
gdb_caching_proc universal_compile_options {
|
|
|
|
|
set me "universal_compile_options"
|
|
|
|
|
set options {}
|
|
|
|
|
|
|
|
|
|
set src [standard_temp_file ccopts[pid].c]
|
|
|
|
|
set obj [standard_temp_file ccopts[pid].o]
|
|
|
|
|
|
|
|
|
|
gdb_produce_source $src {
|
|
|
|
|
int foo(void) { return 0; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# Try an option for disabling colored diagnostics. Some compilers
|
|
|
|
|
# yield colored diagnostics by default (when run from a tty) unless
|
|
|
|
|
# such an option is specified.
|
|
|
|
|
set opt "additional_flags=-fdiagnostics-color=never"
|
|
|
|
|
set lines [target_compile $src $obj object [list "quiet" $opt]]
|
|
|
|
|
if [string match "" $lines] then {
|
|
|
|
|
# Seems to have worked; use the option.
|
|
|
|
|
lappend options $opt
|
|
|
|
|
}
|
|
|
|
|
file delete $src
|
|
|
|
|
file delete $obj
|
|
|
|
|
|
|
|
|
|
verbose "$me: returning $options" 2
|
|
|
|
|
return $options
|
|
|
|
|
}
|
|
|
|
|
|
2018-09-12 12:52:09 +02:00
|
|
|
|
# Compile the code in $code to a file based on $name, using the flags
|
|
|
|
|
# $compile_flag as well as debug, nowarning and quiet.
|
|
|
|
|
# Return 1 if code can be compiled
|
2018-09-05 11:11:32 +02:00
|
|
|
|
# Leave the file name of the resulting object in the upvar object.
|
2018-09-12 12:52:09 +02:00
|
|
|
|
|
2018-09-05 11:11:32 +02:00
|
|
|
|
proc gdb_simple_compile {name code {type object} {compile_flags {}} {object obj}} {
|
|
|
|
|
upvar $object obj
|
2018-09-12 12:52:09 +02:00
|
|
|
|
|
|
|
|
|
switch -regexp -- $type {
|
|
|
|
|
"executable" {
|
|
|
|
|
set postfix "x"
|
|
|
|
|
}
|
|
|
|
|
"object" {
|
|
|
|
|
set postfix "o"
|
|
|
|
|
}
|
|
|
|
|
"preprocess" {
|
|
|
|
|
set postfix "i"
|
|
|
|
|
}
|
|
|
|
|
"assembly" {
|
|
|
|
|
set postfix "s"
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
set src [standard_temp_file $name-[pid].c]
|
|
|
|
|
set obj [standard_temp_file $name-[pid].$postfix]
|
|
|
|
|
set compile_flags [concat $compile_flags {debug nowarnings quiet}]
|
|
|
|
|
|
|
|
|
|
gdb_produce_source $src $code
|
|
|
|
|
|
|
|
|
|
verbose "$name: compiling testfile $src" 2
|
|
|
|
|
set lines [gdb_compile $src $obj $type $compile_flags]
|
|
|
|
|
|
|
|
|
|
file delete $src
|
|
|
|
|
|
|
|
|
|
if ![string match "" $lines] then {
|
|
|
|
|
verbose "$name: compilation failed, returning 0" 2
|
|
|
|
|
return 0
|
|
|
|
|
}
|
|
|
|
|
return 1
|
|
|
|
|
}
|
|
|
|
|
|
2018-09-05 11:11:32 +02:00
|
|
|
|
# Compile the code in $code to a file based on $name, using the flags
|
|
|
|
|
# $compile_flag as well as debug, nowarning and quiet.
|
|
|
|
|
# Return 1 if code can be compiled
|
|
|
|
|
# Delete all created files and objects.
|
|
|
|
|
|
|
|
|
|
proc gdb_can_simple_compile {name code {type object} {compile_flags ""}} {
|
|
|
|
|
set ret [gdb_simple_compile $name $code $type $compile_flags temp_obj]
|
|
|
|
|
file delete $temp_obj
|
|
|
|
|
return $ret
|
|
|
|
|
}
|
|
|
|
|
|
2008-06-27 18:42:19 +02:00
|
|
|
|
# Some targets need to always link a special object in. Save its path here.
|
|
|
|
|
global gdb_saved_set_unbuffered_mode_obj
|
|
|
|
|
set gdb_saved_set_unbuffered_mode_obj ""
|
|
|
|
|
|
2015-12-18 19:39:26 +01:00
|
|
|
|
# Compile source files specified by SOURCE into a binary of type TYPE at path
|
|
|
|
|
# DEST. gdb_compile is implemented using DejaGnu's target_compile, so the type
|
|
|
|
|
# parameter and most options are passed directly to it.
|
|
|
|
|
#
|
|
|
|
|
# The type can be one of the following:
|
|
|
|
|
#
|
|
|
|
|
# - object: Compile into an object file.
|
|
|
|
|
# - executable: Compile and link into an executable.
|
|
|
|
|
# - preprocess: Preprocess the source files.
|
|
|
|
|
# - assembly: Generate assembly listing.
|
|
|
|
|
#
|
|
|
|
|
# The following options are understood and processed by gdb_compile:
|
|
|
|
|
#
|
|
|
|
|
# - shlib=so_path: Add SO_PATH to the sources, and enable some target-specific
|
|
|
|
|
# quirks to be able to use shared libraries.
|
|
|
|
|
# - shlib_load: Link with appropriate libraries to allow the test to
|
|
|
|
|
# dynamically load libraries at runtime. For example, on Linux, this adds
|
|
|
|
|
# -ldl so that the test can use dlopen.
|
|
|
|
|
# - nowarnings: Inhibit all compiler warnings.
|
2019-02-13 13:28:38 +01:00
|
|
|
|
# - pie: Force creation of PIE executables.
|
2018-12-13 16:20:49 +01:00
|
|
|
|
# - nopie: Prevent creation of PIE executables.
|
2015-12-18 19:39:26 +01:00
|
|
|
|
#
|
|
|
|
|
# And here are some of the not too obscure options understood by DejaGnu that
|
|
|
|
|
# influence the compilation:
|
|
|
|
|
#
|
|
|
|
|
# - additional_flags=flag: Add FLAG to the compiler flags.
|
|
|
|
|
# - libs=library: Add LIBRARY to the libraries passed to the linker. The
|
|
|
|
|
# argument can be a file, in which case it's added to the sources, or a
|
|
|
|
|
# linker flag.
|
|
|
|
|
# - ldflags=flag: Add FLAG to the linker flags.
|
|
|
|
|
# - incdir=path: Add PATH to the searched include directories.
|
|
|
|
|
# - libdir=path: Add PATH to the linker searched directories.
|
|
|
|
|
# - ada, c++, f77: Compile the file as Ada, C++ or Fortran.
|
|
|
|
|
# - debug: Build with debug information.
|
|
|
|
|
# - optimize: Build with optimization.
|
|
|
|
|
|
1999-04-16 03:35:26 +02:00
|
|
|
|
proc gdb_compile {source dest type options} {
|
2013-06-07 19:31:09 +02:00
|
|
|
|
global GDB_TESTCASE_OPTIONS
|
|
|
|
|
global gdb_wrapper_file
|
|
|
|
|
global gdb_wrapper_flags
|
|
|
|
|
global gdb_wrapper_initialized
|
2008-06-27 18:42:19 +02:00
|
|
|
|
global srcdir
|
|
|
|
|
global objdir
|
|
|
|
|
global gdb_saved_set_unbuffered_mode_obj
|
1999-04-16 03:35:26 +02:00
|
|
|
|
|
2007-09-10 00:19:15 +02:00
|
|
|
|
set outdir [file dirname $dest]
|
|
|
|
|
|
|
|
|
|
# Add platform-specific options if a shared library was specified using
|
|
|
|
|
# "shlib=librarypath" in OPTIONS.
|
2018-01-18 19:42:46 +01:00
|
|
|
|
set new_options {}
|
2017-09-04 07:15:03 +02:00
|
|
|
|
if {[lsearch -exact $options rust] != -1} {
|
|
|
|
|
# -fdiagnostics-color is not a rustcc option.
|
|
|
|
|
} else {
|
|
|
|
|
set new_options [universal_compile_options]
|
|
|
|
|
}
|
2019-11-27 22:51:35 +01:00
|
|
|
|
|
|
|
|
|
# Place (and look for) Fortran `.mod` files in the output
|
|
|
|
|
# directory for this specific test.
|
|
|
|
|
if {[lsearch -exact $options f77] != -1 \
|
|
|
|
|
|| [lsearch -exact $options f90] != -1 } {
|
|
|
|
|
# Fortran compile.
|
|
|
|
|
set mod_path [standard_output_file ""]
|
|
|
|
|
lappend new_options "additional_flags=-J${mod_path}"
|
|
|
|
|
}
|
|
|
|
|
|
2007-09-10 00:19:15 +02:00
|
|
|
|
set shlib_found 0
|
2009-11-12 18:35:54 +01:00
|
|
|
|
set shlib_load 0
|
2019-01-21 11:43:53 +01:00
|
|
|
|
set getting_compiler_info 0
|
2007-09-10 00:19:15 +02:00
|
|
|
|
foreach opt $options {
|
2018-01-12 03:08:23 +01:00
|
|
|
|
if {[regexp {^shlib=(.*)} $opt dummy_var shlib_name]
|
|
|
|
|
&& $type == "executable"} {
|
2005-04-14 21:06:19 +02:00
|
|
|
|
if [test_compiler_info "xlc-*"] {
|
2007-05-16 16:21:47 +02:00
|
|
|
|
# IBM xlc compiler doesn't accept shared library named other
|
|
|
|
|
# than .so: use "-Wl," to bypass this
|
|
|
|
|
lappend source "-Wl,$shlib_name"
|
|
|
|
|
} elseif { ([istarget "*-*-mingw*"]
|
|
|
|
|
|| [istarget *-*-cygwin*]
|
|
|
|
|
|| [istarget *-*-pe*])} {
|
|
|
|
|
lappend source "${shlib_name}.a"
|
2005-04-14 21:06:19 +02:00
|
|
|
|
} else {
|
|
|
|
|
lappend source $shlib_name
|
|
|
|
|
}
|
2009-10-09 00:42:53 +02:00
|
|
|
|
if { $shlib_found == 0 } {
|
2005-04-14 21:06:19 +02:00
|
|
|
|
set shlib_found 1
|
2009-10-09 00:42:53 +02:00
|
|
|
|
if { ([istarget "*-*-mingw*"]
|
|
|
|
|
|| [istarget *-*-cygwin*]) } {
|
2009-10-03 00:25:26 +02:00
|
|
|
|
lappend new_options "additional_flags=-Wl,--enable-auto-import"
|
2009-10-09 00:42:53 +02:00
|
|
|
|
}
|
2015-07-25 00:24:37 +02:00
|
|
|
|
if { [test_compiler_info "gcc-*"] || [test_compiler_info "clang-*"] } {
|
|
|
|
|
# Undo debian's change in the default.
|
|
|
|
|
# Put it at the front to not override any user-provided
|
|
|
|
|
# value, and to make sure it appears in front of all the
|
|
|
|
|
# shlibs!
|
|
|
|
|
lappend new_options "early_flags=-Wl,--no-as-needed"
|
|
|
|
|
}
|
2005-04-14 21:06:19 +02:00
|
|
|
|
}
|
2018-01-12 03:08:23 +01:00
|
|
|
|
} elseif { $opt == "shlib_load" && $type == "executable" } {
|
2009-11-12 18:35:54 +01:00
|
|
|
|
set shlib_load 1
|
2019-01-21 11:43:53 +01:00
|
|
|
|
} elseif { $opt == "getting_compiler_info" } {
|
|
|
|
|
# If this is set, calling test_compiler_info will cause recursion.
|
|
|
|
|
set getting_compiler_info 1
|
2005-04-14 21:06:19 +02:00
|
|
|
|
} else {
|
|
|
|
|
lappend new_options $opt
|
|
|
|
|
}
|
2007-09-10 00:19:15 +02:00
|
|
|
|
}
|
2009-11-12 18:35:54 +01:00
|
|
|
|
|
2019-01-21 11:43:53 +01:00
|
|
|
|
# Ensure stack protector is disabled for GCC, as this causes problems with
|
|
|
|
|
# DWARF line numbering.
|
|
|
|
|
# See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88432
|
|
|
|
|
# This option defaults to on for Debian/Ubuntu.
|
|
|
|
|
if { $getting_compiler_info == 0
|
|
|
|
|
&& [test_compiler_info {gcc-*-*}]
|
|
|
|
|
&& !([test_compiler_info {gcc-[0-3]-*}]
|
2019-04-24 21:43:27 +02:00
|
|
|
|
|| [test_compiler_info {gcc-4-0-*}])
|
|
|
|
|
&& [lsearch -exact $options rust] == -1} {
|
2019-01-21 11:43:53 +01:00
|
|
|
|
# Put it at the front to not override any user-provided value.
|
|
|
|
|
lappend new_options "early_flags=-fno-stack-protector"
|
|
|
|
|
}
|
|
|
|
|
|
Make ftrace tests work with remote targets
When we build a shared library for testing, it is built differently
whether it is meant for the local system or a remote one. When it is
for the local system, the library is built with no SONAME. So when the
executable is built, roughly in this way:
$ gcc testfile.c /path/to/library.so
the executable will contain an absolute reference to the library. For
example:
$ readelf -a testsuite/gdb.python/py-shared | grep NEEDED
0x0000000000000001 (NEEDED) Shared library: [/home/emaisin/build/binutils-gdb/gdb/testsuite/gdb.python/py-shared-sl.sl]
When testing is done remotely, the absolute path obviously doesn't work.
Therefore, we build the library with an SONAME:
$ readelf -a testsuite/gdb.python/py-shared-sl.sl | grep SONAME
0x000000000000000e (SONAME) Library soname: [py-shared-sl.sl]
which ends up in the executable's NEEDED field:
$ readelf -a testsuite/gdb.python/py-shared | grep NEEDED
0x0000000000000001 (NEEDED) Shared library: [py-shared-sl.sl]
The executable and the library are then uploaded side-by-side on the
remote system. To allow the dynamic linker to find the shared library,
we have to add the special RPATH value $ORIGIN, which tells it to search
in the executable's directory:
$ readelf -a testsuite/gdb.python/py-shared | grep ORIGIN
0x000000000000000f (RPATH) Library rpath: [$ORIGIN]
The problem with the IPA library is that it doesn't have an SONAME,
making it very difficult to do testing on a remote board. When a
test executable is linked with it, it contains an absolute reference to
the library path. Therefore, unless the paths on the target are the
same as on the build system, it won't work.
To make it possible for tests using the IPA library to run test on
remote boards, I suggest adding an SONAME to libinproctrace.so. I don't
think it should be a big problem for users. All the libraries installed
on my system have an SONAME, so it should be fine if libinproctrace.so
does too.
As a consequence, native testing does not work anymore, since
executables do not contain the absolute path to the library anymore. To
keep them working, we can have gdb_load_shlibs copy the library to the
test directory when testing natively. That's done by modifying
gdb_load_shlibs. We also have to add RPATH=$ORIGIN to executables, even
when testing natively.
I think it's a good change in general, as it reduces the differences
between testing a native and a remote target. To further reduce those
differences, we can also always build test shared libraries with an
SONAME.
ftrace.exp and ftrace-lock.exp need to be modified slightly. The code
checks that the IPA library is loaded using the absolute path on the
build machine. That obviously doesn't work if the test is done
remotely, as the path will be different. I changed the tests to only
search for the library basename (e.g. libinproctrace.so).
gdb/gdbserver/ChangeLog:
* Makefile.in ($(IPA_LIB)): Set SONAME of the IPA lib.
gdb/testsuite/ChangeLog:
* gdb.trace/ftrace-lock.exp: Check for IPA basename instead of
absolute.
* gdb.trace/ftrace.exp: Likewise.
* lib/gdb.exp (gdb_compile): Set rpath $ORIGIN for non-remote
targets as well.
(gdb_compile_shlib): Set SONAME for non-remote targets as well.
(gdb_load_shlibs): Copy libraries to test directory when testing
natively. Only set solib-search-path if testing remotely.
* lib/mi-support.exp (mi_load_shlibs): Likewise.
2016-04-05 19:59:50 +02:00
|
|
|
|
# Because we link with libraries using their basename, we may need
|
|
|
|
|
# (depending on the platform) to set a special rpath value, to allow
|
|
|
|
|
# the executable to find the libraries it depends on.
|
|
|
|
|
if { $shlib_load || $shlib_found } {
|
2009-11-12 18:35:54 +01:00
|
|
|
|
if { ([istarget "*-*-mingw*"]
|
|
|
|
|
|| [istarget *-*-cygwin*]
|
2015-12-21 18:51:54 +01:00
|
|
|
|
|| [istarget *-*-pe*]) } {
|
2009-11-12 18:35:54 +01:00
|
|
|
|
# Do not need anything.
|
2011-09-22 06:58:22 +02:00
|
|
|
|
} elseif { [istarget *-*-freebsd*] || [istarget *-*-openbsd*] } {
|
2010-10-12 20:12:49 +02:00
|
|
|
|
lappend new_options "ldflags=-Wl,-rpath,${outdir}"
|
2010-03-12 20:17:01 +01:00
|
|
|
|
} elseif { [istarget arm*-*-symbianelf*] } {
|
|
|
|
|
if { $shlib_load } {
|
|
|
|
|
lappend new_options "libs=-ldl"
|
|
|
|
|
}
|
2009-11-12 18:35:54 +01:00
|
|
|
|
} else {
|
|
|
|
|
if { $shlib_load } {
|
|
|
|
|
lappend new_options "libs=-ldl"
|
|
|
|
|
}
|
2010-10-12 20:12:49 +02:00
|
|
|
|
lappend new_options "ldflags=-Wl,-rpath,\\\$ORIGIN"
|
2009-11-12 18:35:54 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
2007-09-10 00:19:15 +02:00
|
|
|
|
set options $new_options
|
2005-04-14 21:06:19 +02:00
|
|
|
|
|
1999-04-16 03:35:26 +02:00
|
|
|
|
if [info exists GDB_TESTCASE_OPTIONS] {
|
2013-06-07 19:31:09 +02:00
|
|
|
|
lappend options "additional_flags=$GDB_TESTCASE_OPTIONS"
|
1999-04-16 03:35:26 +02:00
|
|
|
|
}
|
|
|
|
|
verbose "options are $options"
|
|
|
|
|
verbose "source is $source $dest $type $options"
|
|
|
|
|
|
2002-05-07 02:45:46 +02:00
|
|
|
|
if { $gdb_wrapper_initialized == 0 } { gdb_wrapper_init }
|
|
|
|
|
|
|
|
|
|
if {[target_info exists needs_status_wrapper] && \
|
|
|
|
|
[target_info needs_status_wrapper] != "0" && \
|
|
|
|
|
[info exists gdb_wrapper_file]} {
|
|
|
|
|
lappend options "libs=${gdb_wrapper_file}"
|
|
|
|
|
lappend options "ldflags=${gdb_wrapper_flags}"
|
|
|
|
|
}
|
|
|
|
|
|
2006-03-07 16:23:33 +01:00
|
|
|
|
# Replace the "nowarnings" option with the appropriate additional_flags
|
|
|
|
|
# to disable compiler warnings.
|
|
|
|
|
set nowarnings [lsearch -exact $options nowarnings]
|
|
|
|
|
if {$nowarnings != -1} {
|
|
|
|
|
if [target_info exists gdb,nowarnings_flag] {
|
|
|
|
|
set flag "additional_flags=[target_info gdb,nowarnings_flag]"
|
|
|
|
|
} else {
|
|
|
|
|
set flag "additional_flags=-w"
|
|
|
|
|
}
|
|
|
|
|
set options [lreplace $options $nowarnings $nowarnings $flag]
|
|
|
|
|
}
|
|
|
|
|
|
2019-02-13 13:28:38 +01:00
|
|
|
|
# Replace the "pie" option with the appropriate compiler and linker flags
|
|
|
|
|
# to enable PIE executables.
|
|
|
|
|
set pie [lsearch -exact $options pie]
|
|
|
|
|
if {$pie != -1} {
|
|
|
|
|
if [target_info exists gdb,pie_flag] {
|
|
|
|
|
set flag "additional_flags=[target_info gdb,pie_flag]"
|
|
|
|
|
} else {
|
|
|
|
|
# For safety, use fPIE rather than fpie. On AArch64, m68k, PowerPC
|
|
|
|
|
# and SPARC, fpie can cause compile errors due to the GOT exceeding
|
|
|
|
|
# a maximum size. On other architectures the two flags are
|
|
|
|
|
# identical (see the GCC manual). Note Debian9 and Ubuntu16.10
|
|
|
|
|
# onwards default GCC to using fPIE. If you do require fpie, then
|
|
|
|
|
# it can be set using the pie_flag.
|
|
|
|
|
set flag "additional_flags=-fPIE"
|
|
|
|
|
}
|
|
|
|
|
set options [lreplace $options $pie $pie $flag]
|
|
|
|
|
|
|
|
|
|
if [target_info exists gdb,pie_ldflag] {
|
|
|
|
|
set flag "ldflags=[target_info gdb,pie_ldflag]"
|
|
|
|
|
} else {
|
|
|
|
|
set flag "ldflags=-pie"
|
|
|
|
|
}
|
|
|
|
|
lappend options "$flag"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# Replace the "nopie" option with the appropriate linker flag to disable
|
|
|
|
|
# PIE executables. There are no compiler flags for this option.
|
2018-12-13 16:20:49 +01:00
|
|
|
|
set nopie [lsearch -exact $options nopie]
|
|
|
|
|
if {$nopie != -1} {
|
|
|
|
|
if [target_info exists gdb,nopie_flag] {
|
|
|
|
|
set flag "ldflags=[target_info gdb,nopie_flag]"
|
|
|
|
|
} else {
|
|
|
|
|
set flag "ldflags=-no-pie"
|
|
|
|
|
}
|
|
|
|
|
set options [lreplace $options $nopie $nopie $flag]
|
|
|
|
|
}
|
|
|
|
|
|
2008-06-27 18:42:19 +02:00
|
|
|
|
if { $type == "executable" } {
|
|
|
|
|
if { ([istarget "*-*-mingw*"]
|
2009-06-18 00:46:09 +02:00
|
|
|
|
|| [istarget "*-*-*djgpp"]
|
2008-06-27 18:42:19 +02:00
|
|
|
|
|| [istarget "*-*-cygwin*"])} {
|
|
|
|
|
# Force output to unbuffered mode, by linking in an object file
|
|
|
|
|
# with a global contructor that calls setvbuf.
|
|
|
|
|
#
|
|
|
|
|
# Compile the special object seperatelly for two reasons:
|
|
|
|
|
# 1) Insulate it from $options.
|
|
|
|
|
# 2) Avoid compiling it for every gdb_compile invocation,
|
|
|
|
|
# which is time consuming, especially if we're remote
|
|
|
|
|
# host testing.
|
|
|
|
|
#
|
|
|
|
|
if { $gdb_saved_set_unbuffered_mode_obj == "" } {
|
|
|
|
|
verbose "compiling gdb_saved_set_unbuffered_obj"
|
|
|
|
|
set unbuf_src ${srcdir}/lib/set_unbuffered_mode.c
|
|
|
|
|
set unbuf_obj ${objdir}/set_unbuffered_mode.o
|
|
|
|
|
|
|
|
|
|
set result [gdb_compile "${unbuf_src}" "${unbuf_obj}" object {nowarnings}]
|
|
|
|
|
if { $result != "" } {
|
|
|
|
|
return $result
|
|
|
|
|
}
|
2013-07-18 07:07:25 +02:00
|
|
|
|
if {[is_remote host]} {
|
|
|
|
|
set gdb_saved_set_unbuffered_mode_obj set_unbuffered_mode_saved.o
|
|
|
|
|
} else {
|
|
|
|
|
set gdb_saved_set_unbuffered_mode_obj ${objdir}/set_unbuffered_mode_saved.o
|
|
|
|
|
}
|
2008-06-27 18:42:19 +02:00
|
|
|
|
# Link a copy of the output object, because the
|
|
|
|
|
# original may be automatically deleted.
|
2013-07-18 07:07:25 +02:00
|
|
|
|
remote_download host $unbuf_obj $gdb_saved_set_unbuffered_mode_obj
|
2008-06-27 18:42:19 +02:00
|
|
|
|
} else {
|
|
|
|
|
verbose "gdb_saved_set_unbuffered_obj already compiled"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# Rely on the internal knowledge that the global ctors are ran in
|
|
|
|
|
# reverse link order. In that case, we can use ldflags to
|
|
|
|
|
# avoid copying the object file to the host multiple
|
|
|
|
|
# times.
|
2009-10-02 23:28:34 +02:00
|
|
|
|
# This object can only be added if standard libraries are
|
|
|
|
|
# used. Thus, we need to disable it if -nostdlib option is used
|
|
|
|
|
if {[lsearch -regexp $options "-nostdlib"] < 0 } {
|
|
|
|
|
lappend options "ldflags=$gdb_saved_set_unbuffered_mode_obj"
|
|
|
|
|
}
|
2008-06-27 18:42:19 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2013-06-07 19:31:09 +02:00
|
|
|
|
set result [target_compile $source $dest $type $options]
|
2007-05-16 16:21:47 +02:00
|
|
|
|
|
|
|
|
|
# Prune uninteresting compiler (and linker) output.
|
|
|
|
|
regsub "Creating library file: \[^\r\n\]*\[\r\n\]+" $result "" result
|
|
|
|
|
|
2013-06-07 19:31:09 +02:00
|
|
|
|
regsub "\[\r\n\]*$" "$result" "" result
|
|
|
|
|
regsub "^\[\r\n\]*" "$result" "" result
|
* lib/gdb.exp (gdb_compile_test): New.
(skip_ada_tests, skip_java_tests): New.
(gdb_compile): Use gdb_compile_test for f77.
* lib/ada.exp (gdb_compile_ada): Use gdb_compile_test to record result.
* lib/java.exp (compile_java_from_source): Remove runtests check,
use gdb_compile_test to record result.
* gdb.ada/packed_array.exp, gdb.ada/fixed_points.exp,
gdb.ada/exec_changed.exp, gdb.ada/start.exp,
gdb.ada/watch_arg.exp, gdb.ada/null_record.exp,
gdb.ada/array_return.exp, gdb.ada/arrayidx.exp,
gdb.mi/mi-var-child-f.exp, gdb.fortran/types.exp,
gdb.fortran/array-element.exp, gdb.fortran/subarray.exp,
gdb.fortran/derived-type.exp, gdb.fortran/exprs.exp,
gdb.java/jmisc.exp, gdb.java/jmisc1.exp, gdb.java/jprint.exp,
gdb.java/jv-print.exp, gdb.java/jmain.exp: Add language skip,
adjust gdb_compile invocations.
2009-11-10 11:16:10 +01:00
|
|
|
|
|
2019-08-05 12:51:58 +02:00
|
|
|
|
if { $type == "executable" && $result == "" \
|
|
|
|
|
&& ($nopie != -1 || $pie != -1) } {
|
|
|
|
|
set is_pie [exec_is_pie "$dest"]
|
|
|
|
|
if { $nopie != -1 && $is_pie == 1 } {
|
2019-07-30 09:42:07 +02:00
|
|
|
|
set result "nopie failed to prevent PIE executable"
|
2019-08-05 12:51:58 +02:00
|
|
|
|
} elseif { $pie != -1 && $is_pie == 0 } {
|
|
|
|
|
set result "pie failed to generate PIE executable"
|
2019-07-30 09:42:07 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
* lib/gdb.exp (gdb_compile_test): New.
(skip_ada_tests, skip_java_tests): New.
(gdb_compile): Use gdb_compile_test for f77.
* lib/ada.exp (gdb_compile_ada): Use gdb_compile_test to record result.
* lib/java.exp (compile_java_from_source): Remove runtests check,
use gdb_compile_test to record result.
* gdb.ada/packed_array.exp, gdb.ada/fixed_points.exp,
gdb.ada/exec_changed.exp, gdb.ada/start.exp,
gdb.ada/watch_arg.exp, gdb.ada/null_record.exp,
gdb.ada/array_return.exp, gdb.ada/arrayidx.exp,
gdb.mi/mi-var-child-f.exp, gdb.fortran/types.exp,
gdb.fortran/array-element.exp, gdb.fortran/subarray.exp,
gdb.fortran/derived-type.exp, gdb.fortran/exprs.exp,
gdb.java/jmisc.exp, gdb.java/jmisc1.exp, gdb.java/jprint.exp,
gdb.java/jv-print.exp, gdb.java/jmain.exp: Add language skip,
adjust gdb_compile invocations.
2009-11-10 11:16:10 +01:00
|
|
|
|
if {[lsearch $options quiet] < 0} {
|
|
|
|
|
# We shall update this on a per language basis, to avoid
|
|
|
|
|
# changing the entire testsuite in one go.
|
|
|
|
|
if {[lsearch $options f77] >= 0} {
|
|
|
|
|
gdb_compile_test $source $result
|
|
|
|
|
} elseif { $result != "" } {
|
|
|
|
|
clone_output "gdb compile failed, $result"
|
|
|
|
|
}
|
1999-04-16 03:35:26 +02:00
|
|
|
|
}
|
gdb/testsuite/
* config/monitor.exp (gdb_target_cmd): Remove semicolon after
'return'.
(gdb_target_monitor, gdb_load): Likewise.
* config/sid.exp (gdb_load): Likewise.
* config/slite.exp (gdb_load): Likewise.
* config/vx.exp (gdb_start, spawn_vxgdb): Likewise.
* gdb.ada/arrayidx.exp, gdb.ada/null_array.exp: Likewise.
* gdb.arch/mips-octeon-bbit.exp (single_step): Likewise.
(single_step_until): Likewise.
* gdb.arch/powerpc-d128-regs.exp: Likewise.
* gdb.arch/system-gcore.exp: Likewise.
* gdb.base/bigcore.exp (extract_heap): Likewise.
* gdb.base/break-on-linker-gcd-function.exp: Likewise.
* gdb.base/call-ar-st.exp: Likewise.
* gdb.base/call-rt-st.exp: Likewise.
* gdb.base/call-sc.exp, gdb.base/call-strs.exp: Likewise.
* gdb.base/callfuncs.exp, gdb.base/completion.exp: Likewise.
* gdb.base/condbreak.exp, gdb.base/constvars.exp: Likewise.
* gdb.base/corefile.exp: Likewise.
* gdb.base/dbx.exp (gdb_file_cmd): Likewise.
* gdb.base/exprs.exp, gdb.base/fileio.exp: Likewise.
* gdb.base/fixsection.exp: Likewise.
* gdb.base/funcargs.exp: Likewise.
* gdb.base/gcore-buffer-overflow.exp: Likewise.
* gdb.base/gcore-relro.exp: Likewise.
* gdb.base/gcore.exp, gdb.base/gdb11530.exp: Likewise.
* gdb.base/gdb11531.exp, gdb.base/gnu-ifunc.exp: Likewise.
* gdb.base/info-os.exp, gdb.base/info-proc.exp: Likewise.
* gdb.base/interp.exp, gdb.base/langs.exp:: Likewise.
* gdb.base/list.exp: Likewise.
(set_listsize): Likewise.
* gdb.base/logical.exp, gdb.base/mips_pro.exp: Likewise.
* gdb.base/miscexprs.exp, gdb.base/nodebug.exp: Likewise.
* gdb.base/opaque.exp, gdb.base/pointers.exp: Likewise.
* gdb.base/psymtab.exp, gdb.base/ptype.exp: Likewise.
* gdb.base/relational.exp, gdb.base/scope.exp: Likewise.
* gdb.base/setvar.exp: Likewise.
(test_set): Likewise.
* gdb.base/signals.exp, gdb.base/sizeof.exp: Likewise.
* gdb.base/solib-overlap.exp: Likewise.
* gdb.base/store.exp, gdb.base/structs.exp: Likewise.
* gdb.base/structs2.exp, gdb.base/volatile.exp: Likewise.
* gdb.base/watchpoint.exp (initialize): Likewise.
(test_simple_watchpoint): Likewise.
(test_disabling_watchpoints): Likewise.
(test_watchpoint_triggered_in_syscall): Likewise.
* gdb.base/whatis.exp, gdb.cp/ambiguous.exp: Likewise.
* gdb.cp/casts.exp, gdb.cp/ctti.exp: Likewise.
* gdb.cp/namespace.exp, gdb.cp/nsdecl.exp: Likewise.
* gdb.cp/psmang.exp, gdb.dwarf2/dw2-ranges.exp: Likewise.
* gdb.hp/gdb.aCC/optimize.exp: Likewise.
* gdb.hp/gdb.aCC/watch-cmd.exp: Likewise.
* gdb.hp/gdb.base-hp/callfwmall.exp: Likewise.
* gdb.hp/gdb.base-hp/pxdb.exp: Likewise.
* gdb.hp/gdb.compat/xdb1.exp: Likewise.
* gdb.hp/gdb.compat/xdb2.exp: Likewise.
* gdb.hp/gdb.compat/xdb3.exp: Likewise.
* gdb.hp/gdb.defects/bs14602.exp: Likewise.
* gdb.hp/gdb.defects/solib-d.exp: Likewise.
* gdb.mi/gdb792.exp: Likewise.
* gdb.mi/mi-inheritance-syntax-error.exp: Likewise.
* gdb.mi/mi-logging.exp, gdb.mi/mi-var-cp.exp : Likewise.
* gdb.mi/mi-var-rtti.exp, gdb.python/py-type.exp: Likewise.
* gdb.threads/gcore-thread.exp: Likewise.
(load_core): Likewise.
* gdb.threads/pthreads.exp (all_threads_running): Likewise.
(test_startup, check_control_c): Likewise.
* gdb.threads/sigstep-threads.exp: Likewise.
* gdb.threads/thread_check.exp: Likewise.
* gdb.trace/backtrace.exp, gdb.trace/change-loc.exp: Likewise.
* gdb.trace/circ.exp (run_trace_experiment): Likewise.
(set_a_tracepoint, trace_buffer_normal): Likewise.
(gdb_trace_circular_tests): Likewise.
* gdb.trace/collection.exp: Likewise.
* gdb.trace/disconnected-tracing.exp: Likewise.
* gdb.trace/infotrace.exp: Likewise.
* gdb.trace/mi-traceframe-changed.exp: Likewise.
* gdb.trace/mi-tracepoint-changed.exp: Likewise.
* gdb.trace/mi-tsv-changed.exp (test_create_delete_modify_tsv): Likewise.
* gdb.trace/packetlen.exp, gdb.trace/passc-dyn.exp: Likewise.
* gdb.trace/pending.exp, gdb.trace/report.exp: Likewise.
* gdb.trace/stap-trace.exp: Likewise.
* gdb.trace/status-stop.exp,gdb.trace/strace.exp: Likewise.
* gdb.trace/tfind.exp, gdb.trace/trace-break.exp: Likewise.
* gdb.trace/trace-buffer-size.exp: Likewise.
* gdb.trace/tspeed.exp, gdb.trace/tsv.exp: Likewise.
* gdb.trace/unavailable.exp: Likewise.
* gdb.trace/while-dyn.exp: Likewise.
* lib/fortran.exp (set_lang_fortran): Likewise.
* lib/gdb.exp (default_gdb_version, gdb_start_cmd): Likewise.
(gdb_breakpoint, gdb_reinitialize_dir): Likewise.
(default_gdb_start, get_compiler_info): Likewise.
(gdb_compile, gdb_compile_objc, gdb_reload, gdb_init): Likewise.
(get_debug_format, setup_xfail_format): Likewise.
(rerun_to_main, gdb_skip_float_test): Likewise.
(build_id_debug_filename_get, get_remotetimeout): Likewise.
* lib/java.exp (set_lang_java): Likewise.
* lib/mi-support.exp (default_mi_gdb_start): Likewise.
(mi_gdb_reinitialize_dir, mi_gdb_target_cmd): Likewise.
(mi_gdb_file_cmd, mi_gdb_test): Likewise.
(mi_run_cmd_full, mi_expect_interrupt): Likewise.
* lib/objc.exp (set_lang_objc): Likewise.
* lib/pascal.exp (set_lang_pascal): Likewise.
* lib/prompt.exp (default_prompt_gdb_start): Likewise.
* lib/trace-support.exp (gdb_trace_setactions, gdb_tfind_test): Likewise.
(gdb_readexpr, gdb_gettpnum, gdb_find_recursion_test_baseline): Likewise.
2013-03-14 14:34:06 +01:00
|
|
|
|
return $result
|
1999-04-16 03:35:26 +02:00
|
|
|
|
}
|
|
|
|
|
|
2002-08-30 00:36:52 +02:00
|
|
|
|
|
|
|
|
|
# This is just like gdb_compile, above, except that it tries compiling
|
|
|
|
|
# against several different thread libraries, to see which one this
|
|
|
|
|
# system has.
|
|
|
|
|
proc gdb_compile_pthreads {source dest type options} {
|
2019-08-22 04:32:12 +02:00
|
|
|
|
if {$type != "executable"} {
|
|
|
|
|
return [gdb_compile $source $dest $type $options]
|
|
|
|
|
}
|
2002-09-04 00:29:14 +02:00
|
|
|
|
set built_binfile 0
|
2002-08-30 00:36:52 +02:00
|
|
|
|
set why_msg "unrecognized error"
|
2010-03-03 23:19:05 +01:00
|
|
|
|
foreach lib {-lpthreads -lpthread -lthread ""} {
|
2002-08-30 00:36:52 +02:00
|
|
|
|
# This kind of wipes out whatever libs the caller may have
|
|
|
|
|
# set. Or maybe theirs will override ours. How infelicitous.
|
2003-01-05 00:05:05 +01:00
|
|
|
|
set options_with_lib [concat $options [list libs=$lib quiet]]
|
2002-08-30 00:36:52 +02:00
|
|
|
|
set ccout [gdb_compile $source $dest $type $options_with_lib]
|
|
|
|
|
switch -regexp -- $ccout {
|
|
|
|
|
".*no posix threads support.*" {
|
|
|
|
|
set why_msg "missing threads include file"
|
|
|
|
|
break
|
|
|
|
|
}
|
|
|
|
|
".*cannot open -lpthread.*" {
|
|
|
|
|
set why_msg "missing runtime threads library"
|
|
|
|
|
}
|
|
|
|
|
".*Can't find library for -lpthread.*" {
|
|
|
|
|
set why_msg "missing runtime threads library"
|
|
|
|
|
}
|
|
|
|
|
{^$} {
|
|
|
|
|
pass "successfully compiled posix threads test case"
|
|
|
|
|
set built_binfile 1
|
|
|
|
|
break
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2002-09-04 00:29:14 +02:00
|
|
|
|
if {!$built_binfile} {
|
2016-12-01 21:40:05 +01:00
|
|
|
|
unsupported "couldn't compile [file tail $source]: ${why_msg}"
|
2002-08-30 00:36:52 +02:00
|
|
|
|
return -1
|
|
|
|
|
}
|
2005-04-14 21:06:19 +02:00
|
|
|
|
}
|
|
|
|
|
|
2013-12-10 18:04:17 +01:00
|
|
|
|
# Build a shared library from SOURCES.
|
2005-04-14 21:06:19 +02:00
|
|
|
|
|
|
|
|
|
proc gdb_compile_shlib {sources dest options} {
|
|
|
|
|
set obj_options $options
|
|
|
|
|
|
2013-12-10 18:04:17 +01:00
|
|
|
|
set info_options ""
|
|
|
|
|
if { [lsearch -exact $options "c++"] >= 0 } {
|
|
|
|
|
set info_options "c++"
|
|
|
|
|
}
|
|
|
|
|
if [get_compiler_info ${info_options}] {
|
|
|
|
|
return -1
|
|
|
|
|
}
|
|
|
|
|
|
2005-04-14 21:06:19 +02:00
|
|
|
|
switch -glob [test_compiler_info] {
|
|
|
|
|
"xlc-*" {
|
|
|
|
|
lappend obj_options "additional_flags=-qpic"
|
|
|
|
|
}
|
2014-08-27 18:40:21 +02:00
|
|
|
|
"clang-*" {
|
|
|
|
|
if { !([istarget "*-*-cygwin*"]
|
|
|
|
|
|| [istarget "*-*-mingw*"]) } {
|
|
|
|
|
lappend obj_options "additional_flags=-fpic"
|
|
|
|
|
}
|
|
|
|
|
}
|
2005-04-14 21:06:19 +02:00
|
|
|
|
"gcc-*" {
|
|
|
|
|
if { !([istarget "powerpc*-*-aix*"]
|
2006-12-30 21:32:47 +01:00
|
|
|
|
|| [istarget "rs6000*-*-aix*"]
|
|
|
|
|
|| [istarget "*-*-cygwin*"]
|
|
|
|
|
|| [istarget "*-*-mingw*"]
|
|
|
|
|
|| [istarget "*-*-pe*"]) } {
|
2005-04-14 21:06:19 +02:00
|
|
|
|
lappend obj_options "additional_flags=-fpic"
|
|
|
|
|
}
|
|
|
|
|
}
|
2016-04-18 11:49:07 +02:00
|
|
|
|
"icc-*" {
|
|
|
|
|
lappend obj_options "additional_flags=-fpic"
|
|
|
|
|
}
|
2005-04-14 21:06:19 +02:00
|
|
|
|
default {
|
2015-12-21 18:51:54 +01:00
|
|
|
|
# don't know what the compiler is...
|
2005-04-14 21:06:19 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
set outdir [file dirname $dest]
|
|
|
|
|
set objects ""
|
|
|
|
|
foreach source $sources {
|
2019-03-27 22:00:21 +01:00
|
|
|
|
set sourcebase [file tail $source]
|
|
|
|
|
if {[file extension $source] == ".o"} {
|
|
|
|
|
# Already a .o file.
|
|
|
|
|
lappend objects $source
|
|
|
|
|
} elseif {[gdb_compile $source "${outdir}/${sourcebase}.o" object \
|
|
|
|
|
$obj_options] != ""} {
|
|
|
|
|
return -1
|
|
|
|
|
} else {
|
|
|
|
|
lappend objects ${outdir}/${sourcebase}.o
|
|
|
|
|
}
|
2005-04-14 21:06:19 +02:00
|
|
|
|
}
|
|
|
|
|
|
2015-12-21 18:51:54 +01:00
|
|
|
|
set link_options $options
|
|
|
|
|
if [test_compiler_info "xlc-*"] {
|
|
|
|
|
lappend link_options "additional_flags=-qmkshrobj"
|
2005-04-14 21:06:19 +02:00
|
|
|
|
} else {
|
2015-12-21 18:51:54 +01:00
|
|
|
|
lappend link_options "additional_flags=-shared"
|
|
|
|
|
|
|
|
|
|
if { ([istarget "*-*-mingw*"]
|
|
|
|
|
|| [istarget *-*-cygwin*]
|
|
|
|
|
|| [istarget *-*-pe*]) } {
|
|
|
|
|
if { [is_remote host] } {
|
|
|
|
|
set name [file tail ${dest}]
|
|
|
|
|
} else {
|
|
|
|
|
set name ${dest}
|
|
|
|
|
}
|
|
|
|
|
lappend link_options "additional_flags=-Wl,--out-implib,${name}.a"
|
Make ftrace tests work with remote targets
When we build a shared library for testing, it is built differently
whether it is meant for the local system or a remote one. When it is
for the local system, the library is built with no SONAME. So when the
executable is built, roughly in this way:
$ gcc testfile.c /path/to/library.so
the executable will contain an absolute reference to the library. For
example:
$ readelf -a testsuite/gdb.python/py-shared | grep NEEDED
0x0000000000000001 (NEEDED) Shared library: [/home/emaisin/build/binutils-gdb/gdb/testsuite/gdb.python/py-shared-sl.sl]
When testing is done remotely, the absolute path obviously doesn't work.
Therefore, we build the library with an SONAME:
$ readelf -a testsuite/gdb.python/py-shared-sl.sl | grep SONAME
0x000000000000000e (SONAME) Library soname: [py-shared-sl.sl]
which ends up in the executable's NEEDED field:
$ readelf -a testsuite/gdb.python/py-shared | grep NEEDED
0x0000000000000001 (NEEDED) Shared library: [py-shared-sl.sl]
The executable and the library are then uploaded side-by-side on the
remote system. To allow the dynamic linker to find the shared library,
we have to add the special RPATH value $ORIGIN, which tells it to search
in the executable's directory:
$ readelf -a testsuite/gdb.python/py-shared | grep ORIGIN
0x000000000000000f (RPATH) Library rpath: [$ORIGIN]
The problem with the IPA library is that it doesn't have an SONAME,
making it very difficult to do testing on a remote board. When a
test executable is linked with it, it contains an absolute reference to
the library path. Therefore, unless the paths on the target are the
same as on the build system, it won't work.
To make it possible for tests using the IPA library to run test on
remote boards, I suggest adding an SONAME to libinproctrace.so. I don't
think it should be a big problem for users. All the libraries installed
on my system have an SONAME, so it should be fine if libinproctrace.so
does too.
As a consequence, native testing does not work anymore, since
executables do not contain the absolute path to the library anymore. To
keep them working, we can have gdb_load_shlibs copy the library to the
test directory when testing natively. That's done by modifying
gdb_load_shlibs. We also have to add RPATH=$ORIGIN to executables, even
when testing natively.
I think it's a good change in general, as it reduces the differences
between testing a native and a remote target. To further reduce those
differences, we can also always build test shared libraries with an
SONAME.
ftrace.exp and ftrace-lock.exp need to be modified slightly. The code
checks that the IPA library is loaded using the absolute path on the
build machine. That obviously doesn't work if the test is done
remotely, as the path will be different. I changed the tests to only
search for the library basename (e.g. libinproctrace.so).
gdb/gdbserver/ChangeLog:
* Makefile.in ($(IPA_LIB)): Set SONAME of the IPA lib.
gdb/testsuite/ChangeLog:
* gdb.trace/ftrace-lock.exp: Check for IPA basename instead of
absolute.
* gdb.trace/ftrace.exp: Likewise.
* lib/gdb.exp (gdb_compile): Set rpath $ORIGIN for non-remote
targets as well.
(gdb_compile_shlib): Set SONAME for non-remote targets as well.
(gdb_load_shlibs): Copy libraries to test directory when testing
natively. Only set solib-search-path if testing remotely.
* lib/mi-support.exp (mi_load_shlibs): Likewise.
2016-04-05 19:59:50 +02:00
|
|
|
|
} else {
|
|
|
|
|
# Set the soname of the library. This causes the linker on ELF
|
|
|
|
|
# systems to create the DT_NEEDED entry in the executable referring
|
|
|
|
|
# to the soname of the library, and not its absolute path. This
|
|
|
|
|
# (using the absolute path) would be problem when testing on a
|
|
|
|
|
# remote target.
|
|
|
|
|
#
|
|
|
|
|
# In conjunction with setting the soname, we add the special
|
|
|
|
|
# rpath=$ORIGIN value when building the executable, so that it's
|
|
|
|
|
# able to find the library in its own directory.
|
2015-12-21 18:51:54 +01:00
|
|
|
|
set destbase [file tail $dest]
|
|
|
|
|
lappend link_options "additional_flags=-Wl,-soname,$destbase"
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if {[gdb_compile "${objects}" "${dest}" executable $link_options] != ""} {
|
|
|
|
|
return -1
|
2005-04-14 21:06:19 +02:00
|
|
|
|
}
|
2015-12-21 18:51:54 +01:00
|
|
|
|
if { [is_remote host]
|
|
|
|
|
&& ([istarget "*-*-mingw*"]
|
|
|
|
|
|| [istarget *-*-cygwin*]
|
|
|
|
|
|| [istarget *-*-pe*]) } {
|
|
|
|
|
set dest_tail_name [file tail ${dest}]
|
|
|
|
|
remote_upload host $dest_tail_name.a ${dest}.a
|
|
|
|
|
remote_file host delete $dest_tail_name.a
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return ""
|
2002-08-30 00:36:52 +02:00
|
|
|
|
}
|
|
|
|
|
|
2011-07-15 16:11:22 +02:00
|
|
|
|
# This is just like gdb_compile_shlib, above, except that it tries compiling
|
|
|
|
|
# against several different thread libraries, to see which one this
|
|
|
|
|
# system has.
|
|
|
|
|
proc gdb_compile_shlib_pthreads {sources dest options} {
|
|
|
|
|
set built_binfile 0
|
|
|
|
|
set why_msg "unrecognized error"
|
|
|
|
|
foreach lib {-lpthreads -lpthread -lthread ""} {
|
|
|
|
|
# This kind of wipes out whatever libs the caller may have
|
|
|
|
|
# set. Or maybe theirs will override ours. How infelicitous.
|
|
|
|
|
set options_with_lib [concat $options [list libs=$lib quiet]]
|
|
|
|
|
set ccout [gdb_compile_shlib $sources $dest $options_with_lib]
|
|
|
|
|
switch -regexp -- $ccout {
|
|
|
|
|
".*no posix threads support.*" {
|
|
|
|
|
set why_msg "missing threads include file"
|
|
|
|
|
break
|
|
|
|
|
}
|
|
|
|
|
".*cannot open -lpthread.*" {
|
|
|
|
|
set why_msg "missing runtime threads library"
|
|
|
|
|
}
|
|
|
|
|
".*Can't find library for -lpthread.*" {
|
|
|
|
|
set why_msg "missing runtime threads library"
|
|
|
|
|
}
|
|
|
|
|
{^$} {
|
|
|
|
|
pass "successfully compiled posix threads test case"
|
|
|
|
|
set built_binfile 1
|
|
|
|
|
break
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if {!$built_binfile} {
|
2016-12-01 21:40:05 +01:00
|
|
|
|
unsupported "couldn't compile $sources: ${why_msg}"
|
2011-07-15 16:11:22 +02:00
|
|
|
|
return -1
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2003-05-01 03:09:51 +02:00
|
|
|
|
# This is just like gdb_compile_pthreads, above, except that we always add the
|
|
|
|
|
# objc library for compiling Objective-C programs
|
|
|
|
|
proc gdb_compile_objc {source dest type options} {
|
|
|
|
|
set built_binfile 0
|
|
|
|
|
set why_msg "unrecognized error"
|
|
|
|
|
foreach lib {-lobjc -lpthreads -lpthread -lthread solaris} {
|
|
|
|
|
# This kind of wipes out whatever libs the caller may have
|
|
|
|
|
# set. Or maybe theirs will override ours. How infelicitous.
|
|
|
|
|
if { $lib == "solaris" } {
|
|
|
|
|
set lib "-lpthread -lposix4"
|
|
|
|
|
}
|
|
|
|
|
if { $lib != "-lobjc" } {
|
|
|
|
|
set lib "-lobjc $lib"
|
|
|
|
|
}
|
|
|
|
|
set options_with_lib [concat $options [list libs=$lib quiet]]
|
|
|
|
|
set ccout [gdb_compile $source $dest $type $options_with_lib]
|
|
|
|
|
switch -regexp -- $ccout {
|
|
|
|
|
".*no posix threads support.*" {
|
|
|
|
|
set why_msg "missing threads include file"
|
|
|
|
|
break
|
|
|
|
|
}
|
|
|
|
|
".*cannot open -lpthread.*" {
|
|
|
|
|
set why_msg "missing runtime threads library"
|
|
|
|
|
}
|
|
|
|
|
".*Can't find library for -lpthread.*" {
|
|
|
|
|
set why_msg "missing runtime threads library"
|
|
|
|
|
}
|
|
|
|
|
{^$} {
|
|
|
|
|
pass "successfully compiled objc with posix threads test case"
|
|
|
|
|
set built_binfile 1
|
|
|
|
|
break
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if {!$built_binfile} {
|
2016-12-01 21:40:05 +01:00
|
|
|
|
unsupported "couldn't compile [file tail $source]: ${why_msg}"
|
2003-05-01 03:09:51 +02:00
|
|
|
|
return -1
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2019-08-22 04:32:12 +02:00
|
|
|
|
# Build an OpenMP program from SOURCE. See prefatory comment for
|
|
|
|
|
# gdb_compile, above, for discussion of the parameters to this proc.
|
|
|
|
|
|
|
|
|
|
proc gdb_compile_openmp {source dest type options} {
|
|
|
|
|
lappend options "additional_flags=-fopenmp"
|
|
|
|
|
return [gdb_compile $source $dest $type $options]
|
|
|
|
|
}
|
|
|
|
|
|
2019-05-17 17:30:09 +02:00
|
|
|
|
# Send a command to GDB.
|
|
|
|
|
# For options for TYPE see gdb_stdin_log_write
|
|
|
|
|
|
|
|
|
|
proc send_gdb { string {type standard}} {
|
2013-06-07 19:31:09 +02:00
|
|
|
|
global suppress_flag
|
1999-04-16 03:35:26 +02:00
|
|
|
|
if { $suppress_flag } {
|
gdb/testsuite/
* config/monitor.exp (gdb_target_cmd): Remove semicolon after
'return'.
(gdb_target_monitor, gdb_load): Likewise.
* config/sid.exp (gdb_load): Likewise.
* config/slite.exp (gdb_load): Likewise.
* config/vx.exp (gdb_start, spawn_vxgdb): Likewise.
* gdb.ada/arrayidx.exp, gdb.ada/null_array.exp: Likewise.
* gdb.arch/mips-octeon-bbit.exp (single_step): Likewise.
(single_step_until): Likewise.
* gdb.arch/powerpc-d128-regs.exp: Likewise.
* gdb.arch/system-gcore.exp: Likewise.
* gdb.base/bigcore.exp (extract_heap): Likewise.
* gdb.base/break-on-linker-gcd-function.exp: Likewise.
* gdb.base/call-ar-st.exp: Likewise.
* gdb.base/call-rt-st.exp: Likewise.
* gdb.base/call-sc.exp, gdb.base/call-strs.exp: Likewise.
* gdb.base/callfuncs.exp, gdb.base/completion.exp: Likewise.
* gdb.base/condbreak.exp, gdb.base/constvars.exp: Likewise.
* gdb.base/corefile.exp: Likewise.
* gdb.base/dbx.exp (gdb_file_cmd): Likewise.
* gdb.base/exprs.exp, gdb.base/fileio.exp: Likewise.
* gdb.base/fixsection.exp: Likewise.
* gdb.base/funcargs.exp: Likewise.
* gdb.base/gcore-buffer-overflow.exp: Likewise.
* gdb.base/gcore-relro.exp: Likewise.
* gdb.base/gcore.exp, gdb.base/gdb11530.exp: Likewise.
* gdb.base/gdb11531.exp, gdb.base/gnu-ifunc.exp: Likewise.
* gdb.base/info-os.exp, gdb.base/info-proc.exp: Likewise.
* gdb.base/interp.exp, gdb.base/langs.exp:: Likewise.
* gdb.base/list.exp: Likewise.
(set_listsize): Likewise.
* gdb.base/logical.exp, gdb.base/mips_pro.exp: Likewise.
* gdb.base/miscexprs.exp, gdb.base/nodebug.exp: Likewise.
* gdb.base/opaque.exp, gdb.base/pointers.exp: Likewise.
* gdb.base/psymtab.exp, gdb.base/ptype.exp: Likewise.
* gdb.base/relational.exp, gdb.base/scope.exp: Likewise.
* gdb.base/setvar.exp: Likewise.
(test_set): Likewise.
* gdb.base/signals.exp, gdb.base/sizeof.exp: Likewise.
* gdb.base/solib-overlap.exp: Likewise.
* gdb.base/store.exp, gdb.base/structs.exp: Likewise.
* gdb.base/structs2.exp, gdb.base/volatile.exp: Likewise.
* gdb.base/watchpoint.exp (initialize): Likewise.
(test_simple_watchpoint): Likewise.
(test_disabling_watchpoints): Likewise.
(test_watchpoint_triggered_in_syscall): Likewise.
* gdb.base/whatis.exp, gdb.cp/ambiguous.exp: Likewise.
* gdb.cp/casts.exp, gdb.cp/ctti.exp: Likewise.
* gdb.cp/namespace.exp, gdb.cp/nsdecl.exp: Likewise.
* gdb.cp/psmang.exp, gdb.dwarf2/dw2-ranges.exp: Likewise.
* gdb.hp/gdb.aCC/optimize.exp: Likewise.
* gdb.hp/gdb.aCC/watch-cmd.exp: Likewise.
* gdb.hp/gdb.base-hp/callfwmall.exp: Likewise.
* gdb.hp/gdb.base-hp/pxdb.exp: Likewise.
* gdb.hp/gdb.compat/xdb1.exp: Likewise.
* gdb.hp/gdb.compat/xdb2.exp: Likewise.
* gdb.hp/gdb.compat/xdb3.exp: Likewise.
* gdb.hp/gdb.defects/bs14602.exp: Likewise.
* gdb.hp/gdb.defects/solib-d.exp: Likewise.
* gdb.mi/gdb792.exp: Likewise.
* gdb.mi/mi-inheritance-syntax-error.exp: Likewise.
* gdb.mi/mi-logging.exp, gdb.mi/mi-var-cp.exp : Likewise.
* gdb.mi/mi-var-rtti.exp, gdb.python/py-type.exp: Likewise.
* gdb.threads/gcore-thread.exp: Likewise.
(load_core): Likewise.
* gdb.threads/pthreads.exp (all_threads_running): Likewise.
(test_startup, check_control_c): Likewise.
* gdb.threads/sigstep-threads.exp: Likewise.
* gdb.threads/thread_check.exp: Likewise.
* gdb.trace/backtrace.exp, gdb.trace/change-loc.exp: Likewise.
* gdb.trace/circ.exp (run_trace_experiment): Likewise.
(set_a_tracepoint, trace_buffer_normal): Likewise.
(gdb_trace_circular_tests): Likewise.
* gdb.trace/collection.exp: Likewise.
* gdb.trace/disconnected-tracing.exp: Likewise.
* gdb.trace/infotrace.exp: Likewise.
* gdb.trace/mi-traceframe-changed.exp: Likewise.
* gdb.trace/mi-tracepoint-changed.exp: Likewise.
* gdb.trace/mi-tsv-changed.exp (test_create_delete_modify_tsv): Likewise.
* gdb.trace/packetlen.exp, gdb.trace/passc-dyn.exp: Likewise.
* gdb.trace/pending.exp, gdb.trace/report.exp: Likewise.
* gdb.trace/stap-trace.exp: Likewise.
* gdb.trace/status-stop.exp,gdb.trace/strace.exp: Likewise.
* gdb.trace/tfind.exp, gdb.trace/trace-break.exp: Likewise.
* gdb.trace/trace-buffer-size.exp: Likewise.
* gdb.trace/tspeed.exp, gdb.trace/tsv.exp: Likewise.
* gdb.trace/unavailable.exp: Likewise.
* gdb.trace/while-dyn.exp: Likewise.
* lib/fortran.exp (set_lang_fortran): Likewise.
* lib/gdb.exp (default_gdb_version, gdb_start_cmd): Likewise.
(gdb_breakpoint, gdb_reinitialize_dir): Likewise.
(default_gdb_start, get_compiler_info): Likewise.
(gdb_compile, gdb_compile_objc, gdb_reload, gdb_init): Likewise.
(get_debug_format, setup_xfail_format): Likewise.
(rerun_to_main, gdb_skip_float_test): Likewise.
(build_id_debug_filename_get, get_remotetimeout): Likewise.
* lib/java.exp (set_lang_java): Likewise.
* lib/mi-support.exp (default_mi_gdb_start): Likewise.
(mi_gdb_reinitialize_dir, mi_gdb_target_cmd): Likewise.
(mi_gdb_file_cmd, mi_gdb_test): Likewise.
(mi_run_cmd_full, mi_expect_interrupt): Likewise.
* lib/objc.exp (set_lang_objc): Likewise.
* lib/pascal.exp (set_lang_pascal): Likewise.
* lib/prompt.exp (default_prompt_gdb_start): Likewise.
* lib/trace-support.exp (gdb_trace_setactions, gdb_tfind_test): Likewise.
(gdb_readexpr, gdb_gettpnum, gdb_find_recursion_test_baseline): Likewise.
2013-03-14 14:34:06 +01:00
|
|
|
|
return "suppressed"
|
1999-04-16 03:35:26 +02:00
|
|
|
|
}
|
2019-05-17 17:30:09 +02:00
|
|
|
|
gdb_stdin_log_write $string $type
|
gdb/testsuite/
* config/monitor.exp (gdb_target_cmd): Remove semicolon after
'return'.
(gdb_target_monitor, gdb_load): Likewise.
* config/sid.exp (gdb_load): Likewise.
* config/slite.exp (gdb_load): Likewise.
* config/vx.exp (gdb_start, spawn_vxgdb): Likewise.
* gdb.ada/arrayidx.exp, gdb.ada/null_array.exp: Likewise.
* gdb.arch/mips-octeon-bbit.exp (single_step): Likewise.
(single_step_until): Likewise.
* gdb.arch/powerpc-d128-regs.exp: Likewise.
* gdb.arch/system-gcore.exp: Likewise.
* gdb.base/bigcore.exp (extract_heap): Likewise.
* gdb.base/break-on-linker-gcd-function.exp: Likewise.
* gdb.base/call-ar-st.exp: Likewise.
* gdb.base/call-rt-st.exp: Likewise.
* gdb.base/call-sc.exp, gdb.base/call-strs.exp: Likewise.
* gdb.base/callfuncs.exp, gdb.base/completion.exp: Likewise.
* gdb.base/condbreak.exp, gdb.base/constvars.exp: Likewise.
* gdb.base/corefile.exp: Likewise.
* gdb.base/dbx.exp (gdb_file_cmd): Likewise.
* gdb.base/exprs.exp, gdb.base/fileio.exp: Likewise.
* gdb.base/fixsection.exp: Likewise.
* gdb.base/funcargs.exp: Likewise.
* gdb.base/gcore-buffer-overflow.exp: Likewise.
* gdb.base/gcore-relro.exp: Likewise.
* gdb.base/gcore.exp, gdb.base/gdb11530.exp: Likewise.
* gdb.base/gdb11531.exp, gdb.base/gnu-ifunc.exp: Likewise.
* gdb.base/info-os.exp, gdb.base/info-proc.exp: Likewise.
* gdb.base/interp.exp, gdb.base/langs.exp:: Likewise.
* gdb.base/list.exp: Likewise.
(set_listsize): Likewise.
* gdb.base/logical.exp, gdb.base/mips_pro.exp: Likewise.
* gdb.base/miscexprs.exp, gdb.base/nodebug.exp: Likewise.
* gdb.base/opaque.exp, gdb.base/pointers.exp: Likewise.
* gdb.base/psymtab.exp, gdb.base/ptype.exp: Likewise.
* gdb.base/relational.exp, gdb.base/scope.exp: Likewise.
* gdb.base/setvar.exp: Likewise.
(test_set): Likewise.
* gdb.base/signals.exp, gdb.base/sizeof.exp: Likewise.
* gdb.base/solib-overlap.exp: Likewise.
* gdb.base/store.exp, gdb.base/structs.exp: Likewise.
* gdb.base/structs2.exp, gdb.base/volatile.exp: Likewise.
* gdb.base/watchpoint.exp (initialize): Likewise.
(test_simple_watchpoint): Likewise.
(test_disabling_watchpoints): Likewise.
(test_watchpoint_triggered_in_syscall): Likewise.
* gdb.base/whatis.exp, gdb.cp/ambiguous.exp: Likewise.
* gdb.cp/casts.exp, gdb.cp/ctti.exp: Likewise.
* gdb.cp/namespace.exp, gdb.cp/nsdecl.exp: Likewise.
* gdb.cp/psmang.exp, gdb.dwarf2/dw2-ranges.exp: Likewise.
* gdb.hp/gdb.aCC/optimize.exp: Likewise.
* gdb.hp/gdb.aCC/watch-cmd.exp: Likewise.
* gdb.hp/gdb.base-hp/callfwmall.exp: Likewise.
* gdb.hp/gdb.base-hp/pxdb.exp: Likewise.
* gdb.hp/gdb.compat/xdb1.exp: Likewise.
* gdb.hp/gdb.compat/xdb2.exp: Likewise.
* gdb.hp/gdb.compat/xdb3.exp: Likewise.
* gdb.hp/gdb.defects/bs14602.exp: Likewise.
* gdb.hp/gdb.defects/solib-d.exp: Likewise.
* gdb.mi/gdb792.exp: Likewise.
* gdb.mi/mi-inheritance-syntax-error.exp: Likewise.
* gdb.mi/mi-logging.exp, gdb.mi/mi-var-cp.exp : Likewise.
* gdb.mi/mi-var-rtti.exp, gdb.python/py-type.exp: Likewise.
* gdb.threads/gcore-thread.exp: Likewise.
(load_core): Likewise.
* gdb.threads/pthreads.exp (all_threads_running): Likewise.
(test_startup, check_control_c): Likewise.
* gdb.threads/sigstep-threads.exp: Likewise.
* gdb.threads/thread_check.exp: Likewise.
* gdb.trace/backtrace.exp, gdb.trace/change-loc.exp: Likewise.
* gdb.trace/circ.exp (run_trace_experiment): Likewise.
(set_a_tracepoint, trace_buffer_normal): Likewise.
(gdb_trace_circular_tests): Likewise.
* gdb.trace/collection.exp: Likewise.
* gdb.trace/disconnected-tracing.exp: Likewise.
* gdb.trace/infotrace.exp: Likewise.
* gdb.trace/mi-traceframe-changed.exp: Likewise.
* gdb.trace/mi-tracepoint-changed.exp: Likewise.
* gdb.trace/mi-tsv-changed.exp (test_create_delete_modify_tsv): Likewise.
* gdb.trace/packetlen.exp, gdb.trace/passc-dyn.exp: Likewise.
* gdb.trace/pending.exp, gdb.trace/report.exp: Likewise.
* gdb.trace/stap-trace.exp: Likewise.
* gdb.trace/status-stop.exp,gdb.trace/strace.exp: Likewise.
* gdb.trace/tfind.exp, gdb.trace/trace-break.exp: Likewise.
* gdb.trace/trace-buffer-size.exp: Likewise.
* gdb.trace/tspeed.exp, gdb.trace/tsv.exp: Likewise.
* gdb.trace/unavailable.exp: Likewise.
* gdb.trace/while-dyn.exp: Likewise.
* lib/fortran.exp (set_lang_fortran): Likewise.
* lib/gdb.exp (default_gdb_version, gdb_start_cmd): Likewise.
(gdb_breakpoint, gdb_reinitialize_dir): Likewise.
(default_gdb_start, get_compiler_info): Likewise.
(gdb_compile, gdb_compile_objc, gdb_reload, gdb_init): Likewise.
(get_debug_format, setup_xfail_format): Likewise.
(rerun_to_main, gdb_skip_float_test): Likewise.
(build_id_debug_filename_get, get_remotetimeout): Likewise.
* lib/java.exp (set_lang_java): Likewise.
* lib/mi-support.exp (default_mi_gdb_start): Likewise.
(mi_gdb_reinitialize_dir, mi_gdb_target_cmd): Likewise.
(mi_gdb_file_cmd, mi_gdb_test): Likewise.
(mi_run_cmd_full, mi_expect_interrupt): Likewise.
* lib/objc.exp (set_lang_objc): Likewise.
* lib/pascal.exp (set_lang_pascal): Likewise.
* lib/prompt.exp (default_prompt_gdb_start): Likewise.
* lib/trace-support.exp (gdb_trace_setactions, gdb_tfind_test): Likewise.
(gdb_readexpr, gdb_gettpnum, gdb_find_recursion_test_baseline): Likewise.
2013-03-14 14:34:06 +01:00
|
|
|
|
return [remote_send host "$string"]
|
1999-04-16 03:35:26 +02:00
|
|
|
|
}
|
|
|
|
|
|
testsuite: Introduce $inferior_spawn_id
Some important tests, like gdb.base/interrupt.exp end up skipped
against gdbserver, because they depend on inferior I/O, which
gdbserver doesn't do.
This patch adds a mechanism that makes it possible to make them work.
It adds a new "inferior_spawn_id" global that is the spawn ID used for
I/O interaction with the inferior. By default, for native targets, or
remote targets that can do I/O through GDB (semi-hosting) this will be
the same as the gdb/host spawn ID. Otherwise, the board may set this
to some other spawn ID. When debugging with GDBserver, this will be
set to GDBserver's spawn ID.
Then tests can use send_inferior instead of send_gdb to send input to
the inferior, and use expect's "-i" switch to select which spawn ID to
use for matching input/output. That is, something like this will now
work:
send_inferior "echo me\n"
gdb_test_multiple "continue" "test msg" {
-i "$inferior_spawn_id" -re "echo me\r\necho\r\n" {
...
}
}
Or even:
gdb_test_multiple "continue" "test msg" {
-i "$inferior_spawn_id" -re "hello world" {
...
}
-i "$gdb_spawn_id" -re "error.*$gdb_prompt $" {
...
}
}
Of course, by default, gdb_test_multiple still matches with
$gdb_spawn_id.
gdb/testsuite/ChangeLog:
2015-04-07 Pedro Alves <palves@redhat.com>
* lib/gdb.exp (inferior_spawn_id): New global.
(gdb_test_multiple): Handle "-i". Reset the spawn id to GDB's
spawn id after processing the user code.
(default_gdb_start): Set inferior_spawn_id.
(send_inferior): New procedure.
* lib/gdbserver-support.exp (gdbserver_start): Set
inferior_spawn_id.
(close_gdbserver, gdb_exit): Unset inferior_spawn_id.
2015-04-07 19:19:30 +02:00
|
|
|
|
# Send STRING to the inferior's terminal.
|
|
|
|
|
|
|
|
|
|
proc send_inferior { string } {
|
|
|
|
|
global inferior_spawn_id
|
|
|
|
|
|
|
|
|
|
if {[catch "send -i $inferior_spawn_id -- \$string" errorInfo]} {
|
|
|
|
|
return "$errorInfo"
|
|
|
|
|
} else {
|
|
|
|
|
return ""
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
1999-04-16 03:35:26 +02:00
|
|
|
|
#
|
|
|
|
|
#
|
|
|
|
|
|
|
|
|
|
proc gdb_expect { args } {
|
|
|
|
|
if { [llength $args] == 2 && [lindex $args 0] != "-re" } {
|
2013-06-07 19:31:09 +02:00
|
|
|
|
set atimeout [lindex $args 0]
|
|
|
|
|
set expcode [list [lindex $args 1]]
|
1999-04-16 03:35:26 +02:00
|
|
|
|
} else {
|
2013-06-07 19:31:09 +02:00
|
|
|
|
set expcode $args
|
2008-02-29 16:40:20 +01:00
|
|
|
|
}
|
|
|
|
|
|
GDB/testsuite: Avoid timeout lowering
The recent change to introduce `gdb_reverse_timeout' turned out
ineffective for board setups that set the `gdb,timeout' target variable.
A lower `gdb,timeout' setting takes precedence and defeats the effect of
`gdb_reverse_timeout'. This is because the global timeout is overridden
in gdb_test_multiple and then again in gdb_expect.
Three timeout variables are taken into account in these two places, in
this precedence:
1. The `gdb,timeout' target variable.
2. The caller's local `timeout' variable (upvar timeout)
3. The global `timeout' variable.
This precedence is obeyed by gdb_test_multiple strictly. OTOH
gdb_expect will select the higher of the two formers and will only take
the latter into account if none of the formers is present. However the
two timeout selections are conceptually the same and gdb_test_multiple
does its only for the purpose of passing it down to gdb_expect.
Therefore I decided there is no point to keep carrying on this
duplication and removed the sequence from gdb_test_multiple, however
retaining the `upvar timeout' variable definition. This way gdb_expect
will still access gdb_test_multiple's caller `timeout' variable (if any)
via its own `upvar timeout' reference.
Now as to the sequence in gdb_expect. In addition to the three
variables described above it also takes a timeout argument into account,
as the fourth value to choose from. It is currently used if it is
higher than the timeout selected from the variables as described above.
With the timeout selection code from gdb_test_multiple gone, gone is
also the most prominent use of this timeout argument, it's now used in
a couple of places only, mostly within this test framework library code
itself for preparatory commands or suchlike. With this being the case
this timeout selection code can be simplified as follows:
1. Among the three timeout variables, the highest is always chosen.
This is so that a test case doesn't inadvertently lower a high value
timeout needed by slow target boards. This is what all test cases
use.
2. Any timeout argument takes precedence. This is for special cases
such as within the framework library code, e.g. it doesn't make sense
to send `set height 0' with a timeout of 7200 seconds. This is a
local command that does not interact with the target and setting a
high timeout here only risks a test suite run taking ages if it goes
astray for some reason.
3. The fallback timeout of 60s remains.
* lib/gdb.exp (gdb_test_multiple): Remove code to select the
timeout, don't pass one down to gdb_expect.
(gdb_expect): Rework timeout selection.
2014-09-09 17:39:16 +02:00
|
|
|
|
# A timeout argument takes precedence, otherwise of all the timeouts
|
|
|
|
|
# select the largest.
|
|
|
|
|
if [info exists atimeout] {
|
|
|
|
|
set tmt $atimeout
|
|
|
|
|
} else {
|
2015-04-15 13:46:58 +02:00
|
|
|
|
set tmt [get_largest_timeout]
|
1999-04-16 03:35:26 +02:00
|
|
|
|
}
|
2008-02-29 16:40:20 +01:00
|
|
|
|
|
2013-06-07 19:31:09 +02:00
|
|
|
|
global suppress_flag
|
|
|
|
|
global remote_suppress_flag
|
1999-04-16 03:35:26 +02:00
|
|
|
|
if [info exists remote_suppress_flag] {
|
2013-06-07 19:31:09 +02:00
|
|
|
|
set old_val $remote_suppress_flag
|
1999-04-16 03:35:26 +02:00
|
|
|
|
}
|
|
|
|
|
if [info exists suppress_flag] {
|
|
|
|
|
if { $suppress_flag } {
|
2013-06-07 19:31:09 +02:00
|
|
|
|
set remote_suppress_flag 1
|
1999-04-16 03:35:26 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
1999-08-03 01:48:37 +02:00
|
|
|
|
set code [catch \
|
GDB/testsuite: Avoid timeout lowering
The recent change to introduce `gdb_reverse_timeout' turned out
ineffective for board setups that set the `gdb,timeout' target variable.
A lower `gdb,timeout' setting takes precedence and defeats the effect of
`gdb_reverse_timeout'. This is because the global timeout is overridden
in gdb_test_multiple and then again in gdb_expect.
Three timeout variables are taken into account in these two places, in
this precedence:
1. The `gdb,timeout' target variable.
2. The caller's local `timeout' variable (upvar timeout)
3. The global `timeout' variable.
This precedence is obeyed by gdb_test_multiple strictly. OTOH
gdb_expect will select the higher of the two formers and will only take
the latter into account if none of the formers is present. However the
two timeout selections are conceptually the same and gdb_test_multiple
does its only for the purpose of passing it down to gdb_expect.
Therefore I decided there is no point to keep carrying on this
duplication and removed the sequence from gdb_test_multiple, however
retaining the `upvar timeout' variable definition. This way gdb_expect
will still access gdb_test_multiple's caller `timeout' variable (if any)
via its own `upvar timeout' reference.
Now as to the sequence in gdb_expect. In addition to the three
variables described above it also takes a timeout argument into account,
as the fourth value to choose from. It is currently used if it is
higher than the timeout selected from the variables as described above.
With the timeout selection code from gdb_test_multiple gone, gone is
also the most prominent use of this timeout argument, it's now used in
a couple of places only, mostly within this test framework library code
itself for preparatory commands or suchlike. With this being the case
this timeout selection code can be simplified as follows:
1. Among the three timeout variables, the highest is always chosen.
This is so that a test case doesn't inadvertently lower a high value
timeout needed by slow target boards. This is what all test cases
use.
2. Any timeout argument takes precedence. This is for special cases
such as within the framework library code, e.g. it doesn't make sense
to send `set height 0' with a timeout of 7200 seconds. This is a
local command that does not interact with the target and setting a
high timeout here only risks a test suite run taking ages if it goes
astray for some reason.
3. The fallback timeout of 60s remains.
* lib/gdb.exp (gdb_test_multiple): Remove code to select the
timeout, don't pass one down to gdb_expect.
(gdb_expect): Rework timeout selection.
2014-09-09 17:39:16 +02:00
|
|
|
|
{uplevel remote_expect host $tmt $expcode} string]
|
1999-04-16 03:35:26 +02:00
|
|
|
|
if [info exists old_val] {
|
2013-06-07 19:31:09 +02:00
|
|
|
|
set remote_suppress_flag $old_val
|
1999-04-16 03:35:26 +02:00
|
|
|
|
} else {
|
|
|
|
|
if [info exists remote_suppress_flag] {
|
2013-06-07 19:31:09 +02:00
|
|
|
|
unset remote_suppress_flag
|
1999-04-16 03:35:26 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if {$code == 1} {
|
2013-06-07 19:31:09 +02:00
|
|
|
|
global errorInfo errorCode
|
1999-04-16 03:35:26 +02:00
|
|
|
|
|
|
|
|
|
return -code error -errorinfo $errorInfo -errorcode $errorCode $string
|
2011-12-03 00:58:01 +01:00
|
|
|
|
} else {
|
1999-04-16 03:35:26 +02:00
|
|
|
|
return -code $code $string
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2010-11-30 18:41:14 +01:00
|
|
|
|
# gdb_expect_list TEST SENTINEL LIST -- expect a sequence of outputs
|
1999-06-28 18:06:02 +02:00
|
|
|
|
#
|
|
|
|
|
# Check for long sequence of output by parts.
|
2010-11-30 18:41:14 +01:00
|
|
|
|
# TEST: is the test message to be printed with the test success/fail.
|
1999-06-28 18:06:02 +02:00
|
|
|
|
# SENTINEL: Is the terminal pattern indicating that output has finished.
|
|
|
|
|
# LIST: is the sequence of outputs to match.
|
|
|
|
|
# If the sentinel is recognized early, it is considered an error.
|
|
|
|
|
#
|
1999-11-09 02:23:30 +01:00
|
|
|
|
# Returns:
|
|
|
|
|
# 1 if the test failed,
|
|
|
|
|
# 0 if the test passes,
|
|
|
|
|
# -1 if there was an internal error.
|
2010-11-30 18:41:14 +01:00
|
|
|
|
|
1999-12-07 04:56:43 +01:00
|
|
|
|
proc gdb_expect_list {test sentinel list} {
|
1999-06-28 18:06:02 +02:00
|
|
|
|
global gdb_prompt
|
1999-11-09 02:23:30 +01:00
|
|
|
|
global suppress_flag
|
1999-06-28 18:06:02 +02:00
|
|
|
|
set index 0
|
1999-07-05 19:58:44 +02:00
|
|
|
|
set ok 1
|
1999-11-09 02:23:30 +01:00
|
|
|
|
if { $suppress_flag } {
|
|
|
|
|
set ok 0
|
2002-08-02 00:06:49 +02:00
|
|
|
|
unresolved "${test}"
|
1999-11-09 02:23:30 +01:00
|
|
|
|
}
|
1999-07-05 19:58:44 +02:00
|
|
|
|
while { ${index} < [llength ${list}] } {
|
1999-06-28 18:06:02 +02:00
|
|
|
|
set pattern [lindex ${list} ${index}]
|
|
|
|
|
set index [expr ${index} + 1]
|
2010-11-23 23:25:37 +01:00
|
|
|
|
verbose -log "gdb_expect_list pattern: /$pattern/" 2
|
1999-06-28 18:06:02 +02:00
|
|
|
|
if { ${index} == [llength ${list}] } {
|
1999-07-05 19:58:44 +02:00
|
|
|
|
if { ${ok} } {
|
|
|
|
|
gdb_expect {
|
1999-12-07 04:56:43 +01:00
|
|
|
|
-re "${pattern}${sentinel}" {
|
2002-08-02 00:06:49 +02:00
|
|
|
|
# pass "${test}, pattern ${index} + sentinel"
|
1999-12-07 04:56:43 +01:00
|
|
|
|
}
|
|
|
|
|
-re "${sentinel}" {
|
2002-08-02 00:06:49 +02:00
|
|
|
|
fail "${test} (pattern ${index} + sentinel)"
|
1999-12-07 04:56:43 +01:00
|
|
|
|
set ok 0
|
1999-07-05 19:58:44 +02:00
|
|
|
|
}
|
2004-02-10 22:00:15 +01:00
|
|
|
|
-re ".*A problem internal to GDB has been detected" {
|
|
|
|
|
fail "${test} (GDB internal error)"
|
|
|
|
|
set ok 0
|
|
|
|
|
gdb_internal_error_resync
|
|
|
|
|
}
|
1999-07-05 19:58:44 +02:00
|
|
|
|
timeout {
|
2002-08-02 00:06:49 +02:00
|
|
|
|
fail "${test} (pattern ${index} + sentinel) (timeout)"
|
1999-07-05 19:58:44 +02:00
|
|
|
|
set ok 0
|
|
|
|
|
}
|
1999-06-28 18:06:02 +02:00
|
|
|
|
}
|
1999-07-05 19:58:44 +02:00
|
|
|
|
} else {
|
2002-08-02 00:06:49 +02:00
|
|
|
|
# unresolved "${test}, pattern ${index} + sentinel"
|
1999-06-28 18:06:02 +02:00
|
|
|
|
}
|
|
|
|
|
} else {
|
1999-07-05 19:58:44 +02:00
|
|
|
|
if { ${ok} } {
|
|
|
|
|
gdb_expect {
|
|
|
|
|
-re "${pattern}" {
|
2002-08-02 00:06:49 +02:00
|
|
|
|
# pass "${test}, pattern ${index}"
|
1999-07-05 19:58:44 +02:00
|
|
|
|
}
|
1999-12-07 04:56:43 +01:00
|
|
|
|
-re "${sentinel}" {
|
2002-08-02 00:06:49 +02:00
|
|
|
|
fail "${test} (pattern ${index})"
|
1999-07-05 19:58:44 +02:00
|
|
|
|
set ok 0
|
|
|
|
|
}
|
2004-02-10 22:00:15 +01:00
|
|
|
|
-re ".*A problem internal to GDB has been detected" {
|
|
|
|
|
fail "${test} (GDB internal error)"
|
|
|
|
|
set ok 0
|
|
|
|
|
gdb_internal_error_resync
|
|
|
|
|
}
|
1999-07-05 19:58:44 +02:00
|
|
|
|
timeout {
|
2002-08-02 00:06:49 +02:00
|
|
|
|
fail "${test} (pattern ${index}) (timeout)"
|
1999-07-05 19:58:44 +02:00
|
|
|
|
set ok 0
|
|
|
|
|
}
|
1999-06-28 18:06:02 +02:00
|
|
|
|
}
|
1999-07-05 19:58:44 +02:00
|
|
|
|
} else {
|
2002-08-02 00:06:49 +02:00
|
|
|
|
# unresolved "${test}, pattern ${index}"
|
1999-06-28 18:06:02 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
1999-11-09 02:23:30 +01:00
|
|
|
|
if { ${ok} } {
|
2002-08-02 00:06:49 +02:00
|
|
|
|
pass "${test}"
|
1999-11-09 02:23:30 +01:00
|
|
|
|
return 0
|
|
|
|
|
} else {
|
|
|
|
|
return 1
|
|
|
|
|
}
|
1999-06-28 18:06:02 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#
|
|
|
|
|
#
|
1999-04-16 03:35:26 +02:00
|
|
|
|
proc gdb_suppress_entire_file { reason } {
|
2013-06-07 19:31:09 +02:00
|
|
|
|
global suppress_flag
|
1999-04-16 03:35:26 +02:00
|
|
|
|
|
2013-06-07 19:31:09 +02:00
|
|
|
|
warning "$reason\n"
|
|
|
|
|
set suppress_flag -1
|
1999-04-16 03:35:26 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#
|
|
|
|
|
# Set suppress_flag, which will cause all subsequent calls to send_gdb and
|
|
|
|
|
# gdb_expect to fail immediately (until the next call to
|
|
|
|
|
# gdb_stop_suppressing_tests).
|
|
|
|
|
#
|
|
|
|
|
proc gdb_suppress_tests { args } {
|
2013-06-07 19:31:09 +02:00
|
|
|
|
global suppress_flag
|
1999-04-16 03:35:26 +02:00
|
|
|
|
|
|
|
|
|
return; # fnf - disable pending review of results where
|
|
|
|
|
# testsuite ran better without this
|
2013-06-07 19:31:09 +02:00
|
|
|
|
incr suppress_flag
|
1999-04-16 03:35:26 +02:00
|
|
|
|
|
|
|
|
|
if { $suppress_flag == 1 } {
|
|
|
|
|
if { [llength $args] > 0 } {
|
2013-06-07 19:31:09 +02:00
|
|
|
|
warning "[lindex $args 0]\n"
|
1999-04-16 03:35:26 +02:00
|
|
|
|
} else {
|
2013-06-07 19:31:09 +02:00
|
|
|
|
warning "Because of previous failure, all subsequent tests in this group will automatically fail.\n"
|
1999-04-16 03:35:26 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#
|
|
|
|
|
# Clear suppress_flag.
|
|
|
|
|
#
|
|
|
|
|
proc gdb_stop_suppressing_tests { } {
|
2013-06-07 19:31:09 +02:00
|
|
|
|
global suppress_flag
|
1999-04-16 03:35:26 +02:00
|
|
|
|
|
|
|
|
|
if [info exists suppress_flag] {
|
|
|
|
|
if { $suppress_flag > 0 } {
|
2013-06-07 19:31:09 +02:00
|
|
|
|
set suppress_flag 0
|
|
|
|
|
clone_output "Tests restarted.\n"
|
1999-04-16 03:35:26 +02:00
|
|
|
|
}
|
|
|
|
|
} else {
|
2013-06-07 19:31:09 +02:00
|
|
|
|
set suppress_flag 0
|
1999-04-16 03:35:26 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
proc gdb_clear_suppressed { } {
|
2013-06-07 19:31:09 +02:00
|
|
|
|
global suppress_flag
|
1999-04-16 03:35:26 +02:00
|
|
|
|
|
2013-06-07 19:31:09 +02:00
|
|
|
|
set suppress_flag 0
|
1999-04-16 03:35:26 +02:00
|
|
|
|
}
|
|
|
|
|
|
Canceling pagination caused by execution command from command line aborts readline/gdb
This fixes:
$ ./gdb program -ex "set height 2" -ex "start"
...
Reading symbols from /home/pedro/gdb/tests/threads...done.
---Type <return> to continue, or q <return> to quit---^CQuit << ctrl-c triggers a Quit
*type something*
readline: readline_callback_read_char() called with no handler!
Aborted
$
Usually, if an error propagates all the way to the top level, we'll
re-enable stdin, in case the command that was running was a
synchronous command. That's done in the event loop's actual loop
(event-loop.c:start_event_loop). However, if a foreground execution
command is run before the event loop starts and throws, nothing is
presently reenabling stdin, which leaves sync_execution set.
When we do start the event loop, because sync_execution is still
(mistakenly) set, display_gdb_prompt removes the readline input
callback, even though stdin is registered in the event loop. Any
input from here on results in readline aborting.
Such commands are run through catch_command_errors,
catch_command_errors_const, so add the tweak there.
gdb/
2014-07-14 Pedro Alves <palves@redhat.com>
PR gdb/17072
* main.c: Include event-top.h.
(handle_command_errors): New function.
(catch_command_errors, catch_command_errors_const): Use it.
gdb/testsuite/
2014-07-14 Pedro Alves <palves@redhat.com>
PR gdb/17072
* gdb.base/paginate-execution-startup.c: New file.
* gdb.base/paginate-execution-startup.exp: New file.
* lib/gdb.exp (pagination_prompt): New global.
(default_gdb_spawn): New procedure, factored out from
default_gdb_spawn.
(default_gdb_start): Adjust to call default_gdb_spawn.
(gdb_spawn): New procedure.
2014-07-14 20:55:31 +02:00
|
|
|
|
# Spawn the gdb process.
|
|
|
|
|
#
|
|
|
|
|
# This doesn't expect any output or do any other initialization,
|
|
|
|
|
# leaving those to the caller.
|
|
|
|
|
#
|
|
|
|
|
# Overridable function -- you can override this function in your
|
|
|
|
|
# baseboard file.
|
|
|
|
|
|
|
|
|
|
proc gdb_spawn { } {
|
|
|
|
|
default_gdb_spawn
|
|
|
|
|
}
|
|
|
|
|
|
gdb/17347 - Regression: GDB stopped on run with attached process
Doing:
gdb --pid=PID -ex run
Results in GDB getting a SIGTTIN, and thus ending stopped. That's
usually indicative of a missing target_terminal_ours call.
E.g., from the PR:
$ sleep 1h & p=$!; sleep 0.1; gdb -batch sleep $p -ex run
[1] 28263
[1] Killed sleep 1h
[2]+ Stopped gdb -batch sleep $p -ex run
The workaround is doing:
gdb -ex "attach $PID" -ex "run"
instead of
gdb [-p] $PID -ex "run"
With the former, gdb waits for the attach command to complete before
moving on to the "run" command, because the interpreter is in sync
mode at this point, within execute_command. But for the latter,
attach_command is called directly from captured_main, and thus misses
that waiting. IOW, "run" is running before the attach continuation
has run, before the program stops and attach completes. The broken
terminal settings are just one symptom of that. Any command that
queries or requires input results in the same.
The fix is to wait in catch_command_errors (which is specific to
main.c nowadays), just like we wait in execute_command.
gdb/ChangeLog:
2014-09-11 Pedro Alves <palves@redhat.com>
PR gdb/17347
* main.c: Include "infrun.h".
(catch_command_errors, catch_command_errors_const): Wait for the
foreground command to complete.
* top.c (maybe_wait_sync_command_done): New function, factored out
from ...
(maybe_wait_sync_command_done): ... here.
* top.h (maybe_wait_sync_command_done): New declaration.
gdb/testsuite/ChangeLog:
2014-09-11 Pedro Alves <palves@redhat.com>
PR gdb/17347
* lib/gdb.exp (gdb_spawn_with_cmdline_opts): New procedure.
* gdb.base/attach.exp (test_command_line_attach_run): New
procedure.
(top level): Call it.
2014-09-11 14:04:15 +02:00
|
|
|
|
# Spawn GDB with CMDLINE_FLAGS appended to the GDBFLAGS global.
|
|
|
|
|
|
|
|
|
|
proc gdb_spawn_with_cmdline_opts { cmdline_flags } {
|
|
|
|
|
global GDBFLAGS
|
|
|
|
|
|
|
|
|
|
set saved_gdbflags $GDBFLAGS
|
|
|
|
|
|
2015-03-30 19:00:28 +02:00
|
|
|
|
if {$GDBFLAGS != ""} {
|
|
|
|
|
append GDBFLAGS " "
|
|
|
|
|
}
|
gdb/17347 - Regression: GDB stopped on run with attached process
Doing:
gdb --pid=PID -ex run
Results in GDB getting a SIGTTIN, and thus ending stopped. That's
usually indicative of a missing target_terminal_ours call.
E.g., from the PR:
$ sleep 1h & p=$!; sleep 0.1; gdb -batch sleep $p -ex run
[1] 28263
[1] Killed sleep 1h
[2]+ Stopped gdb -batch sleep $p -ex run
The workaround is doing:
gdb -ex "attach $PID" -ex "run"
instead of
gdb [-p] $PID -ex "run"
With the former, gdb waits for the attach command to complete before
moving on to the "run" command, because the interpreter is in sync
mode at this point, within execute_command. But for the latter,
attach_command is called directly from captured_main, and thus misses
that waiting. IOW, "run" is running before the attach continuation
has run, before the program stops and attach completes. The broken
terminal settings are just one symptom of that. Any command that
queries or requires input results in the same.
The fix is to wait in catch_command_errors (which is specific to
main.c nowadays), just like we wait in execute_command.
gdb/ChangeLog:
2014-09-11 Pedro Alves <palves@redhat.com>
PR gdb/17347
* main.c: Include "infrun.h".
(catch_command_errors, catch_command_errors_const): Wait for the
foreground command to complete.
* top.c (maybe_wait_sync_command_done): New function, factored out
from ...
(maybe_wait_sync_command_done): ... here.
* top.h (maybe_wait_sync_command_done): New declaration.
gdb/testsuite/ChangeLog:
2014-09-11 Pedro Alves <palves@redhat.com>
PR gdb/17347
* lib/gdb.exp (gdb_spawn_with_cmdline_opts): New procedure.
* gdb.base/attach.exp (test_command_line_attach_run): New
procedure.
(top level): Call it.
2014-09-11 14:04:15 +02:00
|
|
|
|
append GDBFLAGS $cmdline_flags
|
|
|
|
|
|
|
|
|
|
set res [gdb_spawn]
|
|
|
|
|
|
|
|
|
|
set GDBFLAGS $saved_gdbflags
|
|
|
|
|
|
|
|
|
|
return $res
|
|
|
|
|
}
|
|
|
|
|
|
Canceling pagination caused by execution command from command line aborts readline/gdb
This fixes:
$ ./gdb program -ex "set height 2" -ex "start"
...
Reading symbols from /home/pedro/gdb/tests/threads...done.
---Type <return> to continue, or q <return> to quit---^CQuit << ctrl-c triggers a Quit
*type something*
readline: readline_callback_read_char() called with no handler!
Aborted
$
Usually, if an error propagates all the way to the top level, we'll
re-enable stdin, in case the command that was running was a
synchronous command. That's done in the event loop's actual loop
(event-loop.c:start_event_loop). However, if a foreground execution
command is run before the event loop starts and throws, nothing is
presently reenabling stdin, which leaves sync_execution set.
When we do start the event loop, because sync_execution is still
(mistakenly) set, display_gdb_prompt removes the readline input
callback, even though stdin is registered in the event loop. Any
input from here on results in readline aborting.
Such commands are run through catch_command_errors,
catch_command_errors_const, so add the tweak there.
gdb/
2014-07-14 Pedro Alves <palves@redhat.com>
PR gdb/17072
* main.c: Include event-top.h.
(handle_command_errors): New function.
(catch_command_errors, catch_command_errors_const): Use it.
gdb/testsuite/
2014-07-14 Pedro Alves <palves@redhat.com>
PR gdb/17072
* gdb.base/paginate-execution-startup.c: New file.
* gdb.base/paginate-execution-startup.exp: New file.
* lib/gdb.exp (pagination_prompt): New global.
(default_gdb_spawn): New procedure, factored out from
default_gdb_spawn.
(default_gdb_start): Adjust to call default_gdb_spawn.
(gdb_spawn): New procedure.
2014-07-14 20:55:31 +02:00
|
|
|
|
# Start gdb running, wait for prompt, and disable the pagers.
|
|
|
|
|
|
|
|
|
|
# Overridable function -- you can override this function in your
|
|
|
|
|
# baseboard file.
|
|
|
|
|
|
1999-04-16 03:35:26 +02:00
|
|
|
|
proc gdb_start { } {
|
|
|
|
|
default_gdb_start
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
proc gdb_exit { } {
|
|
|
|
|
catch default_gdb_exit
|
|
|
|
|
}
|
|
|
|
|
|
2015-01-09 12:04:19 +01:00
|
|
|
|
# Return true if we can spawn a program on the target and attach to
|
|
|
|
|
# it.
|
|
|
|
|
|
|
|
|
|
proc can_spawn_for_attach { } {
|
testsuite: tcl exec& -> 'kill -9 $pid' is racy (attach-many-short-lived-thread.exp races and others)
The buildbots show that attach-many-short-lived-thread.exp is racy.
But after staring at debug logs and playing with SystemTap scripts for
a (long) while, I figured out that neither GDB, nor the kernel nor the
test's program itself are at fault.
The problem is simply that the testsuite machinery is currently
subject to PID-reuse races. The attach-many-short-lived-threads.c
test program just happens to be much more susceptible to trigger this
race because threads and processes share the same number space on
Linux, and the test spawns many many short lived threads in
succession, thus enlarging the race window a lot.
Part of the problem is that several tests spawn processes with "exec&"
(in order to test the "attach" command) , and then at the end of the
test, to make sure things are cleaned up, issue a 'remote_spawn "kill
-p $testpid"'. Since with tcl's "exec&", tcl itself is responsible
for reaping the process's exit status, when we go kill the process,
testpid may have already exited _and_ its status may have (and often
has) been reaped already. Thus it can happen that another process
meanwhile reuses $testpid, and that "kill" command kills the wrong
process... Frequently, that happens to be
attach-many-short-lived-thread, but this explains other test's races
as well.
In the attach-many-short-lived-threads test, it sometimes manifests
like this:
(gdb) file /home/pedro/gdb/mygit/build/gdb/testsuite/gdb.threads/attach-many-short-lived-threads
Reading symbols from /home/pedro/gdb/mygit/build/gdb/testsuite/gdb.threads/attach-many-short-lived-threads...done.
(gdb) Loaded /home/pedro/gdb/mygit/build/gdb/testsuite/gdb.threads/attach-many-short-lived-threads into /home/pedro/gdb/mygit/build/gdb/testsuite/../../gdb/gdb
attach 5940
Attaching to program: /home/pedro/gdb/mygit/build/gdb/testsuite/gdb.threads/attach-many-short-lived-threads, process 5940
warning: process 5940 is a zombie - the process has already terminated
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ptrace: Operation not permitted.
(gdb) PASS: gdb.threads/attach-many-short-lived-threads.exp: iter 1: attach
info threads
No threads.
(gdb) PASS: gdb.threads/attach-many-short-lived-threads.exp: iter 1: no new threads
set breakpoint always-inserted on
(gdb) PASS: gdb.threads/attach-many-short-lived-threads.exp: iter 1: set breakpoint always-inserted on
Other times the process dies while the test is ongoing (the process is
ptrace-stopped):
(gdb) print again = 1
Cannot access memory at address 0x6020cc
(gdb) FAIL: gdb.threads/attach-many-short-lived-threads.exp: iter 2: reset timer in the inferior
(Recall that on Linux, SIGKILL is not interceptable)
And other times it dies just while we're detaching:
$4 = 319
(gdb) PASS: gdb.threads/attach-many-short-lived-threads.exp: iter 2: print seconds_left
detach
Can't detach Thread 0x7fb13b7de700 (LWP 1842): No such process
(gdb) FAIL: gdb.threads/attach-many-short-lived-threads.exp: iter 2: detach
GDB mishandles the latter (it should ignore ESRCH while detaching just
like when continuing), but that's another story.
The fix here is to change spawn_wait_for_attach to use Expect's
'spawn' command instead of Tcl's 'exec&' to spawn programs, because
with spawn we control when to wait for/reap the process. That allows
killing the process by PID without being subject to pid-reuse races,
because even if the process is already dead, the kernel won't reuse
the process's PID until the zombie is reaped.
The other part of the problem lies in DejaGnu itself, unfortunately.
I have occasionally seen tests (attach-many-short-lived-threads
included, but not only that one) die with a random inexplicable
SIGTERM too, and that too is caused by the same reason, except that in
that case, the rogue SIGTERM is sent from this bit in DejaGnu's remote.exp:
exec sh -c "exec > /dev/null 2>&1 && (kill -2 $pgid || kill -2 $pid) && sleep 5 && (kill $pgid || kill $pid) && sleep 5 && (kill -9 $pgid || kill -9 $pid) &"
...
catch "wait -i $shell_id"
Even if the program exits promptly, that whole cascade of kills
carries on in the background, thus potentially killing the poor
process that manages to reuse $pid...
I sent a fix for that to the DejaGnu list:
http://lists.gnu.org/archive/html/dejagnu/2015-07/msg00000.html
With both patches in place, I haven't seen
attach-many-short-lived-threads.exp fail again.
Tested on x86_64 Fedora 20, native, gdbserver and extended-gdbserver.
gdb/testsuite/ChangeLog:
2015-07-31 Pedro Alves <palves@redhat.com>
* gdb.base/attach-pie-misread.exp: Rename $res to $test_spawn_id.
Use spawn_id_get_pid. Wait for spawn id after eof. Use
kill_wait_spawned_process instead of explicit "kill -9".
* gdb.base/attach-pie-noexec.exp: Adjust to spawn_wait_for_attach
returning a spawn id instead of a pid. Use spawn_id_get_pid and
kill_wait_spawned_process.
* gdb.base/attach-twice.exp: Likewise.
* gdb.base/attach.exp: Likewise.
(do_command_attach_tests): Use gdb_spawn_with_cmdline_opts and
gdb_test_multiple.
* gdb.base/solib-overlap.exp: Adjust to spawn_wait_for_attach
returning a spawn id instead of a pid. Use spawn_id_get_pid and
kill_wait_spawned_process.
* gdb.base/valgrind-infcall.exp: Likewise.
* gdb.multi/multi-attach.exp: Likewise.
* gdb.python/py-prompt.exp: Likewise.
* gdb.python/py-sync-interp.exp: Likewise.
* gdb.server/ext-attach.exp: Likewise.
* gdb.threads/attach-into-signal.exp (corefunc): Use
spawn_wait_for_attach, spawn_id_get_pid and
kill_wait_spawned_process.
* gdb.threads/attach-many-short-lived-threads.exp: Adjust to
spawn_wait_for_attach returning a spawn id instead of a pid. Use
spawn_id_get_pid and kill_wait_spawned_process.
* gdb.threads/attach-stopped.exp (corefunc): Use
spawn_wait_for_attach, spawn_id_get_pid and
kill_wait_spawned_process.
* gdb.base/break-interp.exp: Rename $res to $test_spawn_id.
Use spawn_id_get_pid. Wait for spawn id after eof. Use
kill_wait_spawned_process instead of explicit "kill -9".
* lib/gdb.exp (can_spawn_for_attach): Adjust comment.
(kill_wait_spawned_process, spawn_id_get_pid): New procedures.
(spawn_wait_for_attach): Use spawn instead of exec to spawn
processes. Don't map cygwin/windows pids here. Now returns a
spawn id list.
2015-07-31 21:06:24 +02:00
|
|
|
|
# We use exp_pid to get the inferior's pid, assuming that gives
|
|
|
|
|
# back the pid of the program. On remote boards, that would give
|
|
|
|
|
# us instead the PID of e.g., the ssh client, etc.
|
2015-01-09 12:04:19 +01:00
|
|
|
|
if [is_remote target] then {
|
|
|
|
|
return 0
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# The "attach" command doesn't make sense when the target is
|
|
|
|
|
# stub-like, where GDB finds the program already started on
|
|
|
|
|
# initial connection.
|
|
|
|
|
if {[target_info exists use_gdb_stub]} {
|
|
|
|
|
return 0
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# Assume yes.
|
|
|
|
|
return 1
|
|
|
|
|
}
|
|
|
|
|
|
testsuite: tcl exec& -> 'kill -9 $pid' is racy (attach-many-short-lived-thread.exp races and others)
The buildbots show that attach-many-short-lived-thread.exp is racy.
But after staring at debug logs and playing with SystemTap scripts for
a (long) while, I figured out that neither GDB, nor the kernel nor the
test's program itself are at fault.
The problem is simply that the testsuite machinery is currently
subject to PID-reuse races. The attach-many-short-lived-threads.c
test program just happens to be much more susceptible to trigger this
race because threads and processes share the same number space on
Linux, and the test spawns many many short lived threads in
succession, thus enlarging the race window a lot.
Part of the problem is that several tests spawn processes with "exec&"
(in order to test the "attach" command) , and then at the end of the
test, to make sure things are cleaned up, issue a 'remote_spawn "kill
-p $testpid"'. Since with tcl's "exec&", tcl itself is responsible
for reaping the process's exit status, when we go kill the process,
testpid may have already exited _and_ its status may have (and often
has) been reaped already. Thus it can happen that another process
meanwhile reuses $testpid, and that "kill" command kills the wrong
process... Frequently, that happens to be
attach-many-short-lived-thread, but this explains other test's races
as well.
In the attach-many-short-lived-threads test, it sometimes manifests
like this:
(gdb) file /home/pedro/gdb/mygit/build/gdb/testsuite/gdb.threads/attach-many-short-lived-threads
Reading symbols from /home/pedro/gdb/mygit/build/gdb/testsuite/gdb.threads/attach-many-short-lived-threads...done.
(gdb) Loaded /home/pedro/gdb/mygit/build/gdb/testsuite/gdb.threads/attach-many-short-lived-threads into /home/pedro/gdb/mygit/build/gdb/testsuite/../../gdb/gdb
attach 5940
Attaching to program: /home/pedro/gdb/mygit/build/gdb/testsuite/gdb.threads/attach-many-short-lived-threads, process 5940
warning: process 5940 is a zombie - the process has already terminated
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ptrace: Operation not permitted.
(gdb) PASS: gdb.threads/attach-many-short-lived-threads.exp: iter 1: attach
info threads
No threads.
(gdb) PASS: gdb.threads/attach-many-short-lived-threads.exp: iter 1: no new threads
set breakpoint always-inserted on
(gdb) PASS: gdb.threads/attach-many-short-lived-threads.exp: iter 1: set breakpoint always-inserted on
Other times the process dies while the test is ongoing (the process is
ptrace-stopped):
(gdb) print again = 1
Cannot access memory at address 0x6020cc
(gdb) FAIL: gdb.threads/attach-many-short-lived-threads.exp: iter 2: reset timer in the inferior
(Recall that on Linux, SIGKILL is not interceptable)
And other times it dies just while we're detaching:
$4 = 319
(gdb) PASS: gdb.threads/attach-many-short-lived-threads.exp: iter 2: print seconds_left
detach
Can't detach Thread 0x7fb13b7de700 (LWP 1842): No such process
(gdb) FAIL: gdb.threads/attach-many-short-lived-threads.exp: iter 2: detach
GDB mishandles the latter (it should ignore ESRCH while detaching just
like when continuing), but that's another story.
The fix here is to change spawn_wait_for_attach to use Expect's
'spawn' command instead of Tcl's 'exec&' to spawn programs, because
with spawn we control when to wait for/reap the process. That allows
killing the process by PID without being subject to pid-reuse races,
because even if the process is already dead, the kernel won't reuse
the process's PID until the zombie is reaped.
The other part of the problem lies in DejaGnu itself, unfortunately.
I have occasionally seen tests (attach-many-short-lived-threads
included, but not only that one) die with a random inexplicable
SIGTERM too, and that too is caused by the same reason, except that in
that case, the rogue SIGTERM is sent from this bit in DejaGnu's remote.exp:
exec sh -c "exec > /dev/null 2>&1 && (kill -2 $pgid || kill -2 $pid) && sleep 5 && (kill $pgid || kill $pid) && sleep 5 && (kill -9 $pgid || kill -9 $pid) &"
...
catch "wait -i $shell_id"
Even if the program exits promptly, that whole cascade of kills
carries on in the background, thus potentially killing the poor
process that manages to reuse $pid...
I sent a fix for that to the DejaGnu list:
http://lists.gnu.org/archive/html/dejagnu/2015-07/msg00000.html
With both patches in place, I haven't seen
attach-many-short-lived-threads.exp fail again.
Tested on x86_64 Fedora 20, native, gdbserver and extended-gdbserver.
gdb/testsuite/ChangeLog:
2015-07-31 Pedro Alves <palves@redhat.com>
* gdb.base/attach-pie-misread.exp: Rename $res to $test_spawn_id.
Use spawn_id_get_pid. Wait for spawn id after eof. Use
kill_wait_spawned_process instead of explicit "kill -9".
* gdb.base/attach-pie-noexec.exp: Adjust to spawn_wait_for_attach
returning a spawn id instead of a pid. Use spawn_id_get_pid and
kill_wait_spawned_process.
* gdb.base/attach-twice.exp: Likewise.
* gdb.base/attach.exp: Likewise.
(do_command_attach_tests): Use gdb_spawn_with_cmdline_opts and
gdb_test_multiple.
* gdb.base/solib-overlap.exp: Adjust to spawn_wait_for_attach
returning a spawn id instead of a pid. Use spawn_id_get_pid and
kill_wait_spawned_process.
* gdb.base/valgrind-infcall.exp: Likewise.
* gdb.multi/multi-attach.exp: Likewise.
* gdb.python/py-prompt.exp: Likewise.
* gdb.python/py-sync-interp.exp: Likewise.
* gdb.server/ext-attach.exp: Likewise.
* gdb.threads/attach-into-signal.exp (corefunc): Use
spawn_wait_for_attach, spawn_id_get_pid and
kill_wait_spawned_process.
* gdb.threads/attach-many-short-lived-threads.exp: Adjust to
spawn_wait_for_attach returning a spawn id instead of a pid. Use
spawn_id_get_pid and kill_wait_spawned_process.
* gdb.threads/attach-stopped.exp (corefunc): Use
spawn_wait_for_attach, spawn_id_get_pid and
kill_wait_spawned_process.
* gdb.base/break-interp.exp: Rename $res to $test_spawn_id.
Use spawn_id_get_pid. Wait for spawn id after eof. Use
kill_wait_spawned_process instead of explicit "kill -9".
* lib/gdb.exp (can_spawn_for_attach): Adjust comment.
(kill_wait_spawned_process, spawn_id_get_pid): New procedures.
(spawn_wait_for_attach): Use spawn instead of exec to spawn
processes. Don't map cygwin/windows pids here. Now returns a
spawn id list.
2015-07-31 21:06:24 +02:00
|
|
|
|
# Kill a progress previously started with spawn_wait_for_attach, and
|
|
|
|
|
# reap its wait status. PROC_SPAWN_ID is the spawn id associated with
|
|
|
|
|
# the process.
|
|
|
|
|
|
|
|
|
|
proc kill_wait_spawned_process { proc_spawn_id } {
|
|
|
|
|
set pid [exp_pid -i $proc_spawn_id]
|
|
|
|
|
|
|
|
|
|
verbose -log "killing ${pid}"
|
|
|
|
|
remote_exec build "kill -9 ${pid}"
|
|
|
|
|
|
|
|
|
|
verbose -log "closing ${proc_spawn_id}"
|
|
|
|
|
catch "close -i $proc_spawn_id"
|
|
|
|
|
verbose -log "waiting for ${proc_spawn_id}"
|
|
|
|
|
|
|
|
|
|
# If somehow GDB ends up still attached to the process here, a
|
|
|
|
|
# blocking wait hangs until gdb is killed (or until gdb / the
|
|
|
|
|
# ptracer reaps the exit status too, but that won't happen because
|
|
|
|
|
# something went wrong.) Passing -nowait makes expect tell Tcl to
|
|
|
|
|
# wait for the PID in the background. That's fine because we
|
|
|
|
|
# don't care about the exit status. */
|
|
|
|
|
wait -nowait -i $proc_spawn_id
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# Returns the process id corresponding to the given spawn id.
|
|
|
|
|
|
|
|
|
|
proc spawn_id_get_pid { spawn_id } {
|
|
|
|
|
set testpid [exp_pid -i $spawn_id]
|
|
|
|
|
|
|
|
|
|
if { [istarget "*-*-cygwin*"] } {
|
|
|
|
|
# testpid is the Cygwin PID, GDB uses the Windows PID, which
|
|
|
|
|
# might be different due to the way fork/exec works.
|
|
|
|
|
set testpid [ exec ps -e | gawk "{ if (\$1 == $testpid) print \$4; }" ]
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return $testpid
|
|
|
|
|
}
|
|
|
|
|
|
2014-09-11 14:04:14 +02:00
|
|
|
|
# Start a set of programs running and then wait for a bit, to be sure
|
testsuite: tcl exec& -> 'kill -9 $pid' is racy (attach-many-short-lived-thread.exp races and others)
The buildbots show that attach-many-short-lived-thread.exp is racy.
But after staring at debug logs and playing with SystemTap scripts for
a (long) while, I figured out that neither GDB, nor the kernel nor the
test's program itself are at fault.
The problem is simply that the testsuite machinery is currently
subject to PID-reuse races. The attach-many-short-lived-threads.c
test program just happens to be much more susceptible to trigger this
race because threads and processes share the same number space on
Linux, and the test spawns many many short lived threads in
succession, thus enlarging the race window a lot.
Part of the problem is that several tests spawn processes with "exec&"
(in order to test the "attach" command) , and then at the end of the
test, to make sure things are cleaned up, issue a 'remote_spawn "kill
-p $testpid"'. Since with tcl's "exec&", tcl itself is responsible
for reaping the process's exit status, when we go kill the process,
testpid may have already exited _and_ its status may have (and often
has) been reaped already. Thus it can happen that another process
meanwhile reuses $testpid, and that "kill" command kills the wrong
process... Frequently, that happens to be
attach-many-short-lived-thread, but this explains other test's races
as well.
In the attach-many-short-lived-threads test, it sometimes manifests
like this:
(gdb) file /home/pedro/gdb/mygit/build/gdb/testsuite/gdb.threads/attach-many-short-lived-threads
Reading symbols from /home/pedro/gdb/mygit/build/gdb/testsuite/gdb.threads/attach-many-short-lived-threads...done.
(gdb) Loaded /home/pedro/gdb/mygit/build/gdb/testsuite/gdb.threads/attach-many-short-lived-threads into /home/pedro/gdb/mygit/build/gdb/testsuite/../../gdb/gdb
attach 5940
Attaching to program: /home/pedro/gdb/mygit/build/gdb/testsuite/gdb.threads/attach-many-short-lived-threads, process 5940
warning: process 5940 is a zombie - the process has already terminated
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ptrace: Operation not permitted.
(gdb) PASS: gdb.threads/attach-many-short-lived-threads.exp: iter 1: attach
info threads
No threads.
(gdb) PASS: gdb.threads/attach-many-short-lived-threads.exp: iter 1: no new threads
set breakpoint always-inserted on
(gdb) PASS: gdb.threads/attach-many-short-lived-threads.exp: iter 1: set breakpoint always-inserted on
Other times the process dies while the test is ongoing (the process is
ptrace-stopped):
(gdb) print again = 1
Cannot access memory at address 0x6020cc
(gdb) FAIL: gdb.threads/attach-many-short-lived-threads.exp: iter 2: reset timer in the inferior
(Recall that on Linux, SIGKILL is not interceptable)
And other times it dies just while we're detaching:
$4 = 319
(gdb) PASS: gdb.threads/attach-many-short-lived-threads.exp: iter 2: print seconds_left
detach
Can't detach Thread 0x7fb13b7de700 (LWP 1842): No such process
(gdb) FAIL: gdb.threads/attach-many-short-lived-threads.exp: iter 2: detach
GDB mishandles the latter (it should ignore ESRCH while detaching just
like when continuing), but that's another story.
The fix here is to change spawn_wait_for_attach to use Expect's
'spawn' command instead of Tcl's 'exec&' to spawn programs, because
with spawn we control when to wait for/reap the process. That allows
killing the process by PID without being subject to pid-reuse races,
because even if the process is already dead, the kernel won't reuse
the process's PID until the zombie is reaped.
The other part of the problem lies in DejaGnu itself, unfortunately.
I have occasionally seen tests (attach-many-short-lived-threads
included, but not only that one) die with a random inexplicable
SIGTERM too, and that too is caused by the same reason, except that in
that case, the rogue SIGTERM is sent from this bit in DejaGnu's remote.exp:
exec sh -c "exec > /dev/null 2>&1 && (kill -2 $pgid || kill -2 $pid) && sleep 5 && (kill $pgid || kill $pid) && sleep 5 && (kill -9 $pgid || kill -9 $pid) &"
...
catch "wait -i $shell_id"
Even if the program exits promptly, that whole cascade of kills
carries on in the background, thus potentially killing the poor
process that manages to reuse $pid...
I sent a fix for that to the DejaGnu list:
http://lists.gnu.org/archive/html/dejagnu/2015-07/msg00000.html
With both patches in place, I haven't seen
attach-many-short-lived-threads.exp fail again.
Tested on x86_64 Fedora 20, native, gdbserver and extended-gdbserver.
gdb/testsuite/ChangeLog:
2015-07-31 Pedro Alves <palves@redhat.com>
* gdb.base/attach-pie-misread.exp: Rename $res to $test_spawn_id.
Use spawn_id_get_pid. Wait for spawn id after eof. Use
kill_wait_spawned_process instead of explicit "kill -9".
* gdb.base/attach-pie-noexec.exp: Adjust to spawn_wait_for_attach
returning a spawn id instead of a pid. Use spawn_id_get_pid and
kill_wait_spawned_process.
* gdb.base/attach-twice.exp: Likewise.
* gdb.base/attach.exp: Likewise.
(do_command_attach_tests): Use gdb_spawn_with_cmdline_opts and
gdb_test_multiple.
* gdb.base/solib-overlap.exp: Adjust to spawn_wait_for_attach
returning a spawn id instead of a pid. Use spawn_id_get_pid and
kill_wait_spawned_process.
* gdb.base/valgrind-infcall.exp: Likewise.
* gdb.multi/multi-attach.exp: Likewise.
* gdb.python/py-prompt.exp: Likewise.
* gdb.python/py-sync-interp.exp: Likewise.
* gdb.server/ext-attach.exp: Likewise.
* gdb.threads/attach-into-signal.exp (corefunc): Use
spawn_wait_for_attach, spawn_id_get_pid and
kill_wait_spawned_process.
* gdb.threads/attach-many-short-lived-threads.exp: Adjust to
spawn_wait_for_attach returning a spawn id instead of a pid. Use
spawn_id_get_pid and kill_wait_spawned_process.
* gdb.threads/attach-stopped.exp (corefunc): Use
spawn_wait_for_attach, spawn_id_get_pid and
kill_wait_spawned_process.
* gdb.base/break-interp.exp: Rename $res to $test_spawn_id.
Use spawn_id_get_pid. Wait for spawn id after eof. Use
kill_wait_spawned_process instead of explicit "kill -9".
* lib/gdb.exp (can_spawn_for_attach): Adjust comment.
(kill_wait_spawned_process, spawn_id_get_pid): New procedures.
(spawn_wait_for_attach): Use spawn instead of exec to spawn
processes. Don't map cygwin/windows pids here. Now returns a
spawn id list.
2015-07-31 21:06:24 +02:00
|
|
|
|
# that they can be attached to. Return a list of processes spawn IDs,
|
|
|
|
|
# one element for each process spawned. It's a test error to call
|
|
|
|
|
# this when [can_spawn_for_attach] is false.
|
2014-09-11 14:04:14 +02:00
|
|
|
|
|
|
|
|
|
proc spawn_wait_for_attach { executable_list } {
|
testsuite: tcl exec& -> 'kill -9 $pid' is racy (attach-many-short-lived-thread.exp races and others)
The buildbots show that attach-many-short-lived-thread.exp is racy.
But after staring at debug logs and playing with SystemTap scripts for
a (long) while, I figured out that neither GDB, nor the kernel nor the
test's program itself are at fault.
The problem is simply that the testsuite machinery is currently
subject to PID-reuse races. The attach-many-short-lived-threads.c
test program just happens to be much more susceptible to trigger this
race because threads and processes share the same number space on
Linux, and the test spawns many many short lived threads in
succession, thus enlarging the race window a lot.
Part of the problem is that several tests spawn processes with "exec&"
(in order to test the "attach" command) , and then at the end of the
test, to make sure things are cleaned up, issue a 'remote_spawn "kill
-p $testpid"'. Since with tcl's "exec&", tcl itself is responsible
for reaping the process's exit status, when we go kill the process,
testpid may have already exited _and_ its status may have (and often
has) been reaped already. Thus it can happen that another process
meanwhile reuses $testpid, and that "kill" command kills the wrong
process... Frequently, that happens to be
attach-many-short-lived-thread, but this explains other test's races
as well.
In the attach-many-short-lived-threads test, it sometimes manifests
like this:
(gdb) file /home/pedro/gdb/mygit/build/gdb/testsuite/gdb.threads/attach-many-short-lived-threads
Reading symbols from /home/pedro/gdb/mygit/build/gdb/testsuite/gdb.threads/attach-many-short-lived-threads...done.
(gdb) Loaded /home/pedro/gdb/mygit/build/gdb/testsuite/gdb.threads/attach-many-short-lived-threads into /home/pedro/gdb/mygit/build/gdb/testsuite/../../gdb/gdb
attach 5940
Attaching to program: /home/pedro/gdb/mygit/build/gdb/testsuite/gdb.threads/attach-many-short-lived-threads, process 5940
warning: process 5940 is a zombie - the process has already terminated
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ptrace: Operation not permitted.
(gdb) PASS: gdb.threads/attach-many-short-lived-threads.exp: iter 1: attach
info threads
No threads.
(gdb) PASS: gdb.threads/attach-many-short-lived-threads.exp: iter 1: no new threads
set breakpoint always-inserted on
(gdb) PASS: gdb.threads/attach-many-short-lived-threads.exp: iter 1: set breakpoint always-inserted on
Other times the process dies while the test is ongoing (the process is
ptrace-stopped):
(gdb) print again = 1
Cannot access memory at address 0x6020cc
(gdb) FAIL: gdb.threads/attach-many-short-lived-threads.exp: iter 2: reset timer in the inferior
(Recall that on Linux, SIGKILL is not interceptable)
And other times it dies just while we're detaching:
$4 = 319
(gdb) PASS: gdb.threads/attach-many-short-lived-threads.exp: iter 2: print seconds_left
detach
Can't detach Thread 0x7fb13b7de700 (LWP 1842): No such process
(gdb) FAIL: gdb.threads/attach-many-short-lived-threads.exp: iter 2: detach
GDB mishandles the latter (it should ignore ESRCH while detaching just
like when continuing), but that's another story.
The fix here is to change spawn_wait_for_attach to use Expect's
'spawn' command instead of Tcl's 'exec&' to spawn programs, because
with spawn we control when to wait for/reap the process. That allows
killing the process by PID without being subject to pid-reuse races,
because even if the process is already dead, the kernel won't reuse
the process's PID until the zombie is reaped.
The other part of the problem lies in DejaGnu itself, unfortunately.
I have occasionally seen tests (attach-many-short-lived-threads
included, but not only that one) die with a random inexplicable
SIGTERM too, and that too is caused by the same reason, except that in
that case, the rogue SIGTERM is sent from this bit in DejaGnu's remote.exp:
exec sh -c "exec > /dev/null 2>&1 && (kill -2 $pgid || kill -2 $pid) && sleep 5 && (kill $pgid || kill $pid) && sleep 5 && (kill -9 $pgid || kill -9 $pid) &"
...
catch "wait -i $shell_id"
Even if the program exits promptly, that whole cascade of kills
carries on in the background, thus potentially killing the poor
process that manages to reuse $pid...
I sent a fix for that to the DejaGnu list:
http://lists.gnu.org/archive/html/dejagnu/2015-07/msg00000.html
With both patches in place, I haven't seen
attach-many-short-lived-threads.exp fail again.
Tested on x86_64 Fedora 20, native, gdbserver and extended-gdbserver.
gdb/testsuite/ChangeLog:
2015-07-31 Pedro Alves <palves@redhat.com>
* gdb.base/attach-pie-misread.exp: Rename $res to $test_spawn_id.
Use spawn_id_get_pid. Wait for spawn id after eof. Use
kill_wait_spawned_process instead of explicit "kill -9".
* gdb.base/attach-pie-noexec.exp: Adjust to spawn_wait_for_attach
returning a spawn id instead of a pid. Use spawn_id_get_pid and
kill_wait_spawned_process.
* gdb.base/attach-twice.exp: Likewise.
* gdb.base/attach.exp: Likewise.
(do_command_attach_tests): Use gdb_spawn_with_cmdline_opts and
gdb_test_multiple.
* gdb.base/solib-overlap.exp: Adjust to spawn_wait_for_attach
returning a spawn id instead of a pid. Use spawn_id_get_pid and
kill_wait_spawned_process.
* gdb.base/valgrind-infcall.exp: Likewise.
* gdb.multi/multi-attach.exp: Likewise.
* gdb.python/py-prompt.exp: Likewise.
* gdb.python/py-sync-interp.exp: Likewise.
* gdb.server/ext-attach.exp: Likewise.
* gdb.threads/attach-into-signal.exp (corefunc): Use
spawn_wait_for_attach, spawn_id_get_pid and
kill_wait_spawned_process.
* gdb.threads/attach-many-short-lived-threads.exp: Adjust to
spawn_wait_for_attach returning a spawn id instead of a pid. Use
spawn_id_get_pid and kill_wait_spawned_process.
* gdb.threads/attach-stopped.exp (corefunc): Use
spawn_wait_for_attach, spawn_id_get_pid and
kill_wait_spawned_process.
* gdb.base/break-interp.exp: Rename $res to $test_spawn_id.
Use spawn_id_get_pid. Wait for spawn id after eof. Use
kill_wait_spawned_process instead of explicit "kill -9".
* lib/gdb.exp (can_spawn_for_attach): Adjust comment.
(kill_wait_spawned_process, spawn_id_get_pid): New procedures.
(spawn_wait_for_attach): Use spawn instead of exec to spawn
processes. Don't map cygwin/windows pids here. Now returns a
spawn id list.
2015-07-31 21:06:24 +02:00
|
|
|
|
set spawn_id_list {}
|
2014-09-11 14:04:14 +02:00
|
|
|
|
|
2015-01-09 12:04:19 +01:00
|
|
|
|
if ![can_spawn_for_attach] {
|
|
|
|
|
# The caller should have checked can_spawn_for_attach itself
|
|
|
|
|
# before getting here.
|
|
|
|
|
error "can't spawn for attach with this target/board"
|
|
|
|
|
}
|
|
|
|
|
|
2014-09-11 14:04:14 +02:00
|
|
|
|
foreach {executable} $executable_list {
|
testsuite: tcl exec& -> 'kill -9 $pid' is racy (attach-many-short-lived-thread.exp races and others)
The buildbots show that attach-many-short-lived-thread.exp is racy.
But after staring at debug logs and playing with SystemTap scripts for
a (long) while, I figured out that neither GDB, nor the kernel nor the
test's program itself are at fault.
The problem is simply that the testsuite machinery is currently
subject to PID-reuse races. The attach-many-short-lived-threads.c
test program just happens to be much more susceptible to trigger this
race because threads and processes share the same number space on
Linux, and the test spawns many many short lived threads in
succession, thus enlarging the race window a lot.
Part of the problem is that several tests spawn processes with "exec&"
(in order to test the "attach" command) , and then at the end of the
test, to make sure things are cleaned up, issue a 'remote_spawn "kill
-p $testpid"'. Since with tcl's "exec&", tcl itself is responsible
for reaping the process's exit status, when we go kill the process,
testpid may have already exited _and_ its status may have (and often
has) been reaped already. Thus it can happen that another process
meanwhile reuses $testpid, and that "kill" command kills the wrong
process... Frequently, that happens to be
attach-many-short-lived-thread, but this explains other test's races
as well.
In the attach-many-short-lived-threads test, it sometimes manifests
like this:
(gdb) file /home/pedro/gdb/mygit/build/gdb/testsuite/gdb.threads/attach-many-short-lived-threads
Reading symbols from /home/pedro/gdb/mygit/build/gdb/testsuite/gdb.threads/attach-many-short-lived-threads...done.
(gdb) Loaded /home/pedro/gdb/mygit/build/gdb/testsuite/gdb.threads/attach-many-short-lived-threads into /home/pedro/gdb/mygit/build/gdb/testsuite/../../gdb/gdb
attach 5940
Attaching to program: /home/pedro/gdb/mygit/build/gdb/testsuite/gdb.threads/attach-many-short-lived-threads, process 5940
warning: process 5940 is a zombie - the process has already terminated
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ptrace: Operation not permitted.
(gdb) PASS: gdb.threads/attach-many-short-lived-threads.exp: iter 1: attach
info threads
No threads.
(gdb) PASS: gdb.threads/attach-many-short-lived-threads.exp: iter 1: no new threads
set breakpoint always-inserted on
(gdb) PASS: gdb.threads/attach-many-short-lived-threads.exp: iter 1: set breakpoint always-inserted on
Other times the process dies while the test is ongoing (the process is
ptrace-stopped):
(gdb) print again = 1
Cannot access memory at address 0x6020cc
(gdb) FAIL: gdb.threads/attach-many-short-lived-threads.exp: iter 2: reset timer in the inferior
(Recall that on Linux, SIGKILL is not interceptable)
And other times it dies just while we're detaching:
$4 = 319
(gdb) PASS: gdb.threads/attach-many-short-lived-threads.exp: iter 2: print seconds_left
detach
Can't detach Thread 0x7fb13b7de700 (LWP 1842): No such process
(gdb) FAIL: gdb.threads/attach-many-short-lived-threads.exp: iter 2: detach
GDB mishandles the latter (it should ignore ESRCH while detaching just
like when continuing), but that's another story.
The fix here is to change spawn_wait_for_attach to use Expect's
'spawn' command instead of Tcl's 'exec&' to spawn programs, because
with spawn we control when to wait for/reap the process. That allows
killing the process by PID without being subject to pid-reuse races,
because even if the process is already dead, the kernel won't reuse
the process's PID until the zombie is reaped.
The other part of the problem lies in DejaGnu itself, unfortunately.
I have occasionally seen tests (attach-many-short-lived-threads
included, but not only that one) die with a random inexplicable
SIGTERM too, and that too is caused by the same reason, except that in
that case, the rogue SIGTERM is sent from this bit in DejaGnu's remote.exp:
exec sh -c "exec > /dev/null 2>&1 && (kill -2 $pgid || kill -2 $pid) && sleep 5 && (kill $pgid || kill $pid) && sleep 5 && (kill -9 $pgid || kill -9 $pid) &"
...
catch "wait -i $shell_id"
Even if the program exits promptly, that whole cascade of kills
carries on in the background, thus potentially killing the poor
process that manages to reuse $pid...
I sent a fix for that to the DejaGnu list:
http://lists.gnu.org/archive/html/dejagnu/2015-07/msg00000.html
With both patches in place, I haven't seen
attach-many-short-lived-threads.exp fail again.
Tested on x86_64 Fedora 20, native, gdbserver and extended-gdbserver.
gdb/testsuite/ChangeLog:
2015-07-31 Pedro Alves <palves@redhat.com>
* gdb.base/attach-pie-misread.exp: Rename $res to $test_spawn_id.
Use spawn_id_get_pid. Wait for spawn id after eof. Use
kill_wait_spawned_process instead of explicit "kill -9".
* gdb.base/attach-pie-noexec.exp: Adjust to spawn_wait_for_attach
returning a spawn id instead of a pid. Use spawn_id_get_pid and
kill_wait_spawned_process.
* gdb.base/attach-twice.exp: Likewise.
* gdb.base/attach.exp: Likewise.
(do_command_attach_tests): Use gdb_spawn_with_cmdline_opts and
gdb_test_multiple.
* gdb.base/solib-overlap.exp: Adjust to spawn_wait_for_attach
returning a spawn id instead of a pid. Use spawn_id_get_pid and
kill_wait_spawned_process.
* gdb.base/valgrind-infcall.exp: Likewise.
* gdb.multi/multi-attach.exp: Likewise.
* gdb.python/py-prompt.exp: Likewise.
* gdb.python/py-sync-interp.exp: Likewise.
* gdb.server/ext-attach.exp: Likewise.
* gdb.threads/attach-into-signal.exp (corefunc): Use
spawn_wait_for_attach, spawn_id_get_pid and
kill_wait_spawned_process.
* gdb.threads/attach-many-short-lived-threads.exp: Adjust to
spawn_wait_for_attach returning a spawn id instead of a pid. Use
spawn_id_get_pid and kill_wait_spawned_process.
* gdb.threads/attach-stopped.exp (corefunc): Use
spawn_wait_for_attach, spawn_id_get_pid and
kill_wait_spawned_process.
* gdb.base/break-interp.exp: Rename $res to $test_spawn_id.
Use spawn_id_get_pid. Wait for spawn id after eof. Use
kill_wait_spawned_process instead of explicit "kill -9".
* lib/gdb.exp (can_spawn_for_attach): Adjust comment.
(kill_wait_spawned_process, spawn_id_get_pid): New procedures.
(spawn_wait_for_attach): Use spawn instead of exec to spawn
processes. Don't map cygwin/windows pids here. Now returns a
spawn id list.
2015-07-31 21:06:24 +02:00
|
|
|
|
# Note we use Expect's spawn, not Tcl's exec, because with
|
|
|
|
|
# spawn we control when to wait for/reap the process. That
|
|
|
|
|
# allows killing the process by PID without being subject to
|
|
|
|
|
# pid-reuse races.
|
|
|
|
|
lappend spawn_id_list [remote_spawn target $executable]
|
2014-09-11 14:04:14 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
sleep 2
|
|
|
|
|
|
testsuite: tcl exec& -> 'kill -9 $pid' is racy (attach-many-short-lived-thread.exp races and others)
The buildbots show that attach-many-short-lived-thread.exp is racy.
But after staring at debug logs and playing with SystemTap scripts for
a (long) while, I figured out that neither GDB, nor the kernel nor the
test's program itself are at fault.
The problem is simply that the testsuite machinery is currently
subject to PID-reuse races. The attach-many-short-lived-threads.c
test program just happens to be much more susceptible to trigger this
race because threads and processes share the same number space on
Linux, and the test spawns many many short lived threads in
succession, thus enlarging the race window a lot.
Part of the problem is that several tests spawn processes with "exec&"
(in order to test the "attach" command) , and then at the end of the
test, to make sure things are cleaned up, issue a 'remote_spawn "kill
-p $testpid"'. Since with tcl's "exec&", tcl itself is responsible
for reaping the process's exit status, when we go kill the process,
testpid may have already exited _and_ its status may have (and often
has) been reaped already. Thus it can happen that another process
meanwhile reuses $testpid, and that "kill" command kills the wrong
process... Frequently, that happens to be
attach-many-short-lived-thread, but this explains other test's races
as well.
In the attach-many-short-lived-threads test, it sometimes manifests
like this:
(gdb) file /home/pedro/gdb/mygit/build/gdb/testsuite/gdb.threads/attach-many-short-lived-threads
Reading symbols from /home/pedro/gdb/mygit/build/gdb/testsuite/gdb.threads/attach-many-short-lived-threads...done.
(gdb) Loaded /home/pedro/gdb/mygit/build/gdb/testsuite/gdb.threads/attach-many-short-lived-threads into /home/pedro/gdb/mygit/build/gdb/testsuite/../../gdb/gdb
attach 5940
Attaching to program: /home/pedro/gdb/mygit/build/gdb/testsuite/gdb.threads/attach-many-short-lived-threads, process 5940
warning: process 5940 is a zombie - the process has already terminated
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ptrace: Operation not permitted.
(gdb) PASS: gdb.threads/attach-many-short-lived-threads.exp: iter 1: attach
info threads
No threads.
(gdb) PASS: gdb.threads/attach-many-short-lived-threads.exp: iter 1: no new threads
set breakpoint always-inserted on
(gdb) PASS: gdb.threads/attach-many-short-lived-threads.exp: iter 1: set breakpoint always-inserted on
Other times the process dies while the test is ongoing (the process is
ptrace-stopped):
(gdb) print again = 1
Cannot access memory at address 0x6020cc
(gdb) FAIL: gdb.threads/attach-many-short-lived-threads.exp: iter 2: reset timer in the inferior
(Recall that on Linux, SIGKILL is not interceptable)
And other times it dies just while we're detaching:
$4 = 319
(gdb) PASS: gdb.threads/attach-many-short-lived-threads.exp: iter 2: print seconds_left
detach
Can't detach Thread 0x7fb13b7de700 (LWP 1842): No such process
(gdb) FAIL: gdb.threads/attach-many-short-lived-threads.exp: iter 2: detach
GDB mishandles the latter (it should ignore ESRCH while detaching just
like when continuing), but that's another story.
The fix here is to change spawn_wait_for_attach to use Expect's
'spawn' command instead of Tcl's 'exec&' to spawn programs, because
with spawn we control when to wait for/reap the process. That allows
killing the process by PID without being subject to pid-reuse races,
because even if the process is already dead, the kernel won't reuse
the process's PID until the zombie is reaped.
The other part of the problem lies in DejaGnu itself, unfortunately.
I have occasionally seen tests (attach-many-short-lived-threads
included, but not only that one) die with a random inexplicable
SIGTERM too, and that too is caused by the same reason, except that in
that case, the rogue SIGTERM is sent from this bit in DejaGnu's remote.exp:
exec sh -c "exec > /dev/null 2>&1 && (kill -2 $pgid || kill -2 $pid) && sleep 5 && (kill $pgid || kill $pid) && sleep 5 && (kill -9 $pgid || kill -9 $pid) &"
...
catch "wait -i $shell_id"
Even if the program exits promptly, that whole cascade of kills
carries on in the background, thus potentially killing the poor
process that manages to reuse $pid...
I sent a fix for that to the DejaGnu list:
http://lists.gnu.org/archive/html/dejagnu/2015-07/msg00000.html
With both patches in place, I haven't seen
attach-many-short-lived-threads.exp fail again.
Tested on x86_64 Fedora 20, native, gdbserver and extended-gdbserver.
gdb/testsuite/ChangeLog:
2015-07-31 Pedro Alves <palves@redhat.com>
* gdb.base/attach-pie-misread.exp: Rename $res to $test_spawn_id.
Use spawn_id_get_pid. Wait for spawn id after eof. Use
kill_wait_spawned_process instead of explicit "kill -9".
* gdb.base/attach-pie-noexec.exp: Adjust to spawn_wait_for_attach
returning a spawn id instead of a pid. Use spawn_id_get_pid and
kill_wait_spawned_process.
* gdb.base/attach-twice.exp: Likewise.
* gdb.base/attach.exp: Likewise.
(do_command_attach_tests): Use gdb_spawn_with_cmdline_opts and
gdb_test_multiple.
* gdb.base/solib-overlap.exp: Adjust to spawn_wait_for_attach
returning a spawn id instead of a pid. Use spawn_id_get_pid and
kill_wait_spawned_process.
* gdb.base/valgrind-infcall.exp: Likewise.
* gdb.multi/multi-attach.exp: Likewise.
* gdb.python/py-prompt.exp: Likewise.
* gdb.python/py-sync-interp.exp: Likewise.
* gdb.server/ext-attach.exp: Likewise.
* gdb.threads/attach-into-signal.exp (corefunc): Use
spawn_wait_for_attach, spawn_id_get_pid and
kill_wait_spawned_process.
* gdb.threads/attach-many-short-lived-threads.exp: Adjust to
spawn_wait_for_attach returning a spawn id instead of a pid. Use
spawn_id_get_pid and kill_wait_spawned_process.
* gdb.threads/attach-stopped.exp (corefunc): Use
spawn_wait_for_attach, spawn_id_get_pid and
kill_wait_spawned_process.
* gdb.base/break-interp.exp: Rename $res to $test_spawn_id.
Use spawn_id_get_pid. Wait for spawn id after eof. Use
kill_wait_spawned_process instead of explicit "kill -9".
* lib/gdb.exp (can_spawn_for_attach): Adjust comment.
(kill_wait_spawned_process, spawn_id_get_pid): New procedures.
(spawn_wait_for_attach): Use spawn instead of exec to spawn
processes. Don't map cygwin/windows pids here. Now returns a
spawn id list.
2015-07-31 21:06:24 +02:00
|
|
|
|
return $spawn_id_list
|
2014-09-11 14:04:14 +02:00
|
|
|
|
}
|
|
|
|
|
|
2006-06-13 15:20:25 +02:00
|
|
|
|
#
|
|
|
|
|
# gdb_load_cmd -- load a file into the debugger.
|
|
|
|
|
# ARGS - additional args to load command.
|
|
|
|
|
# return a -1 if anything goes wrong.
|
|
|
|
|
#
|
|
|
|
|
proc gdb_load_cmd { args } {
|
|
|
|
|
global gdb_prompt
|
|
|
|
|
|
|
|
|
|
if [target_info exists gdb_load_timeout] {
|
|
|
|
|
set loadtimeout [target_info gdb_load_timeout]
|
|
|
|
|
} else {
|
|
|
|
|
set loadtimeout 1600
|
|
|
|
|
}
|
|
|
|
|
send_gdb "load $args\n"
|
2007-10-11 22:08:01 +02:00
|
|
|
|
verbose "Timeout is now $loadtimeout seconds" 2
|
2006-06-13 15:20:25 +02:00
|
|
|
|
gdb_expect $loadtimeout {
|
|
|
|
|
-re "Loading section\[^\r\]*\r\n" {
|
|
|
|
|
exp_continue
|
|
|
|
|
}
|
|
|
|
|
-re "Start address\[\r\]*\r\n" {
|
|
|
|
|
exp_continue
|
|
|
|
|
}
|
|
|
|
|
-re "Transfer rate\[\r\]*\r\n" {
|
|
|
|
|
exp_continue
|
|
|
|
|
}
|
|
|
|
|
-re "Memory access error\[^\r\]*\r\n" {
|
|
|
|
|
perror "Failed to load program"
|
|
|
|
|
return -1
|
|
|
|
|
}
|
|
|
|
|
-re "$gdb_prompt $" {
|
|
|
|
|
return 0
|
|
|
|
|
}
|
|
|
|
|
-re "(.*)\r\n$gdb_prompt " {
|
|
|
|
|
perror "Unexpected reponse from 'load' -- $expect_out(1,string)"
|
|
|
|
|
return -1
|
|
|
|
|
}
|
|
|
|
|
timeout {
|
2008-03-07 17:23:41 +01:00
|
|
|
|
perror "Timed out trying to load $args."
|
2006-06-13 15:20:25 +02:00
|
|
|
|
return -1
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return -1
|
|
|
|
|
}
|
|
|
|
|
|
2012-11-06 16:21:24 +01:00
|
|
|
|
# Invoke "gcore". CORE is the name of the core file to write. TEST
|
|
|
|
|
# is the name of the test case. This will return 1 if the core file
|
|
|
|
|
# was created, 0 otherwise. If this fails to make a core file because
|
|
|
|
|
# this configuration of gdb does not support making core files, it
|
|
|
|
|
# will call "unsupported", not "fail". However, if this fails to make
|
|
|
|
|
# a core file for some other reason, then it will call "fail".
|
|
|
|
|
|
|
|
|
|
proc gdb_gcore_cmd {core test} {
|
|
|
|
|
global gdb_prompt
|
|
|
|
|
|
|
|
|
|
set result 0
|
|
|
|
|
gdb_test_multiple "gcore $core" $test {
|
|
|
|
|
-re "Saved corefile .*\[\r\n\]+$gdb_prompt $" {
|
|
|
|
|
pass $test
|
|
|
|
|
set result 1
|
|
|
|
|
}
|
2013-10-24 21:37:49 +02:00
|
|
|
|
-re "(?:Can't create a corefile|Target does not support core file generation\\.)\[\r\n\]+$gdb_prompt $" {
|
2012-11-06 16:21:24 +01:00
|
|
|
|
unsupported $test
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return $result
|
|
|
|
|
}
|
|
|
|
|
|
2013-05-07 00:11:16 +02:00
|
|
|
|
# Load core file CORE. TEST is the name of the test case.
|
|
|
|
|
# This will record a pass/fail for loading the core file.
|
|
|
|
|
# Returns:
|
|
|
|
|
# 1 - core file is successfully loaded
|
|
|
|
|
# 0 - core file loaded but has a non fatal error
|
|
|
|
|
# -1 - core file failed to load
|
|
|
|
|
|
|
|
|
|
proc gdb_core_cmd { core test } {
|
|
|
|
|
global gdb_prompt
|
|
|
|
|
|
2013-10-10 11:54:13 +02:00
|
|
|
|
gdb_test_multiple "core $core" "$test" {
|
2013-05-07 00:11:16 +02:00
|
|
|
|
-re "\\\[Thread debugging using \[^ \r\n\]* enabled\\\]\r\n" {
|
|
|
|
|
exp_continue
|
|
|
|
|
}
|
|
|
|
|
-re " is not a core dump:.*\r\n$gdb_prompt $" {
|
2013-10-10 11:54:13 +02:00
|
|
|
|
fail "$test (bad file format)"
|
2013-05-07 00:11:16 +02:00
|
|
|
|
return -1
|
|
|
|
|
}
|
|
|
|
|
-re ": No such file or directory.*\r\n$gdb_prompt $" {
|
2013-10-10 11:54:13 +02:00
|
|
|
|
fail "$test (file not found)"
|
2013-05-07 00:11:16 +02:00
|
|
|
|
return -1
|
|
|
|
|
}
|
|
|
|
|
-re "Couldn't find .* registers in core file.*\r\n$gdb_prompt $" {
|
2013-10-10 11:54:13 +02:00
|
|
|
|
fail "$test (incomplete note section)"
|
2013-05-07 00:11:16 +02:00
|
|
|
|
return 0
|
|
|
|
|
}
|
|
|
|
|
-re "Core was generated by .*\r\n$gdb_prompt $" {
|
2013-10-10 11:54:13 +02:00
|
|
|
|
pass "$test"
|
2013-05-07 00:11:16 +02:00
|
|
|
|
return 1
|
|
|
|
|
}
|
|
|
|
|
-re ".*$gdb_prompt $" {
|
2013-10-10 11:54:13 +02:00
|
|
|
|
fail "$test"
|
2013-05-07 00:11:16 +02:00
|
|
|
|
return -1
|
|
|
|
|
}
|
|
|
|
|
timeout {
|
2013-10-10 11:54:13 +02:00
|
|
|
|
fail "$test (timeout)"
|
2013-05-07 00:11:16 +02:00
|
|
|
|
return -1
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
fail "unsupported output from 'core' command"
|
|
|
|
|
return -1
|
|
|
|
|
}
|
|
|
|
|
|
2010-03-12 20:17:01 +01:00
|
|
|
|
# Return the filename to download to the target and load on the target
|
|
|
|
|
# for this shared library. Normally just LIBNAME, unless shared libraries
|
|
|
|
|
# for this target have separate link and load images.
|
|
|
|
|
|
|
|
|
|
proc shlib_target_file { libname } {
|
|
|
|
|
return $libname
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# Return the filename GDB will load symbols from when debugging this
|
|
|
|
|
# shared library. Normally just LIBNAME, unless shared libraries for
|
|
|
|
|
# this target have separate link and load images.
|
|
|
|
|
|
|
|
|
|
proc shlib_symbol_file { libname } {
|
|
|
|
|
return $libname
|
|
|
|
|
}
|
|
|
|
|
|
2011-05-05 18:29:58 +02:00
|
|
|
|
# Return the filename to download to the target and load for this
|
|
|
|
|
# executable. Normally just BINFILE unless it is renamed to something
|
|
|
|
|
# else for this target.
|
|
|
|
|
|
|
|
|
|
proc exec_target_file { binfile } {
|
|
|
|
|
return $binfile
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# Return the filename GDB will load symbols from when debugging this
|
|
|
|
|
# executable. Normally just BINFILE unless executables for this target
|
|
|
|
|
# have separate files for symbols.
|
|
|
|
|
|
|
|
|
|
proc exec_symbol_file { binfile } {
|
|
|
|
|
return $binfile
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# Rename the executable file. Normally this is just BINFILE1 being renamed
|
|
|
|
|
# to BINFILE2, but some targets require multiple binary files.
|
|
|
|
|
proc gdb_rename_execfile { binfile1 binfile2 } {
|
2011-05-11 11:11:17 +02:00
|
|
|
|
file rename -force [exec_target_file ${binfile1}] \
|
|
|
|
|
[exec_target_file ${binfile2}]
|
2011-05-05 18:29:58 +02:00
|
|
|
|
if { [exec_target_file ${binfile1}] != [exec_symbol_file ${binfile1}] } {
|
2011-05-11 11:11:17 +02:00
|
|
|
|
file rename -force [exec_symbol_file ${binfile1}] \
|
|
|
|
|
[exec_symbol_file ${binfile2}]
|
2011-05-05 18:29:58 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# "Touch" the executable file to update the date. Normally this is just
|
|
|
|
|
# BINFILE, but some targets require multiple files.
|
|
|
|
|
proc gdb_touch_execfile { binfile } {
|
2011-05-11 11:11:17 +02:00
|
|
|
|
set time [clock seconds]
|
|
|
|
|
file mtime [exec_target_file ${binfile}] $time
|
2011-05-05 18:29:58 +02:00
|
|
|
|
if { [exec_target_file ${binfile}] != [exec_symbol_file ${binfile}] } {
|
2011-05-11 11:11:17 +02:00
|
|
|
|
file mtime [exec_symbol_file ${binfile}] $time
|
2011-05-05 18:29:58 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
Improve gdb_remote_download, remove gdb_download
This patch removes gdb_download in favor of gdb_remote_download, since
they are very close in functionality. Also, in preparation for the
following patch about shared library handling during tests, it improves
gdb_remote_download so that it uses standard_output_file for any
destination board that is local, not only host.
If the destination board is remote, gdb_remote_download will use the
standard remote_download from DejaGnu, resulting in the file being
transferred on the remote system.
If the destination is local, gdb_remote_download will copy the file to
the standard test directory (found using standard_output_file). Tcl's
file copy seems to handle gracefully cases where the source file is the
same as the destination, so I don't think it's necessary to check for
that case ourselves, as a previous version of the patch did.
I'd prefer to keep the name gdb_download instead of gdb_remote_download,
since I don't like the fact that gdb_remote_download implies that the
destination is remote, when it's not always the case. However,
gdb_remote_download is used at many more places than gdb_download, so
it's easier to reuse that. Also, since it's a wrapper around DejaGnu's
remote_download, it might be better to keep that name. I don't know.
I ran the testsuite native, with native-gdbserver and with a
remote gdbserver, and didn't see any related failure.
gdb/testsuite/ChangeLog:
* gdb.base/jit-so.exp: Use gdb_remote_download instead of
gdb_download. Use it even if the target is not remote.
* gdb.base/jit.exp (compile_jit_test): Likewise.
* lib/gdb.exp (gdb_remote_download): Copy files to the standard
output directory if the destination board is local, otherwise use
the standard remote_download from DejaGnu.
(gdb_download): Remove.
(gdb_load_shlibs): Use gdb_remote_download instead of
gdb_download.
* lib/gdbserver-support.exp (gdbserver_download_current_prog):
Use gdb_remote_download instead of gdb_download. Use it even if
the target is not remote.
* lib/mi-support.exp (mi_load_shlibs): Use gdb_remote_download
instead of gdb_download.
2016-04-05 19:59:49 +02:00
|
|
|
|
# Like remote_download but provides a gdb-specific behavior.
|
|
|
|
|
#
|
|
|
|
|
# If the destination board is remote, the local file FROMFILE is transferred as
|
|
|
|
|
# usual with remote_download to TOFILE on the remote board. The destination
|
|
|
|
|
# filename is added to the CLEANFILES global, so it can be cleaned up at the
|
|
|
|
|
# end of the test.
|
|
|
|
|
#
|
|
|
|
|
# If the destination board is local, the destination path TOFILE is passed
|
|
|
|
|
# through standard_output_file, and FROMFILE is copied there.
|
|
|
|
|
#
|
|
|
|
|
# In both cases, if TOFILE is omitted, it defaults to the [file tail] of
|
|
|
|
|
# FROMFILE.
|
2013-08-22 15:44:16 +02:00
|
|
|
|
|
|
|
|
|
proc gdb_remote_download {dest fromfile {tofile {}}} {
|
Improve gdb_remote_download, remove gdb_download
This patch removes gdb_download in favor of gdb_remote_download, since
they are very close in functionality. Also, in preparation for the
following patch about shared library handling during tests, it improves
gdb_remote_download so that it uses standard_output_file for any
destination board that is local, not only host.
If the destination board is remote, gdb_remote_download will use the
standard remote_download from DejaGnu, resulting in the file being
transferred on the remote system.
If the destination is local, gdb_remote_download will copy the file to
the standard test directory (found using standard_output_file). Tcl's
file copy seems to handle gracefully cases where the source file is the
same as the destination, so I don't think it's necessary to check for
that case ourselves, as a previous version of the patch did.
I'd prefer to keep the name gdb_download instead of gdb_remote_download,
since I don't like the fact that gdb_remote_download implies that the
destination is remote, when it's not always the case. However,
gdb_remote_download is used at many more places than gdb_download, so
it's easier to reuse that. Also, since it's a wrapper around DejaGnu's
remote_download, it might be better to keep that name. I don't know.
I ran the testsuite native, with native-gdbserver and with a
remote gdbserver, and didn't see any related failure.
gdb/testsuite/ChangeLog:
* gdb.base/jit-so.exp: Use gdb_remote_download instead of
gdb_download. Use it even if the target is not remote.
* gdb.base/jit.exp (compile_jit_test): Likewise.
* lib/gdb.exp (gdb_remote_download): Copy files to the standard
output directory if the destination board is local, otherwise use
the standard remote_download from DejaGnu.
(gdb_download): Remove.
(gdb_load_shlibs): Use gdb_remote_download instead of
gdb_download.
* lib/gdbserver-support.exp (gdbserver_download_current_prog):
Use gdb_remote_download instead of gdb_download. Use it even if
the target is not remote.
* lib/mi-support.exp (mi_load_shlibs): Use gdb_remote_download
instead of gdb_download.
2016-04-05 19:59:49 +02:00
|
|
|
|
# If TOFILE is not given, default to the same filename as FROMFILE.
|
|
|
|
|
if {[string length $tofile] == 0} {
|
|
|
|
|
set tofile [file tail $fromfile]
|
2013-08-22 15:44:16 +02:00
|
|
|
|
}
|
2013-08-27 02:19:02 +02:00
|
|
|
|
|
Improve gdb_remote_download, remove gdb_download
This patch removes gdb_download in favor of gdb_remote_download, since
they are very close in functionality. Also, in preparation for the
following patch about shared library handling during tests, it improves
gdb_remote_download so that it uses standard_output_file for any
destination board that is local, not only host.
If the destination board is remote, gdb_remote_download will use the
standard remote_download from DejaGnu, resulting in the file being
transferred on the remote system.
If the destination is local, gdb_remote_download will copy the file to
the standard test directory (found using standard_output_file). Tcl's
file copy seems to handle gracefully cases where the source file is the
same as the destination, so I don't think it's necessary to check for
that case ourselves, as a previous version of the patch did.
I'd prefer to keep the name gdb_download instead of gdb_remote_download,
since I don't like the fact that gdb_remote_download implies that the
destination is remote, when it's not always the case. However,
gdb_remote_download is used at many more places than gdb_download, so
it's easier to reuse that. Also, since it's a wrapper around DejaGnu's
remote_download, it might be better to keep that name. I don't know.
I ran the testsuite native, with native-gdbserver and with a
remote gdbserver, and didn't see any related failure.
gdb/testsuite/ChangeLog:
* gdb.base/jit-so.exp: Use gdb_remote_download instead of
gdb_download. Use it even if the target is not remote.
* gdb.base/jit.exp (compile_jit_test): Likewise.
* lib/gdb.exp (gdb_remote_download): Copy files to the standard
output directory if the destination board is local, otherwise use
the standard remote_download from DejaGnu.
(gdb_download): Remove.
(gdb_load_shlibs): Use gdb_remote_download instead of
gdb_download.
* lib/gdbserver-support.exp (gdbserver_download_current_prog):
Use gdb_remote_download instead of gdb_download. Use it even if
the target is not remote.
* lib/mi-support.exp (mi_load_shlibs): Use gdb_remote_download
instead of gdb_download.
2016-04-05 19:59:49 +02:00
|
|
|
|
if {[is_remote $dest]} {
|
|
|
|
|
# When the DEST is remote, we simply send the file to DEST.
|
|
|
|
|
global cleanfiles
|
2013-08-22 15:44:16 +02:00
|
|
|
|
|
Improve gdb_remote_download, remove gdb_download
This patch removes gdb_download in favor of gdb_remote_download, since
they are very close in functionality. Also, in preparation for the
following patch about shared library handling during tests, it improves
gdb_remote_download so that it uses standard_output_file for any
destination board that is local, not only host.
If the destination board is remote, gdb_remote_download will use the
standard remote_download from DejaGnu, resulting in the file being
transferred on the remote system.
If the destination is local, gdb_remote_download will copy the file to
the standard test directory (found using standard_output_file). Tcl's
file copy seems to handle gracefully cases where the source file is the
same as the destination, so I don't think it's necessary to check for
that case ourselves, as a previous version of the patch did.
I'd prefer to keep the name gdb_download instead of gdb_remote_download,
since I don't like the fact that gdb_remote_download implies that the
destination is remote, when it's not always the case. However,
gdb_remote_download is used at many more places than gdb_download, so
it's easier to reuse that. Also, since it's a wrapper around DejaGnu's
remote_download, it might be better to keep that name. I don't know.
I ran the testsuite native, with native-gdbserver and with a
remote gdbserver, and didn't see any related failure.
gdb/testsuite/ChangeLog:
* gdb.base/jit-so.exp: Use gdb_remote_download instead of
gdb_download. Use it even if the target is not remote.
* gdb.base/jit.exp (compile_jit_test): Likewise.
* lib/gdb.exp (gdb_remote_download): Copy files to the standard
output directory if the destination board is local, otherwise use
the standard remote_download from DejaGnu.
(gdb_download): Remove.
(gdb_load_shlibs): Use gdb_remote_download instead of
gdb_download.
* lib/gdbserver-support.exp (gdbserver_download_current_prog):
Use gdb_remote_download instead of gdb_download. Use it even if
the target is not remote.
* lib/mi-support.exp (mi_load_shlibs): Use gdb_remote_download
instead of gdb_download.
2016-04-05 19:59:49 +02:00
|
|
|
|
set destname [remote_download $dest $fromfile $tofile]
|
|
|
|
|
lappend cleanfiles $destname
|
2007-05-16 16:21:47 +02:00
|
|
|
|
|
Improve gdb_remote_download, remove gdb_download
This patch removes gdb_download in favor of gdb_remote_download, since
they are very close in functionality. Also, in preparation for the
following patch about shared library handling during tests, it improves
gdb_remote_download so that it uses standard_output_file for any
destination board that is local, not only host.
If the destination board is remote, gdb_remote_download will use the
standard remote_download from DejaGnu, resulting in the file being
transferred on the remote system.
If the destination is local, gdb_remote_download will copy the file to
the standard test directory (found using standard_output_file). Tcl's
file copy seems to handle gracefully cases where the source file is the
same as the destination, so I don't think it's necessary to check for
that case ourselves, as a previous version of the patch did.
I'd prefer to keep the name gdb_download instead of gdb_remote_download,
since I don't like the fact that gdb_remote_download implies that the
destination is remote, when it's not always the case. However,
gdb_remote_download is used at many more places than gdb_download, so
it's easier to reuse that. Also, since it's a wrapper around DejaGnu's
remote_download, it might be better to keep that name. I don't know.
I ran the testsuite native, with native-gdbserver and with a
remote gdbserver, and didn't see any related failure.
gdb/testsuite/ChangeLog:
* gdb.base/jit-so.exp: Use gdb_remote_download instead of
gdb_download. Use it even if the target is not remote.
* gdb.base/jit.exp (compile_jit_test): Likewise.
* lib/gdb.exp (gdb_remote_download): Copy files to the standard
output directory if the destination board is local, otherwise use
the standard remote_download from DejaGnu.
(gdb_download): Remove.
(gdb_load_shlibs): Use gdb_remote_download instead of
gdb_download.
* lib/gdbserver-support.exp (gdbserver_download_current_prog):
Use gdb_remote_download instead of gdb_download. Use it even if
the target is not remote.
* lib/mi-support.exp (mi_load_shlibs): Use gdb_remote_download
instead of gdb_download.
2016-04-05 19:59:49 +02:00
|
|
|
|
return $destname
|
|
|
|
|
} else {
|
2016-04-13 16:47:29 +02:00
|
|
|
|
# When the DEST is local, we copy the file to the test directory (where
|
|
|
|
|
# the executable is).
|
|
|
|
|
#
|
|
|
|
|
# Note that we pass TOFILE through standard_output_file, regardless of
|
|
|
|
|
# whether it is absolute or relative, because we don't want the tests
|
|
|
|
|
# to be able to write outside their standard output directory.
|
|
|
|
|
|
Improve gdb_remote_download, remove gdb_download
This patch removes gdb_download in favor of gdb_remote_download, since
they are very close in functionality. Also, in preparation for the
following patch about shared library handling during tests, it improves
gdb_remote_download so that it uses standard_output_file for any
destination board that is local, not only host.
If the destination board is remote, gdb_remote_download will use the
standard remote_download from DejaGnu, resulting in the file being
transferred on the remote system.
If the destination is local, gdb_remote_download will copy the file to
the standard test directory (found using standard_output_file). Tcl's
file copy seems to handle gracefully cases where the source file is the
same as the destination, so I don't think it's necessary to check for
that case ourselves, as a previous version of the patch did.
I'd prefer to keep the name gdb_download instead of gdb_remote_download,
since I don't like the fact that gdb_remote_download implies that the
destination is remote, when it's not always the case. However,
gdb_remote_download is used at many more places than gdb_download, so
it's easier to reuse that. Also, since it's a wrapper around DejaGnu's
remote_download, it might be better to keep that name. I don't know.
I ran the testsuite native, with native-gdbserver and with a
remote gdbserver, and didn't see any related failure.
gdb/testsuite/ChangeLog:
* gdb.base/jit-so.exp: Use gdb_remote_download instead of
gdb_download. Use it even if the target is not remote.
* gdb.base/jit.exp (compile_jit_test): Likewise.
* lib/gdb.exp (gdb_remote_download): Copy files to the standard
output directory if the destination board is local, otherwise use
the standard remote_download from DejaGnu.
(gdb_download): Remove.
(gdb_load_shlibs): Use gdb_remote_download instead of
gdb_download.
* lib/gdbserver-support.exp (gdbserver_download_current_prog):
Use gdb_remote_download instead of gdb_download. Use it even if
the target is not remote.
* lib/mi-support.exp (mi_load_shlibs): Use gdb_remote_download
instead of gdb_download.
2016-04-05 19:59:49 +02:00
|
|
|
|
set tofile [standard_output_file $tofile]
|
2007-05-16 16:21:47 +02:00
|
|
|
|
|
Improve gdb_remote_download, remove gdb_download
This patch removes gdb_download in favor of gdb_remote_download, since
they are very close in functionality. Also, in preparation for the
following patch about shared library handling during tests, it improves
gdb_remote_download so that it uses standard_output_file for any
destination board that is local, not only host.
If the destination board is remote, gdb_remote_download will use the
standard remote_download from DejaGnu, resulting in the file being
transferred on the remote system.
If the destination is local, gdb_remote_download will copy the file to
the standard test directory (found using standard_output_file). Tcl's
file copy seems to handle gracefully cases where the source file is the
same as the destination, so I don't think it's necessary to check for
that case ourselves, as a previous version of the patch did.
I'd prefer to keep the name gdb_download instead of gdb_remote_download,
since I don't like the fact that gdb_remote_download implies that the
destination is remote, when it's not always the case. However,
gdb_remote_download is used at many more places than gdb_download, so
it's easier to reuse that. Also, since it's a wrapper around DejaGnu's
remote_download, it might be better to keep that name. I don't know.
I ran the testsuite native, with native-gdbserver and with a
remote gdbserver, and didn't see any related failure.
gdb/testsuite/ChangeLog:
* gdb.base/jit-so.exp: Use gdb_remote_download instead of
gdb_download. Use it even if the target is not remote.
* gdb.base/jit.exp (compile_jit_test): Likewise.
* lib/gdb.exp (gdb_remote_download): Copy files to the standard
output directory if the destination board is local, otherwise use
the standard remote_download from DejaGnu.
(gdb_download): Remove.
(gdb_load_shlibs): Use gdb_remote_download instead of
gdb_download.
* lib/gdbserver-support.exp (gdbserver_download_current_prog):
Use gdb_remote_download instead of gdb_download. Use it even if
the target is not remote.
* lib/mi-support.exp (mi_load_shlibs): Use gdb_remote_download
instead of gdb_download.
2016-04-05 19:59:49 +02:00
|
|
|
|
file copy -force $fromfile $tofile
|
|
|
|
|
|
|
|
|
|
return $tofile
|
|
|
|
|
}
|
2007-05-16 16:21:47 +02:00
|
|
|
|
}
|
|
|
|
|
|
2016-04-28 00:08:59 +02:00
|
|
|
|
# gdb_load_shlib LIB...
|
2007-05-16 16:21:47 +02:00
|
|
|
|
#
|
2016-04-28 00:07:44 +02:00
|
|
|
|
# Copy the listed library to the target.
|
2007-05-16 16:21:47 +02:00
|
|
|
|
|
2016-04-28 00:08:59 +02:00
|
|
|
|
proc gdb_load_shlib { file } {
|
2018-07-11 17:58:47 +02:00
|
|
|
|
global gdb_spawn_id
|
|
|
|
|
|
|
|
|
|
if ![info exists gdb_spawn_id] {
|
|
|
|
|
perror "gdb_load_shlib: GDB is not running"
|
|
|
|
|
}
|
|
|
|
|
|
2016-04-28 00:07:44 +02:00
|
|
|
|
set dest [gdb_remote_download target [shlib_target_file $file]]
|
2007-05-16 16:21:47 +02:00
|
|
|
|
|
Make ftrace tests work with remote targets
When we build a shared library for testing, it is built differently
whether it is meant for the local system or a remote one. When it is
for the local system, the library is built with no SONAME. So when the
executable is built, roughly in this way:
$ gcc testfile.c /path/to/library.so
the executable will contain an absolute reference to the library. For
example:
$ readelf -a testsuite/gdb.python/py-shared | grep NEEDED
0x0000000000000001 (NEEDED) Shared library: [/home/emaisin/build/binutils-gdb/gdb/testsuite/gdb.python/py-shared-sl.sl]
When testing is done remotely, the absolute path obviously doesn't work.
Therefore, we build the library with an SONAME:
$ readelf -a testsuite/gdb.python/py-shared-sl.sl | grep SONAME
0x000000000000000e (SONAME) Library soname: [py-shared-sl.sl]
which ends up in the executable's NEEDED field:
$ readelf -a testsuite/gdb.python/py-shared | grep NEEDED
0x0000000000000001 (NEEDED) Shared library: [py-shared-sl.sl]
The executable and the library are then uploaded side-by-side on the
remote system. To allow the dynamic linker to find the shared library,
we have to add the special RPATH value $ORIGIN, which tells it to search
in the executable's directory:
$ readelf -a testsuite/gdb.python/py-shared | grep ORIGIN
0x000000000000000f (RPATH) Library rpath: [$ORIGIN]
The problem with the IPA library is that it doesn't have an SONAME,
making it very difficult to do testing on a remote board. When a
test executable is linked with it, it contains an absolute reference to
the library path. Therefore, unless the paths on the target are the
same as on the build system, it won't work.
To make it possible for tests using the IPA library to run test on
remote boards, I suggest adding an SONAME to libinproctrace.so. I don't
think it should be a big problem for users. All the libraries installed
on my system have an SONAME, so it should be fine if libinproctrace.so
does too.
As a consequence, native testing does not work anymore, since
executables do not contain the absolute path to the library anymore. To
keep them working, we can have gdb_load_shlibs copy the library to the
test directory when testing natively. That's done by modifying
gdb_load_shlibs. We also have to add RPATH=$ORIGIN to executables, even
when testing natively.
I think it's a good change in general, as it reduces the differences
between testing a native and a remote target. To further reduce those
differences, we can also always build test shared libraries with an
SONAME.
ftrace.exp and ftrace-lock.exp need to be modified slightly. The code
checks that the IPA library is loaded using the absolute path on the
build machine. That obviously doesn't work if the test is done
remotely, as the path will be different. I changed the tests to only
search for the library basename (e.g. libinproctrace.so).
gdb/gdbserver/ChangeLog:
* Makefile.in ($(IPA_LIB)): Set SONAME of the IPA lib.
gdb/testsuite/ChangeLog:
* gdb.trace/ftrace-lock.exp: Check for IPA basename instead of
absolute.
* gdb.trace/ftrace.exp: Likewise.
* lib/gdb.exp (gdb_compile): Set rpath $ORIGIN for non-remote
targets as well.
(gdb_compile_shlib): Set SONAME for non-remote targets as well.
(gdb_load_shlibs): Copy libraries to test directory when testing
natively. Only set solib-search-path if testing remotely.
* lib/mi-support.exp (mi_load_shlibs): Likewise.
2016-04-05 19:59:50 +02:00
|
|
|
|
if {[is_remote target]} {
|
|
|
|
|
# If the target is remote, we need to tell gdb where to find the
|
|
|
|
|
# libraries.
|
|
|
|
|
#
|
|
|
|
|
# We could set this even when not testing remotely, but a user
|
|
|
|
|
# generally won't set it unless necessary. In order to make the tests
|
|
|
|
|
# more like the real-life scenarios, we don't set it for local testing.
|
2016-04-28 00:07:44 +02:00
|
|
|
|
gdb_test "set solib-search-path [file dirname $file]" "" ""
|
Make ftrace tests work with remote targets
When we build a shared library for testing, it is built differently
whether it is meant for the local system or a remote one. When it is
for the local system, the library is built with no SONAME. So when the
executable is built, roughly in this way:
$ gcc testfile.c /path/to/library.so
the executable will contain an absolute reference to the library. For
example:
$ readelf -a testsuite/gdb.python/py-shared | grep NEEDED
0x0000000000000001 (NEEDED) Shared library: [/home/emaisin/build/binutils-gdb/gdb/testsuite/gdb.python/py-shared-sl.sl]
When testing is done remotely, the absolute path obviously doesn't work.
Therefore, we build the library with an SONAME:
$ readelf -a testsuite/gdb.python/py-shared-sl.sl | grep SONAME
0x000000000000000e (SONAME) Library soname: [py-shared-sl.sl]
which ends up in the executable's NEEDED field:
$ readelf -a testsuite/gdb.python/py-shared | grep NEEDED
0x0000000000000001 (NEEDED) Shared library: [py-shared-sl.sl]
The executable and the library are then uploaded side-by-side on the
remote system. To allow the dynamic linker to find the shared library,
we have to add the special RPATH value $ORIGIN, which tells it to search
in the executable's directory:
$ readelf -a testsuite/gdb.python/py-shared | grep ORIGIN
0x000000000000000f (RPATH) Library rpath: [$ORIGIN]
The problem with the IPA library is that it doesn't have an SONAME,
making it very difficult to do testing on a remote board. When a
test executable is linked with it, it contains an absolute reference to
the library path. Therefore, unless the paths on the target are the
same as on the build system, it won't work.
To make it possible for tests using the IPA library to run test on
remote boards, I suggest adding an SONAME to libinproctrace.so. I don't
think it should be a big problem for users. All the libraries installed
on my system have an SONAME, so it should be fine if libinproctrace.so
does too.
As a consequence, native testing does not work anymore, since
executables do not contain the absolute path to the library anymore. To
keep them working, we can have gdb_load_shlibs copy the library to the
test directory when testing natively. That's done by modifying
gdb_load_shlibs. We also have to add RPATH=$ORIGIN to executables, even
when testing natively.
I think it's a good change in general, as it reduces the differences
between testing a native and a remote target. To further reduce those
differences, we can also always build test shared libraries with an
SONAME.
ftrace.exp and ftrace-lock.exp need to be modified slightly. The code
checks that the IPA library is loaded using the absolute path on the
build machine. That obviously doesn't work if the test is done
remotely, as the path will be different. I changed the tests to only
search for the library basename (e.g. libinproctrace.so).
gdb/gdbserver/ChangeLog:
* Makefile.in ($(IPA_LIB)): Set SONAME of the IPA lib.
gdb/testsuite/ChangeLog:
* gdb.trace/ftrace-lock.exp: Check for IPA basename instead of
absolute.
* gdb.trace/ftrace.exp: Likewise.
* lib/gdb.exp (gdb_compile): Set rpath $ORIGIN for non-remote
targets as well.
(gdb_compile_shlib): Set SONAME for non-remote targets as well.
(gdb_load_shlibs): Copy libraries to test directory when testing
natively. Only set solib-search-path if testing remotely.
* lib/mi-support.exp (mi_load_shlibs): Likewise.
2016-04-05 19:59:50 +02:00
|
|
|
|
}
|
2016-04-28 00:07:44 +02:00
|
|
|
|
|
|
|
|
|
return $dest
|
2007-05-16 16:21:47 +02:00
|
|
|
|
}
|
|
|
|
|
|
1999-04-16 03:35:26 +02:00
|
|
|
|
#
|
gdb_load: Fix latent bugs
In a test I was writting, I needed a procedure that would connect to
the target, and do "load", or equivalent.
Years ago, boards would override gdb_load to implement that. Then
gdb_reload was added, and gdb_load was relaxed to allow boards avoid
the spawing and connecting to the target. This sped up gdbserver
testing. See
https://www.sourceware.org/ml/gdb-patches/2007-02/msg00318.html.
To actually spawn the target and load the executable on the target
side, gdb_reload was born:
# gdb_reload -- load a file into the target. Called before "running",
# either the first time or after already starting the program once,
# for remote targets. Most files that override gdb_load should now
# override this instead.
proc gdb_reload { } {
# For the benefit of existing configurations, default to gdb_load.
# Specifying no file defaults to the executable currently being
# debugged.
return [gdb_load ""]
}
Note the comment about specifying no file. Indeed looking at
config/sid.exp, or config/monitor.exp, we see examples of that.
However, the default gdb_load itself doesn't handle the case of no
file specified. When passed no file, it just calls gdb_file_cmd with
no file either, which ends up invocing the "file" command with no
argument, which means unloading the file and its symbols... That
means calling gdb_reload when testing against native targets is
broken. We don't see that today because the only call to gdb_reload
that exists today is guarded by target_info exists
gdb,do_reload_on_run.
The native-extended-gdbserver.exp board is likewise broken here. When
[gdb_load ""] is called, the board sets the remote exec-file to "" ...
Tested on x86_64 Fedora 17, native, remote gdbserver and
extended-remote gdbserver.
testsuite/
2014-05-01 Pedro Alves <palves@redhat.com>
* lib/gdb.exp (gdb_load): Extend comment. Skip calling
gdb_file_cmd if no file is specified.
* boards/native-extended-gdbserver.exp (gdb_load): Use the
last_loaded_file to set the remote exec-file.
2014-05-02 01:59:31 +02:00
|
|
|
|
# gdb_load -- load a file into the debugger. Specifying no file
|
|
|
|
|
# defaults to the executable currently being debugged.
|
2015-02-11 07:07:06 +01:00
|
|
|
|
# The return value is 0 for success, -1 for failure.
|
2004-09-10 03:04:59 +02:00
|
|
|
|
# Many files in config/*.exp override this procedure.
|
1999-04-16 03:35:26 +02:00
|
|
|
|
#
|
|
|
|
|
proc gdb_load { arg } {
|
gdb_load: Fix latent bugs
In a test I was writting, I needed a procedure that would connect to
the target, and do "load", or equivalent.
Years ago, boards would override gdb_load to implement that. Then
gdb_reload was added, and gdb_load was relaxed to allow boards avoid
the spawing and connecting to the target. This sped up gdbserver
testing. See
https://www.sourceware.org/ml/gdb-patches/2007-02/msg00318.html.
To actually spawn the target and load the executable on the target
side, gdb_reload was born:
# gdb_reload -- load a file into the target. Called before "running",
# either the first time or after already starting the program once,
# for remote targets. Most files that override gdb_load should now
# override this instead.
proc gdb_reload { } {
# For the benefit of existing configurations, default to gdb_load.
# Specifying no file defaults to the executable currently being
# debugged.
return [gdb_load ""]
}
Note the comment about specifying no file. Indeed looking at
config/sid.exp, or config/monitor.exp, we see examples of that.
However, the default gdb_load itself doesn't handle the case of no
file specified. When passed no file, it just calls gdb_file_cmd with
no file either, which ends up invocing the "file" command with no
argument, which means unloading the file and its symbols... That
means calling gdb_reload when testing against native targets is
broken. We don't see that today because the only call to gdb_reload
that exists today is guarded by target_info exists
gdb,do_reload_on_run.
The native-extended-gdbserver.exp board is likewise broken here. When
[gdb_load ""] is called, the board sets the remote exec-file to "" ...
Tested on x86_64 Fedora 17, native, remote gdbserver and
extended-remote gdbserver.
testsuite/
2014-05-01 Pedro Alves <palves@redhat.com>
* lib/gdb.exp (gdb_load): Extend comment. Skip calling
gdb_file_cmd if no file is specified.
* boards/native-extended-gdbserver.exp (gdb_load): Use the
last_loaded_file to set the remote exec-file.
2014-05-02 01:59:31 +02:00
|
|
|
|
if { $arg != "" } {
|
|
|
|
|
return [gdb_file_cmd $arg]
|
|
|
|
|
}
|
2015-02-11 07:07:06 +01:00
|
|
|
|
return 0
|
1999-04-16 03:35:26 +02:00
|
|
|
|
}
|
|
|
|
|
|
2007-03-27 19:59:38 +02:00
|
|
|
|
# gdb_reload -- load a file into the target. Called before "running",
|
|
|
|
|
# either the first time or after already starting the program once,
|
|
|
|
|
# for remote targets. Most files that override gdb_load should now
|
|
|
|
|
# override this instead.
|
|
|
|
|
|
|
|
|
|
proc gdb_reload { } {
|
|
|
|
|
# For the benefit of existing configurations, default to gdb_load.
|
|
|
|
|
# Specifying no file defaults to the executable currently being
|
|
|
|
|
# debugged.
|
|
|
|
|
return [gdb_load ""]
|
|
|
|
|
}
|
|
|
|
|
|
1999-04-16 03:35:26 +02:00
|
|
|
|
proc gdb_continue { function } {
|
|
|
|
|
global decimal
|
|
|
|
|
|
gdb/testsuite/
* config/monitor.exp (gdb_target_cmd): Remove semicolon after
'return'.
(gdb_target_monitor, gdb_load): Likewise.
* config/sid.exp (gdb_load): Likewise.
* config/slite.exp (gdb_load): Likewise.
* config/vx.exp (gdb_start, spawn_vxgdb): Likewise.
* gdb.ada/arrayidx.exp, gdb.ada/null_array.exp: Likewise.
* gdb.arch/mips-octeon-bbit.exp (single_step): Likewise.
(single_step_until): Likewise.
* gdb.arch/powerpc-d128-regs.exp: Likewise.
* gdb.arch/system-gcore.exp: Likewise.
* gdb.base/bigcore.exp (extract_heap): Likewise.
* gdb.base/break-on-linker-gcd-function.exp: Likewise.
* gdb.base/call-ar-st.exp: Likewise.
* gdb.base/call-rt-st.exp: Likewise.
* gdb.base/call-sc.exp, gdb.base/call-strs.exp: Likewise.
* gdb.base/callfuncs.exp, gdb.base/completion.exp: Likewise.
* gdb.base/condbreak.exp, gdb.base/constvars.exp: Likewise.
* gdb.base/corefile.exp: Likewise.
* gdb.base/dbx.exp (gdb_file_cmd): Likewise.
* gdb.base/exprs.exp, gdb.base/fileio.exp: Likewise.
* gdb.base/fixsection.exp: Likewise.
* gdb.base/funcargs.exp: Likewise.
* gdb.base/gcore-buffer-overflow.exp: Likewise.
* gdb.base/gcore-relro.exp: Likewise.
* gdb.base/gcore.exp, gdb.base/gdb11530.exp: Likewise.
* gdb.base/gdb11531.exp, gdb.base/gnu-ifunc.exp: Likewise.
* gdb.base/info-os.exp, gdb.base/info-proc.exp: Likewise.
* gdb.base/interp.exp, gdb.base/langs.exp:: Likewise.
* gdb.base/list.exp: Likewise.
(set_listsize): Likewise.
* gdb.base/logical.exp, gdb.base/mips_pro.exp: Likewise.
* gdb.base/miscexprs.exp, gdb.base/nodebug.exp: Likewise.
* gdb.base/opaque.exp, gdb.base/pointers.exp: Likewise.
* gdb.base/psymtab.exp, gdb.base/ptype.exp: Likewise.
* gdb.base/relational.exp, gdb.base/scope.exp: Likewise.
* gdb.base/setvar.exp: Likewise.
(test_set): Likewise.
* gdb.base/signals.exp, gdb.base/sizeof.exp: Likewise.
* gdb.base/solib-overlap.exp: Likewise.
* gdb.base/store.exp, gdb.base/structs.exp: Likewise.
* gdb.base/structs2.exp, gdb.base/volatile.exp: Likewise.
* gdb.base/watchpoint.exp (initialize): Likewise.
(test_simple_watchpoint): Likewise.
(test_disabling_watchpoints): Likewise.
(test_watchpoint_triggered_in_syscall): Likewise.
* gdb.base/whatis.exp, gdb.cp/ambiguous.exp: Likewise.
* gdb.cp/casts.exp, gdb.cp/ctti.exp: Likewise.
* gdb.cp/namespace.exp, gdb.cp/nsdecl.exp: Likewise.
* gdb.cp/psmang.exp, gdb.dwarf2/dw2-ranges.exp: Likewise.
* gdb.hp/gdb.aCC/optimize.exp: Likewise.
* gdb.hp/gdb.aCC/watch-cmd.exp: Likewise.
* gdb.hp/gdb.base-hp/callfwmall.exp: Likewise.
* gdb.hp/gdb.base-hp/pxdb.exp: Likewise.
* gdb.hp/gdb.compat/xdb1.exp: Likewise.
* gdb.hp/gdb.compat/xdb2.exp: Likewise.
* gdb.hp/gdb.compat/xdb3.exp: Likewise.
* gdb.hp/gdb.defects/bs14602.exp: Likewise.
* gdb.hp/gdb.defects/solib-d.exp: Likewise.
* gdb.mi/gdb792.exp: Likewise.
* gdb.mi/mi-inheritance-syntax-error.exp: Likewise.
* gdb.mi/mi-logging.exp, gdb.mi/mi-var-cp.exp : Likewise.
* gdb.mi/mi-var-rtti.exp, gdb.python/py-type.exp: Likewise.
* gdb.threads/gcore-thread.exp: Likewise.
(load_core): Likewise.
* gdb.threads/pthreads.exp (all_threads_running): Likewise.
(test_startup, check_control_c): Likewise.
* gdb.threads/sigstep-threads.exp: Likewise.
* gdb.threads/thread_check.exp: Likewise.
* gdb.trace/backtrace.exp, gdb.trace/change-loc.exp: Likewise.
* gdb.trace/circ.exp (run_trace_experiment): Likewise.
(set_a_tracepoint, trace_buffer_normal): Likewise.
(gdb_trace_circular_tests): Likewise.
* gdb.trace/collection.exp: Likewise.
* gdb.trace/disconnected-tracing.exp: Likewise.
* gdb.trace/infotrace.exp: Likewise.
* gdb.trace/mi-traceframe-changed.exp: Likewise.
* gdb.trace/mi-tracepoint-changed.exp: Likewise.
* gdb.trace/mi-tsv-changed.exp (test_create_delete_modify_tsv): Likewise.
* gdb.trace/packetlen.exp, gdb.trace/passc-dyn.exp: Likewise.
* gdb.trace/pending.exp, gdb.trace/report.exp: Likewise.
* gdb.trace/stap-trace.exp: Likewise.
* gdb.trace/status-stop.exp,gdb.trace/strace.exp: Likewise.
* gdb.trace/tfind.exp, gdb.trace/trace-break.exp: Likewise.
* gdb.trace/trace-buffer-size.exp: Likewise.
* gdb.trace/tspeed.exp, gdb.trace/tsv.exp: Likewise.
* gdb.trace/unavailable.exp: Likewise.
* gdb.trace/while-dyn.exp: Likewise.
* lib/fortran.exp (set_lang_fortran): Likewise.
* lib/gdb.exp (default_gdb_version, gdb_start_cmd): Likewise.
(gdb_breakpoint, gdb_reinitialize_dir): Likewise.
(default_gdb_start, get_compiler_info): Likewise.
(gdb_compile, gdb_compile_objc, gdb_reload, gdb_init): Likewise.
(get_debug_format, setup_xfail_format): Likewise.
(rerun_to_main, gdb_skip_float_test): Likewise.
(build_id_debug_filename_get, get_remotetimeout): Likewise.
* lib/java.exp (set_lang_java): Likewise.
* lib/mi-support.exp (default_mi_gdb_start): Likewise.
(mi_gdb_reinitialize_dir, mi_gdb_target_cmd): Likewise.
(mi_gdb_file_cmd, mi_gdb_test): Likewise.
(mi_run_cmd_full, mi_expect_interrupt): Likewise.
* lib/objc.exp (set_lang_objc): Likewise.
* lib/pascal.exp (set_lang_pascal): Likewise.
* lib/prompt.exp (default_prompt_gdb_start): Likewise.
* lib/trace-support.exp (gdb_trace_setactions, gdb_tfind_test): Likewise.
(gdb_readexpr, gdb_gettpnum, gdb_find_recursion_test_baseline): Likewise.
2013-03-14 14:34:06 +01:00
|
|
|
|
return [gdb_test "continue" ".*Breakpoint $decimal, $function .*" "continue to $function"]
|
1999-04-16 03:35:26 +02:00
|
|
|
|
}
|
|
|
|
|
|
gdb_init argument ARGS is a string rather than a list
The argument ARGS of gdb_init is passed from dejagnu is a string, the
test file name. In dejagnu/runtest.exp:
proc runtest { test_file_name } {
....
....
if [info exists tool] {
if { [info procs "${tool}_init"] != "" } {
${tool}_init $test_file_name;
}
}
....
}
but inn default_gdb_init (callee of gdb_init), we have
set gdb_test_file_name [file rootname [file tail [lindex $args 0]]]
In tcl, all actual arguments are combined to a list and assigned to
args. This code here isn't wrong, but unnecessary, because its caller
(proc runtest) only passes one string to it, and IMO, we don't need
such tricky tcl "args".
I doubt that "[lindex $args 0]" is to be backward compatible with old
dejagnu, but dejagnu-1.4 release started to pass $test_file_name to
${too}_init, as I showed above. dejagnu-1.4 was released in 2001, and
it should be old enough. I also tried to check whether gdb testusite
works with dejagnu-1.3 or not, but failed to build dejagnu-1.3 on my
machine. Supposing GDB testsuite requires at least dejagnu-1.4, this
change should be safe.
This patch is update default_gdb_init to treat ARGS as a string instead
of a list. Then, 'args' sounds like a list, and this patch also renames
it by 'test_file_name', to align with dejagnu.
gdb/testsuite:
2014-05-20 Yao Qi <yao@codesourcery.com>
* lib/gdb.exp (default_gdb_init): Rename argument 'args' by
'test_file_name'. Treat args as a string instead of a list.
(gdb_init): Rename argument 'args' by 'test_file_name'.
2014-05-09 05:01:07 +02:00
|
|
|
|
proc default_gdb_init { test_file_name } {
|
2002-05-23 23:25:42 +02:00
|
|
|
|
global gdb_wrapper_initialized
|
2009-11-13 23:51:59 +01:00
|
|
|
|
global gdb_wrapper_target
|
2012-06-22 18:39:11 +02:00
|
|
|
|
global gdb_test_file_name
|
2007-05-16 16:21:47 +02:00
|
|
|
|
global cleanfiles
|
gdb_init argument ARGS is a string rather than a list
The argument ARGS of gdb_init is passed from dejagnu is a string, the
test file name. In dejagnu/runtest.exp:
proc runtest { test_file_name } {
....
....
if [info exists tool] {
if { [info procs "${tool}_init"] != "" } {
${tool}_init $test_file_name;
}
}
....
}
but inn default_gdb_init (callee of gdb_init), we have
set gdb_test_file_name [file rootname [file tail [lindex $args 0]]]
In tcl, all actual arguments are combined to a list and assigned to
args. This code here isn't wrong, but unnecessary, because its caller
(proc runtest) only passes one string to it, and IMO, we don't need
such tricky tcl "args".
I doubt that "[lindex $args 0]" is to be backward compatible with old
dejagnu, but dejagnu-1.4 release started to pass $test_file_name to
${too}_init, as I showed above. dejagnu-1.4 was released in 2001, and
it should be old enough. I also tried to check whether gdb testusite
works with dejagnu-1.3 or not, but failed to build dejagnu-1.3 on my
machine. Supposing GDB testsuite requires at least dejagnu-1.4, this
change should be safe.
This patch is update default_gdb_init to treat ARGS as a string instead
of a list. Then, 'args' sounds like a list, and this patch also renames
it by 'test_file_name', to align with dejagnu.
gdb/testsuite:
2014-05-20 Yao Qi <yao@codesourcery.com>
* lib/gdb.exp (default_gdb_init): Rename argument 'args' by
'test_file_name'. Treat args as a string instead of a list.
(gdb_init): Rename argument 'args' by 'test_file_name'.
2014-05-09 05:01:07 +02:00
|
|
|
|
global pf_prefix
|
2002-05-23 23:25:42 +02:00
|
|
|
|
|
2007-05-16 16:21:47 +02:00
|
|
|
|
set cleanfiles {}
|
|
|
|
|
|
2013-06-07 19:31:09 +02:00
|
|
|
|
gdb_clear_suppressed
|
1999-04-16 03:35:26 +02:00
|
|
|
|
|
gdb_init argument ARGS is a string rather than a list
The argument ARGS of gdb_init is passed from dejagnu is a string, the
test file name. In dejagnu/runtest.exp:
proc runtest { test_file_name } {
....
....
if [info exists tool] {
if { [info procs "${tool}_init"] != "" } {
${tool}_init $test_file_name;
}
}
....
}
but inn default_gdb_init (callee of gdb_init), we have
set gdb_test_file_name [file rootname [file tail [lindex $args 0]]]
In tcl, all actual arguments are combined to a list and assigned to
args. This code here isn't wrong, but unnecessary, because its caller
(proc runtest) only passes one string to it, and IMO, we don't need
such tricky tcl "args".
I doubt that "[lindex $args 0]" is to be backward compatible with old
dejagnu, but dejagnu-1.4 release started to pass $test_file_name to
${too}_init, as I showed above. dejagnu-1.4 was released in 2001, and
it should be old enough. I also tried to check whether gdb testusite
works with dejagnu-1.3 or not, but failed to build dejagnu-1.3 on my
machine. Supposing GDB testsuite requires at least dejagnu-1.4, this
change should be safe.
This patch is update default_gdb_init to treat ARGS as a string instead
of a list. Then, 'args' sounds like a list, and this patch also renames
it by 'test_file_name', to align with dejagnu.
gdb/testsuite:
2014-05-20 Yao Qi <yao@codesourcery.com>
* lib/gdb.exp (default_gdb_init): Rename argument 'args' by
'test_file_name'. Treat args as a string instead of a list.
(gdb_init): Rename argument 'args' by 'test_file_name'.
2014-05-09 05:01:07 +02:00
|
|
|
|
set gdb_test_file_name [file rootname [file tail $test_file_name]]
|
2012-06-22 18:39:11 +02:00
|
|
|
|
|
2002-05-23 23:25:42 +02:00
|
|
|
|
# Make sure that the wrapper is rebuilt
|
|
|
|
|
# with the appropriate multilib option.
|
2009-11-13 23:51:59 +01:00
|
|
|
|
if { $gdb_wrapper_target != [current_target_name] } {
|
|
|
|
|
set gdb_wrapper_initialized 0
|
|
|
|
|
}
|
2002-05-23 23:25:42 +02:00
|
|
|
|
|
2007-08-23 22:10:04 +02:00
|
|
|
|
# Unlike most tests, we have a small number of tests that generate
|
|
|
|
|
# a very large amount of output. We therefore increase the expect
|
2014-05-21 21:34:57 +02:00
|
|
|
|
# buffer size to be able to contain the entire test output. This
|
|
|
|
|
# is especially needed by gdb.base/info-macros.exp.
|
|
|
|
|
match_max -d 65536
|
2009-10-05 08:27:46 +02:00
|
|
|
|
# Also set this value for the currently running GDB.
|
|
|
|
|
match_max [match_max -d]
|
1999-04-16 03:35:26 +02:00
|
|
|
|
|
|
|
|
|
# We want to add the name of the TCL testcase to the PASS/FAIL messages.
|
gdb_init argument ARGS is a string rather than a list
The argument ARGS of gdb_init is passed from dejagnu is a string, the
test file name. In dejagnu/runtest.exp:
proc runtest { test_file_name } {
....
....
if [info exists tool] {
if { [info procs "${tool}_init"] != "" } {
${tool}_init $test_file_name;
}
}
....
}
but inn default_gdb_init (callee of gdb_init), we have
set gdb_test_file_name [file rootname [file tail [lindex $args 0]]]
In tcl, all actual arguments are combined to a list and assigned to
args. This code here isn't wrong, but unnecessary, because its caller
(proc runtest) only passes one string to it, and IMO, we don't need
such tricky tcl "args".
I doubt that "[lindex $args 0]" is to be backward compatible with old
dejagnu, but dejagnu-1.4 release started to pass $test_file_name to
${too}_init, as I showed above. dejagnu-1.4 was released in 2001, and
it should be old enough. I also tried to check whether gdb testusite
works with dejagnu-1.3 or not, but failed to build dejagnu-1.3 on my
machine. Supposing GDB testsuite requires at least dejagnu-1.4, this
change should be safe.
This patch is update default_gdb_init to treat ARGS as a string instead
of a list. Then, 'args' sounds like a list, and this patch also renames
it by 'test_file_name', to align with dejagnu.
gdb/testsuite:
2014-05-20 Yao Qi <yao@codesourcery.com>
* lib/gdb.exp (default_gdb_init): Rename argument 'args' by
'test_file_name'. Treat args as a string instead of a list.
(gdb_init): Rename argument 'args' by 'test_file_name'.
2014-05-09 05:01:07 +02:00
|
|
|
|
set pf_prefix "[file tail [file dirname $test_file_name]]/[file tail $test_file_name]:"
|
1999-04-16 03:35:26 +02:00
|
|
|
|
|
2013-06-07 19:31:09 +02:00
|
|
|
|
global gdb_prompt
|
1999-04-16 03:35:26 +02:00
|
|
|
|
if [target_info exists gdb_prompt] {
|
2013-06-07 19:31:09 +02:00
|
|
|
|
set gdb_prompt [target_info gdb_prompt]
|
1999-04-16 03:35:26 +02:00
|
|
|
|
} else {
|
|
|
|
|
set gdb_prompt "\\(gdb\\)"
|
|
|
|
|
}
|
2011-12-03 21:20:29 +01:00
|
|
|
|
global use_gdb_stub
|
|
|
|
|
if [info exists use_gdb_stub] {
|
|
|
|
|
unset use_gdb_stub
|
|
|
|
|
}
|
1999-04-16 03:35:26 +02:00
|
|
|
|
}
|
|
|
|
|
|
2015-08-03 18:17:40 +02:00
|
|
|
|
# Return a path using GDB_PARALLEL.
|
|
|
|
|
# ARGS is a list of path elements to append to "$objdir/$GDB_PARALLEL".
|
|
|
|
|
# GDB_PARALLEL must be defined, the caller must check.
|
|
|
|
|
#
|
|
|
|
|
# The default value for GDB_PARALLEL is, canonically, ".".
|
|
|
|
|
# The catch is that tests don't expect an additional "./" in file paths so
|
|
|
|
|
# omit any directory for the default case.
|
|
|
|
|
# GDB_PARALLEL is written as "yes" for the default case in Makefile.in to mark
|
|
|
|
|
# its special handling.
|
|
|
|
|
|
|
|
|
|
proc make_gdb_parallel_path { args } {
|
|
|
|
|
global GDB_PARALLEL objdir
|
|
|
|
|
set joiner [list "file" "join" $objdir]
|
2016-02-08 20:02:36 +01:00
|
|
|
|
if { [info exists GDB_PARALLEL] && $GDB_PARALLEL != "yes" } {
|
2015-08-03 18:17:40 +02:00
|
|
|
|
lappend joiner $GDB_PARALLEL
|
|
|
|
|
}
|
|
|
|
|
set joiner [concat $joiner $args]
|
|
|
|
|
return [eval $joiner]
|
|
|
|
|
}
|
|
|
|
|
|
2012-06-22 18:39:11 +02:00
|
|
|
|
# Turn BASENAME into a full file name in the standard output
|
2012-06-25 21:13:25 +02:00
|
|
|
|
# directory. It is ok if BASENAME is the empty string; in this case
|
|
|
|
|
# the directory is returned.
|
2012-06-22 18:39:11 +02:00
|
|
|
|
|
|
|
|
|
proc standard_output_file {basename} {
|
2016-02-08 20:02:36 +01:00
|
|
|
|
global objdir subdir gdb_test_file_name
|
2012-06-22 18:39:11 +02:00
|
|
|
|
|
2016-02-08 20:02:36 +01:00
|
|
|
|
set dir [make_gdb_parallel_path outputs $subdir $gdb_test_file_name]
|
|
|
|
|
file mkdir $dir
|
2019-08-15 01:13:04 +02:00
|
|
|
|
# If running on MinGW, replace /c/foo with c:/foo
|
|
|
|
|
if { [ishost *-*-mingw*] } {
|
|
|
|
|
set dir [regsub {^/([a-z])/} $dir {\1:/}]
|
|
|
|
|
}
|
2016-02-08 20:02:36 +01:00
|
|
|
|
return [file join $dir $basename]
|
2012-06-22 18:39:11 +02:00
|
|
|
|
}
|
|
|
|
|
|
2019-05-17 17:30:09 +02:00
|
|
|
|
# Turn BASENAME into a full file name in the standard output directory. If
|
|
|
|
|
# GDB has been launched more than once then append the count, starting with
|
|
|
|
|
# a ".1" postfix.
|
|
|
|
|
|
|
|
|
|
proc standard_output_file_with_gdb_instance {basename} {
|
|
|
|
|
global gdb_instances
|
|
|
|
|
set count [expr $gdb_instances - 1 ]
|
|
|
|
|
|
|
|
|
|
if {$count == 0} {
|
|
|
|
|
return [standard_output_file $basename]
|
|
|
|
|
}
|
|
|
|
|
return [standard_output_file ${basename}.${count}]
|
|
|
|
|
}
|
|
|
|
|
|
2013-08-13 17:52:24 +02:00
|
|
|
|
# Return the name of a file in our standard temporary directory.
|
|
|
|
|
|
|
|
|
|
proc standard_temp_file {basename} {
|
2016-02-16 15:00:51 +01:00
|
|
|
|
# Since a particular runtest invocation is only executing a single test
|
|
|
|
|
# file at any given time, we can use the runtest pid to build the
|
|
|
|
|
# path of the temp directory.
|
|
|
|
|
set dir [make_gdb_parallel_path temp [pid]]
|
|
|
|
|
file mkdir $dir
|
|
|
|
|
return [file join $dir $basename]
|
2013-08-13 17:52:24 +02:00
|
|
|
|
}
|
|
|
|
|
|
2012-06-22 18:39:11 +02:00
|
|
|
|
# Set 'testfile', 'srcfile', and 'binfile'.
|
|
|
|
|
#
|
|
|
|
|
# ARGS is a list of source file specifications.
|
|
|
|
|
# Without any arguments, the .exp file's base name is used to
|
|
|
|
|
# compute the source file name. The ".c" extension is added in this case.
|
|
|
|
|
# If ARGS is not empty, each entry is a source file specification.
|
|
|
|
|
# If the specification starts with a ".", it is treated as a suffix
|
|
|
|
|
# to append to the .exp file's base name.
|
|
|
|
|
# If the specification is the empty string, it is treated as if it
|
|
|
|
|
# were ".c".
|
|
|
|
|
# Otherwise it is a file name.
|
|
|
|
|
# The first file in the list is used to set the 'srcfile' global.
|
|
|
|
|
# Each subsequent name is used to set 'srcfile2', 'srcfile3', etc.
|
|
|
|
|
#
|
|
|
|
|
# Most tests should call this without arguments.
|
|
|
|
|
#
|
|
|
|
|
# If a completely different binary file name is needed, then it
|
|
|
|
|
# should be handled in the .exp file with a suitable comment.
|
|
|
|
|
|
|
|
|
|
proc standard_testfile {args} {
|
|
|
|
|
global gdb_test_file_name
|
2012-07-12 18:39:42 +02:00
|
|
|
|
global subdir
|
2012-07-10 16:41:16 +02:00
|
|
|
|
global gdb_test_file_last_vars
|
2012-06-22 18:39:11 +02:00
|
|
|
|
|
|
|
|
|
# Outputs.
|
|
|
|
|
global testfile binfile
|
|
|
|
|
|
|
|
|
|
set testfile $gdb_test_file_name
|
|
|
|
|
set binfile [standard_output_file ${testfile}]
|
|
|
|
|
|
|
|
|
|
if {[llength $args] == 0} {
|
|
|
|
|
set args .c
|
|
|
|
|
}
|
|
|
|
|
|
2012-07-10 16:41:16 +02:00
|
|
|
|
# Unset our previous output variables.
|
|
|
|
|
# This can help catch hidden bugs.
|
|
|
|
|
if {[info exists gdb_test_file_last_vars]} {
|
|
|
|
|
foreach varname $gdb_test_file_last_vars {
|
|
|
|
|
global $varname
|
|
|
|
|
catch {unset $varname}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
# 'executable' is often set by tests.
|
|
|
|
|
set gdb_test_file_last_vars {executable}
|
|
|
|
|
|
2012-06-22 18:39:11 +02:00
|
|
|
|
set suffix ""
|
|
|
|
|
foreach arg $args {
|
|
|
|
|
set varname srcfile$suffix
|
|
|
|
|
global $varname
|
|
|
|
|
|
|
|
|
|
# Handle an extension.
|
|
|
|
|
if {$arg == ""} {
|
|
|
|
|
set arg $testfile.c
|
|
|
|
|
} elseif {[string range $arg 0 0] == "."} {
|
|
|
|
|
set arg $testfile$arg
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
set $varname $arg
|
2012-07-10 16:41:16 +02:00
|
|
|
|
lappend gdb_test_file_last_vars $varname
|
2012-06-22 18:39:11 +02:00
|
|
|
|
|
|
|
|
|
if {$suffix == ""} {
|
|
|
|
|
set suffix 2
|
|
|
|
|
} else {
|
|
|
|
|
incr suffix
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2010-02-08 12:33:54 +01:00
|
|
|
|
# The default timeout used when testing GDB commands. We want to use
|
|
|
|
|
# the same timeout as the default dejagnu timeout, unless the user has
|
|
|
|
|
# already provided a specific value (probably through a site.exp file).
|
|
|
|
|
global gdb_test_timeout
|
|
|
|
|
if ![info exists gdb_test_timeout] {
|
|
|
|
|
set gdb_test_timeout $timeout
|
|
|
|
|
}
|
|
|
|
|
|
2010-05-17 19:11:28 +02:00
|
|
|
|
# A list of global variables that GDB testcases should not use.
|
|
|
|
|
# We try to prevent their use by monitoring write accesses and raising
|
|
|
|
|
# an error when that happens.
|
|
|
|
|
set banned_variables { bug_id prms_id }
|
|
|
|
|
|
2012-01-16 18:31:25 +01:00
|
|
|
|
# A list of procedures that GDB testcases should not use.
|
|
|
|
|
# We try to prevent their use by monitoring invocations and raising
|
|
|
|
|
# an error when that happens.
|
|
|
|
|
set banned_procedures { strace }
|
|
|
|
|
|
2010-06-22 09:21:29 +02:00
|
|
|
|
# gdb_init is called by runtest at start, but also by several
|
|
|
|
|
# tests directly; gdb_finish is only called from within runtest after
|
|
|
|
|
# each test source execution.
|
|
|
|
|
# Placing several traces by repetitive calls to gdb_init leads
|
|
|
|
|
# to problems, as only one trace is removed in gdb_finish.
|
|
|
|
|
# To overcome this possible problem, we add a variable that records
|
2012-01-16 18:31:25 +01:00
|
|
|
|
# if the banned variables and procedures are already traced.
|
|
|
|
|
set banned_traced 0
|
2010-06-22 09:21:29 +02:00
|
|
|
|
|
gdb_init argument ARGS is a string rather than a list
The argument ARGS of gdb_init is passed from dejagnu is a string, the
test file name. In dejagnu/runtest.exp:
proc runtest { test_file_name } {
....
....
if [info exists tool] {
if { [info procs "${tool}_init"] != "" } {
${tool}_init $test_file_name;
}
}
....
}
but inn default_gdb_init (callee of gdb_init), we have
set gdb_test_file_name [file rootname [file tail [lindex $args 0]]]
In tcl, all actual arguments are combined to a list and assigned to
args. This code here isn't wrong, but unnecessary, because its caller
(proc runtest) only passes one string to it, and IMO, we don't need
such tricky tcl "args".
I doubt that "[lindex $args 0]" is to be backward compatible with old
dejagnu, but dejagnu-1.4 release started to pass $test_file_name to
${too}_init, as I showed above. dejagnu-1.4 was released in 2001, and
it should be old enough. I also tried to check whether gdb testusite
works with dejagnu-1.3 or not, but failed to build dejagnu-1.3 on my
machine. Supposing GDB testsuite requires at least dejagnu-1.4, this
change should be safe.
This patch is update default_gdb_init to treat ARGS as a string instead
of a list. Then, 'args' sounds like a list, and this patch also renames
it by 'test_file_name', to align with dejagnu.
gdb/testsuite:
2014-05-20 Yao Qi <yao@codesourcery.com>
* lib/gdb.exp (default_gdb_init): Rename argument 'args' by
'test_file_name'. Treat args as a string instead of a list.
(gdb_init): Rename argument 'args' by 'test_file_name'.
2014-05-09 05:01:07 +02:00
|
|
|
|
proc gdb_init { test_file_name } {
|
2010-02-08 12:33:54 +01:00
|
|
|
|
# Reset the timeout value to the default. This way, any testcase
|
|
|
|
|
# that changes the timeout value without resetting it cannot affect
|
|
|
|
|
# the timeout used in subsequent testcases.
|
|
|
|
|
global gdb_test_timeout
|
|
|
|
|
global timeout
|
|
|
|
|
set timeout $gdb_test_timeout
|
|
|
|
|
|
Set timeout for gdb.reverse/*.exp test cases
Hi,
This patch is to add a new board setting gdb_reverse_timeout, which is
used to set timeout for all gdb.reverse test cases, which are usually
very slow and cause some TIMEOUT failures, for example, on some arm
boards. We have some alternatives to this approach, but I am not
satisfied with them:
- Increase the timeout value. This is the global change, and it may
cause some delay where actual failures happen.
- Set timeout by gdb_reverse_timeout in every gdb.reverse/*.exp.
Then, we have to touch every file under gdb.reverse.
In this patch, we choose a central place to set timeout for all tests
in gdb.reverse, which is convenient.
gdb/testsuite:
2014-05-20 Yao Qi <yao@codesourcery.com>
* lib/gdb.exp (gdb_init): Set timeout if test file is under
gdb.reverse directory and gdb_reverse_timeout exists in board
setting.
* README: Document gdb_reverse_timeout.
2014-05-09 09:06:12 +02:00
|
|
|
|
if { [regexp ".*gdb\.reverse\/.*" $test_file_name]
|
|
|
|
|
&& [target_info exists gdb_reverse_timeout] } {
|
|
|
|
|
set timeout [target_info gdb_reverse_timeout]
|
|
|
|
|
}
|
|
|
|
|
|
introduce parallel mode
This introduces parallel mode for the test suite.
It doesn't fully work yet in the sense that if you do a fully parallel
run, you will encounter some file-name clashes, but this has to start
somewhere, and it seemed best to add some infrastructure now, so that
you can follow along and test subsequent patches if you care to.
This patch has two parts.
First, it checks for the GDB_PARALLEL variable. If this is set (say,
on the runtest command line), then the test suite assumes "parallel
mode". In this mode, files are put into a subdirectory named after
the test. That is, for DIR/TEST.exp, the outputs are put into
./outputs/DIR/TEST/.
This first part has various follow-on changes coming in subsequent
patches. This is why the code in this patch also makes "temp" and
"cache" directories.
Second, this adds an "inotify" mode. If you have the inotifywait
command (part of inotify-tools), you can set the GDB_INOTIFY variable.
This will tell the test suite to watch for changes outside of the
allowed output directories.
This mode is useful for debugging the test suite, as it issues a
report whenever a possibly parallel-unsafe file open is done.
2013-08-13 Tom Tromey <tromey@redhat.com>
Yao Qi <yao@codesourcery.com>
* lib/cache.exp (gdb_do_cache): Handle GDB_PARALLEL.
* lib/gdb.exp: Handle GDB_PARALLEL.
(default_gdb_version): Kill inotify_pid if it exists.
(default_gdb_exit): Emit warning if the inotify log is not
empty.
(standard_output_file): Respect GDB_PARALLEL.
(standard_temp_file): Likewise.
(gdb_init): Start inotifywait if requested.
* gdbint.texinfo (Testsuite): Use @table, not @itemize.
Document GDB_PARALLEL and GDB_INOTIFY.
2013-08-13 18:12:04 +02:00
|
|
|
|
# If GDB_INOTIFY is given, check for writes to '.'. This is a
|
|
|
|
|
# debugging tool to help confirm that the test suite is
|
|
|
|
|
# parallel-safe. You need "inotifywait" from the
|
|
|
|
|
# inotify-tools package to use this.
|
|
|
|
|
global GDB_INOTIFY inotify_pid
|
|
|
|
|
if {[info exists GDB_INOTIFY] && ![info exists inotify_pid]} {
|
|
|
|
|
global outdir tool inotify_log_file
|
|
|
|
|
|
|
|
|
|
set exclusions {outputs temp gdb[.](log|sum) cache}
|
|
|
|
|
set exclusion_re ([join $exclusions |])
|
|
|
|
|
|
|
|
|
|
set inotify_log_file [standard_temp_file inotify.out]
|
|
|
|
|
set inotify_pid [exec inotifywait -r -m -e move,create,delete . \
|
|
|
|
|
--exclude $exclusion_re \
|
|
|
|
|
|& tee -a $outdir/$tool.log $inotify_log_file &]
|
|
|
|
|
|
|
|
|
|
# Wait for the watches; hopefully this is long enough.
|
|
|
|
|
sleep 2
|
|
|
|
|
|
|
|
|
|
# Clear the log so that we don't emit a warning the first time
|
|
|
|
|
# we check it.
|
|
|
|
|
set fd [open $inotify_log_file w]
|
|
|
|
|
close $fd
|
|
|
|
|
}
|
|
|
|
|
|
2012-01-16 18:31:25 +01:00
|
|
|
|
# Block writes to all banned variables, and invocation of all
|
|
|
|
|
# banned procedures...
|
2010-05-17 19:11:28 +02:00
|
|
|
|
global banned_variables
|
2012-01-16 18:31:25 +01:00
|
|
|
|
global banned_procedures
|
|
|
|
|
global banned_traced
|
|
|
|
|
if (!$banned_traced) {
|
2010-06-22 09:21:29 +02:00
|
|
|
|
foreach banned_var $banned_variables {
|
|
|
|
|
global "$banned_var"
|
|
|
|
|
trace add variable "$banned_var" write error
|
|
|
|
|
}
|
2012-01-16 18:31:25 +01:00
|
|
|
|
foreach banned_proc $banned_procedures {
|
|
|
|
|
global "$banned_proc"
|
|
|
|
|
trace add execution "$banned_proc" enter error
|
|
|
|
|
}
|
|
|
|
|
set banned_traced 1
|
2010-05-17 19:11:28 +02:00
|
|
|
|
}
|
|
|
|
|
|
2011-03-25 14:08:11 +01:00
|
|
|
|
# We set LC_ALL, LC_CTYPE, and LANG to C so that we get the same
|
|
|
|
|
# messages as expected.
|
2010-07-29 16:18:57 +02:00
|
|
|
|
setenv LC_ALL C
|
2011-03-25 14:08:11 +01:00
|
|
|
|
setenv LC_CTYPE C
|
2010-07-29 16:18:57 +02:00
|
|
|
|
setenv LANG C
|
|
|
|
|
|
2011-03-25 14:08:11 +01:00
|
|
|
|
# Don't let a .inputrc file or an existing setting of INPUTRC mess up
|
|
|
|
|
# the test results. Even if /dev/null doesn't exist on the particular
|
|
|
|
|
# platform, the readline library will use the default setting just by
|
|
|
|
|
# failing to open the file. OTOH, opening /dev/null successfully will
|
|
|
|
|
# also result in the default settings being used since nothing will be
|
|
|
|
|
# read from this file.
|
|
|
|
|
setenv INPUTRC "/dev/null"
|
|
|
|
|
|
2018-11-13 19:59:03 +01:00
|
|
|
|
# This disables style output, which would interfere with many
|
|
|
|
|
# tests.
|
|
|
|
|
setenv TERM "dumb"
|
2011-03-25 14:08:11 +01:00
|
|
|
|
|
Make gdb.base/corefile.exp work on terminals with few rows
When creating a pty to spawn a subprocess (such as gdb), Expect
copies the settings of its own controlling terminal, including the
number of rows and columns. If you "make check" on a terminal with just
a few rows (e.g. 4), GDB will paginate before reaching the initial
prompt. In default_gdb_start, used by most tests, this is already
handled: if we see the pagination prompt, we sent \n to continue.
Philippe reported that gdb.base/corefile.exp didn't work in terminals
with just a few rows. This test spawns GDB by hand, because it needs to
check things before the initial prompt, which it couldn't do if it used
default_gdb_start.
In this case I think it's not safe to use the same technique as in
default_gdb_start. Even if we could send a \n if we see a pagination
prompt, we match some multiline regexes in there. So if a pagination
slips in there, it might make the regexes not match and fail the test.
It's also not possible to use -ex "set height 0" or -iex "set height 0",
it is handled after the introduction text is shown.
The simplest way I found to avoid showing the pagination completely is
to set stty_init (documented in expect's man page) to initialize gdb's
pty with a fixed number of rows.
And actually, if we set stty_init in gdb_init, it works nicely as a
general solution applicable to all tests. We can therefore remove the
solution introduced in e882ef3cfc3 ("testsuite: expect possible
pagination when starting gdb") where we matched the pagination prompt
during startup.
gdb/testsuite/ChangeLog:
* lib/gdb.exp (default_gdb_start): Don't match pagination
prompt.
(gdb_init): Set stty_init.
2019-02-07 15:22:29 +01:00
|
|
|
|
# Initialize GDB's pty with a fixed size, to make sure we avoid pagination
|
|
|
|
|
# during startup. See "man expect" for details about stty_init.
|
|
|
|
|
global stty_init
|
|
|
|
|
set stty_init "rows 25 cols 80"
|
|
|
|
|
|
2011-03-25 14:08:11 +01:00
|
|
|
|
# Some tests (for example gdb.base/maint.exp) shell out from gdb to use
|
2013-10-18 00:02:29 +02:00
|
|
|
|
# grep. Clear GREP_OPTIONS to make the behavior predictable,
|
2011-03-25 14:08:11 +01:00
|
|
|
|
# especially having color output turned on can cause tests to fail.
|
|
|
|
|
setenv GREP_OPTIONS ""
|
|
|
|
|
|
2011-04-24 10:02:21 +02:00
|
|
|
|
# Clear $gdbserver_reconnect_p.
|
|
|
|
|
global gdbserver_reconnect_p
|
|
|
|
|
set gdbserver_reconnect_p 1
|
|
|
|
|
unset gdbserver_reconnect_p
|
|
|
|
|
|
2019-05-17 17:30:09 +02:00
|
|
|
|
# Reset GDB number of instances
|
|
|
|
|
global gdb_instances
|
|
|
|
|
set gdb_instances 0
|
|
|
|
|
|
gdb_init argument ARGS is a string rather than a list
The argument ARGS of gdb_init is passed from dejagnu is a string, the
test file name. In dejagnu/runtest.exp:
proc runtest { test_file_name } {
....
....
if [info exists tool] {
if { [info procs "${tool}_init"] != "" } {
${tool}_init $test_file_name;
}
}
....
}
but inn default_gdb_init (callee of gdb_init), we have
set gdb_test_file_name [file rootname [file tail [lindex $args 0]]]
In tcl, all actual arguments are combined to a list and assigned to
args. This code here isn't wrong, but unnecessary, because its caller
(proc runtest) only passes one string to it, and IMO, we don't need
such tricky tcl "args".
I doubt that "[lindex $args 0]" is to be backward compatible with old
dejagnu, but dejagnu-1.4 release started to pass $test_file_name to
${too}_init, as I showed above. dejagnu-1.4 was released in 2001, and
it should be old enough. I also tried to check whether gdb testusite
works with dejagnu-1.3 or not, but failed to build dejagnu-1.3 on my
machine. Supposing GDB testsuite requires at least dejagnu-1.4, this
change should be safe.
This patch is update default_gdb_init to treat ARGS as a string instead
of a list. Then, 'args' sounds like a list, and this patch also renames
it by 'test_file_name', to align with dejagnu.
gdb/testsuite:
2014-05-20 Yao Qi <yao@codesourcery.com>
* lib/gdb.exp (default_gdb_init): Rename argument 'args' by
'test_file_name'. Treat args as a string instead of a list.
(gdb_init): Rename argument 'args' by 'test_file_name'.
2014-05-09 05:01:07 +02:00
|
|
|
|
return [default_gdb_init $test_file_name]
|
1999-04-16 03:35:26 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
proc gdb_finish { } {
|
2013-10-25 00:32:30 +02:00
|
|
|
|
global gdbserver_reconnect_p
|
|
|
|
|
global gdb_prompt
|
2007-05-16 16:21:47 +02:00
|
|
|
|
global cleanfiles
|
|
|
|
|
|
|
|
|
|
# Exit first, so that the files are no longer in use.
|
|
|
|
|
gdb_exit
|
|
|
|
|
|
|
|
|
|
if { [llength $cleanfiles] > 0 } {
|
|
|
|
|
eval remote_file target delete $cleanfiles
|
|
|
|
|
set cleanfiles {}
|
|
|
|
|
}
|
2010-05-17 19:11:28 +02:00
|
|
|
|
|
|
|
|
|
# Unblock write access to the banned variables. Dejagnu typically
|
|
|
|
|
# resets some of them between testcases.
|
|
|
|
|
global banned_variables
|
2012-01-16 18:31:25 +01:00
|
|
|
|
global banned_procedures
|
|
|
|
|
global banned_traced
|
|
|
|
|
if ($banned_traced) {
|
2010-06-22 09:21:29 +02:00
|
|
|
|
foreach banned_var $banned_variables {
|
|
|
|
|
global "$banned_var"
|
|
|
|
|
trace remove variable "$banned_var" write error
|
|
|
|
|
}
|
2012-01-16 18:31:25 +01:00
|
|
|
|
foreach banned_proc $banned_procedures {
|
|
|
|
|
global "$banned_proc"
|
|
|
|
|
trace remove execution "$banned_proc" enter error
|
|
|
|
|
}
|
|
|
|
|
set banned_traced 0
|
2010-05-17 19:11:28 +02:00
|
|
|
|
}
|
1999-04-16 03:35:26 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
global debug_format
|
1999-04-26 20:34:20 +02:00
|
|
|
|
set debug_format "unknown"
|
1999-04-16 03:35:26 +02:00
|
|
|
|
|
|
|
|
|
# Run the gdb command "info source" and extract the debugging format
|
|
|
|
|
# information from the output and save it in debug_format.
|
|
|
|
|
|
|
|
|
|
proc get_debug_format { } {
|
|
|
|
|
global gdb_prompt
|
|
|
|
|
global verbose
|
|
|
|
|
global expect_out
|
|
|
|
|
global debug_format
|
|
|
|
|
|
|
|
|
|
set debug_format "unknown"
|
|
|
|
|
send_gdb "info source\n"
|
|
|
|
|
gdb_expect 10 {
|
2002-06-11 22:37:05 +02:00
|
|
|
|
-re "Compiled with (.*) debugging format.\r\n.*$gdb_prompt $" {
|
1999-04-16 03:35:26 +02:00
|
|
|
|
set debug_format $expect_out(1,string)
|
|
|
|
|
verbose "debug format is $debug_format"
|
gdb/testsuite/
* config/monitor.exp (gdb_target_cmd): Remove semicolon after
'return'.
(gdb_target_monitor, gdb_load): Likewise.
* config/sid.exp (gdb_load): Likewise.
* config/slite.exp (gdb_load): Likewise.
* config/vx.exp (gdb_start, spawn_vxgdb): Likewise.
* gdb.ada/arrayidx.exp, gdb.ada/null_array.exp: Likewise.
* gdb.arch/mips-octeon-bbit.exp (single_step): Likewise.
(single_step_until): Likewise.
* gdb.arch/powerpc-d128-regs.exp: Likewise.
* gdb.arch/system-gcore.exp: Likewise.
* gdb.base/bigcore.exp (extract_heap): Likewise.
* gdb.base/break-on-linker-gcd-function.exp: Likewise.
* gdb.base/call-ar-st.exp: Likewise.
* gdb.base/call-rt-st.exp: Likewise.
* gdb.base/call-sc.exp, gdb.base/call-strs.exp: Likewise.
* gdb.base/callfuncs.exp, gdb.base/completion.exp: Likewise.
* gdb.base/condbreak.exp, gdb.base/constvars.exp: Likewise.
* gdb.base/corefile.exp: Likewise.
* gdb.base/dbx.exp (gdb_file_cmd): Likewise.
* gdb.base/exprs.exp, gdb.base/fileio.exp: Likewise.
* gdb.base/fixsection.exp: Likewise.
* gdb.base/funcargs.exp: Likewise.
* gdb.base/gcore-buffer-overflow.exp: Likewise.
* gdb.base/gcore-relro.exp: Likewise.
* gdb.base/gcore.exp, gdb.base/gdb11530.exp: Likewise.
* gdb.base/gdb11531.exp, gdb.base/gnu-ifunc.exp: Likewise.
* gdb.base/info-os.exp, gdb.base/info-proc.exp: Likewise.
* gdb.base/interp.exp, gdb.base/langs.exp:: Likewise.
* gdb.base/list.exp: Likewise.
(set_listsize): Likewise.
* gdb.base/logical.exp, gdb.base/mips_pro.exp: Likewise.
* gdb.base/miscexprs.exp, gdb.base/nodebug.exp: Likewise.
* gdb.base/opaque.exp, gdb.base/pointers.exp: Likewise.
* gdb.base/psymtab.exp, gdb.base/ptype.exp: Likewise.
* gdb.base/relational.exp, gdb.base/scope.exp: Likewise.
* gdb.base/setvar.exp: Likewise.
(test_set): Likewise.
* gdb.base/signals.exp, gdb.base/sizeof.exp: Likewise.
* gdb.base/solib-overlap.exp: Likewise.
* gdb.base/store.exp, gdb.base/structs.exp: Likewise.
* gdb.base/structs2.exp, gdb.base/volatile.exp: Likewise.
* gdb.base/watchpoint.exp (initialize): Likewise.
(test_simple_watchpoint): Likewise.
(test_disabling_watchpoints): Likewise.
(test_watchpoint_triggered_in_syscall): Likewise.
* gdb.base/whatis.exp, gdb.cp/ambiguous.exp: Likewise.
* gdb.cp/casts.exp, gdb.cp/ctti.exp: Likewise.
* gdb.cp/namespace.exp, gdb.cp/nsdecl.exp: Likewise.
* gdb.cp/psmang.exp, gdb.dwarf2/dw2-ranges.exp: Likewise.
* gdb.hp/gdb.aCC/optimize.exp: Likewise.
* gdb.hp/gdb.aCC/watch-cmd.exp: Likewise.
* gdb.hp/gdb.base-hp/callfwmall.exp: Likewise.
* gdb.hp/gdb.base-hp/pxdb.exp: Likewise.
* gdb.hp/gdb.compat/xdb1.exp: Likewise.
* gdb.hp/gdb.compat/xdb2.exp: Likewise.
* gdb.hp/gdb.compat/xdb3.exp: Likewise.
* gdb.hp/gdb.defects/bs14602.exp: Likewise.
* gdb.hp/gdb.defects/solib-d.exp: Likewise.
* gdb.mi/gdb792.exp: Likewise.
* gdb.mi/mi-inheritance-syntax-error.exp: Likewise.
* gdb.mi/mi-logging.exp, gdb.mi/mi-var-cp.exp : Likewise.
* gdb.mi/mi-var-rtti.exp, gdb.python/py-type.exp: Likewise.
* gdb.threads/gcore-thread.exp: Likewise.
(load_core): Likewise.
* gdb.threads/pthreads.exp (all_threads_running): Likewise.
(test_startup, check_control_c): Likewise.
* gdb.threads/sigstep-threads.exp: Likewise.
* gdb.threads/thread_check.exp: Likewise.
* gdb.trace/backtrace.exp, gdb.trace/change-loc.exp: Likewise.
* gdb.trace/circ.exp (run_trace_experiment): Likewise.
(set_a_tracepoint, trace_buffer_normal): Likewise.
(gdb_trace_circular_tests): Likewise.
* gdb.trace/collection.exp: Likewise.
* gdb.trace/disconnected-tracing.exp: Likewise.
* gdb.trace/infotrace.exp: Likewise.
* gdb.trace/mi-traceframe-changed.exp: Likewise.
* gdb.trace/mi-tracepoint-changed.exp: Likewise.
* gdb.trace/mi-tsv-changed.exp (test_create_delete_modify_tsv): Likewise.
* gdb.trace/packetlen.exp, gdb.trace/passc-dyn.exp: Likewise.
* gdb.trace/pending.exp, gdb.trace/report.exp: Likewise.
* gdb.trace/stap-trace.exp: Likewise.
* gdb.trace/status-stop.exp,gdb.trace/strace.exp: Likewise.
* gdb.trace/tfind.exp, gdb.trace/trace-break.exp: Likewise.
* gdb.trace/trace-buffer-size.exp: Likewise.
* gdb.trace/tspeed.exp, gdb.trace/tsv.exp: Likewise.
* gdb.trace/unavailable.exp: Likewise.
* gdb.trace/while-dyn.exp: Likewise.
* lib/fortran.exp (set_lang_fortran): Likewise.
* lib/gdb.exp (default_gdb_version, gdb_start_cmd): Likewise.
(gdb_breakpoint, gdb_reinitialize_dir): Likewise.
(default_gdb_start, get_compiler_info): Likewise.
(gdb_compile, gdb_compile_objc, gdb_reload, gdb_init): Likewise.
(get_debug_format, setup_xfail_format): Likewise.
(rerun_to_main, gdb_skip_float_test): Likewise.
(build_id_debug_filename_get, get_remotetimeout): Likewise.
* lib/java.exp (set_lang_java): Likewise.
* lib/mi-support.exp (default_mi_gdb_start): Likewise.
(mi_gdb_reinitialize_dir, mi_gdb_target_cmd): Likewise.
(mi_gdb_file_cmd, mi_gdb_test): Likewise.
(mi_run_cmd_full, mi_expect_interrupt): Likewise.
* lib/objc.exp (set_lang_objc): Likewise.
* lib/pascal.exp (set_lang_pascal): Likewise.
* lib/prompt.exp (default_prompt_gdb_start): Likewise.
* lib/trace-support.exp (gdb_trace_setactions, gdb_tfind_test): Likewise.
(gdb_readexpr, gdb_gettpnum, gdb_find_recursion_test_baseline): Likewise.
2013-03-14 14:34:06 +01:00
|
|
|
|
return 1
|
1999-04-16 03:35:26 +02:00
|
|
|
|
}
|
|
|
|
|
-re "No current source file.\r\n$gdb_prompt $" {
|
|
|
|
|
perror "get_debug_format used when no current source file"
|
gdb/testsuite/
* config/monitor.exp (gdb_target_cmd): Remove semicolon after
'return'.
(gdb_target_monitor, gdb_load): Likewise.
* config/sid.exp (gdb_load): Likewise.
* config/slite.exp (gdb_load): Likewise.
* config/vx.exp (gdb_start, spawn_vxgdb): Likewise.
* gdb.ada/arrayidx.exp, gdb.ada/null_array.exp: Likewise.
* gdb.arch/mips-octeon-bbit.exp (single_step): Likewise.
(single_step_until): Likewise.
* gdb.arch/powerpc-d128-regs.exp: Likewise.
* gdb.arch/system-gcore.exp: Likewise.
* gdb.base/bigcore.exp (extract_heap): Likewise.
* gdb.base/break-on-linker-gcd-function.exp: Likewise.
* gdb.base/call-ar-st.exp: Likewise.
* gdb.base/call-rt-st.exp: Likewise.
* gdb.base/call-sc.exp, gdb.base/call-strs.exp: Likewise.
* gdb.base/callfuncs.exp, gdb.base/completion.exp: Likewise.
* gdb.base/condbreak.exp, gdb.base/constvars.exp: Likewise.
* gdb.base/corefile.exp: Likewise.
* gdb.base/dbx.exp (gdb_file_cmd): Likewise.
* gdb.base/exprs.exp, gdb.base/fileio.exp: Likewise.
* gdb.base/fixsection.exp: Likewise.
* gdb.base/funcargs.exp: Likewise.
* gdb.base/gcore-buffer-overflow.exp: Likewise.
* gdb.base/gcore-relro.exp: Likewise.
* gdb.base/gcore.exp, gdb.base/gdb11530.exp: Likewise.
* gdb.base/gdb11531.exp, gdb.base/gnu-ifunc.exp: Likewise.
* gdb.base/info-os.exp, gdb.base/info-proc.exp: Likewise.
* gdb.base/interp.exp, gdb.base/langs.exp:: Likewise.
* gdb.base/list.exp: Likewise.
(set_listsize): Likewise.
* gdb.base/logical.exp, gdb.base/mips_pro.exp: Likewise.
* gdb.base/miscexprs.exp, gdb.base/nodebug.exp: Likewise.
* gdb.base/opaque.exp, gdb.base/pointers.exp: Likewise.
* gdb.base/psymtab.exp, gdb.base/ptype.exp: Likewise.
* gdb.base/relational.exp, gdb.base/scope.exp: Likewise.
* gdb.base/setvar.exp: Likewise.
(test_set): Likewise.
* gdb.base/signals.exp, gdb.base/sizeof.exp: Likewise.
* gdb.base/solib-overlap.exp: Likewise.
* gdb.base/store.exp, gdb.base/structs.exp: Likewise.
* gdb.base/structs2.exp, gdb.base/volatile.exp: Likewise.
* gdb.base/watchpoint.exp (initialize): Likewise.
(test_simple_watchpoint): Likewise.
(test_disabling_watchpoints): Likewise.
(test_watchpoint_triggered_in_syscall): Likewise.
* gdb.base/whatis.exp, gdb.cp/ambiguous.exp: Likewise.
* gdb.cp/casts.exp, gdb.cp/ctti.exp: Likewise.
* gdb.cp/namespace.exp, gdb.cp/nsdecl.exp: Likewise.
* gdb.cp/psmang.exp, gdb.dwarf2/dw2-ranges.exp: Likewise.
* gdb.hp/gdb.aCC/optimize.exp: Likewise.
* gdb.hp/gdb.aCC/watch-cmd.exp: Likewise.
* gdb.hp/gdb.base-hp/callfwmall.exp: Likewise.
* gdb.hp/gdb.base-hp/pxdb.exp: Likewise.
* gdb.hp/gdb.compat/xdb1.exp: Likewise.
* gdb.hp/gdb.compat/xdb2.exp: Likewise.
* gdb.hp/gdb.compat/xdb3.exp: Likewise.
* gdb.hp/gdb.defects/bs14602.exp: Likewise.
* gdb.hp/gdb.defects/solib-d.exp: Likewise.
* gdb.mi/gdb792.exp: Likewise.
* gdb.mi/mi-inheritance-syntax-error.exp: Likewise.
* gdb.mi/mi-logging.exp, gdb.mi/mi-var-cp.exp : Likewise.
* gdb.mi/mi-var-rtti.exp, gdb.python/py-type.exp: Likewise.
* gdb.threads/gcore-thread.exp: Likewise.
(load_core): Likewise.
* gdb.threads/pthreads.exp (all_threads_running): Likewise.
(test_startup, check_control_c): Likewise.
* gdb.threads/sigstep-threads.exp: Likewise.
* gdb.threads/thread_check.exp: Likewise.
* gdb.trace/backtrace.exp, gdb.trace/change-loc.exp: Likewise.
* gdb.trace/circ.exp (run_trace_experiment): Likewise.
(set_a_tracepoint, trace_buffer_normal): Likewise.
(gdb_trace_circular_tests): Likewise.
* gdb.trace/collection.exp: Likewise.
* gdb.trace/disconnected-tracing.exp: Likewise.
* gdb.trace/infotrace.exp: Likewise.
* gdb.trace/mi-traceframe-changed.exp: Likewise.
* gdb.trace/mi-tracepoint-changed.exp: Likewise.
* gdb.trace/mi-tsv-changed.exp (test_create_delete_modify_tsv): Likewise.
* gdb.trace/packetlen.exp, gdb.trace/passc-dyn.exp: Likewise.
* gdb.trace/pending.exp, gdb.trace/report.exp: Likewise.
* gdb.trace/stap-trace.exp: Likewise.
* gdb.trace/status-stop.exp,gdb.trace/strace.exp: Likewise.
* gdb.trace/tfind.exp, gdb.trace/trace-break.exp: Likewise.
* gdb.trace/trace-buffer-size.exp: Likewise.
* gdb.trace/tspeed.exp, gdb.trace/tsv.exp: Likewise.
* gdb.trace/unavailable.exp: Likewise.
* gdb.trace/while-dyn.exp: Likewise.
* lib/fortran.exp (set_lang_fortran): Likewise.
* lib/gdb.exp (default_gdb_version, gdb_start_cmd): Likewise.
(gdb_breakpoint, gdb_reinitialize_dir): Likewise.
(default_gdb_start, get_compiler_info): Likewise.
(gdb_compile, gdb_compile_objc, gdb_reload, gdb_init): Likewise.
(get_debug_format, setup_xfail_format): Likewise.
(rerun_to_main, gdb_skip_float_test): Likewise.
(build_id_debug_filename_get, get_remotetimeout): Likewise.
* lib/java.exp (set_lang_java): Likewise.
* lib/mi-support.exp (default_mi_gdb_start): Likewise.
(mi_gdb_reinitialize_dir, mi_gdb_target_cmd): Likewise.
(mi_gdb_file_cmd, mi_gdb_test): Likewise.
(mi_run_cmd_full, mi_expect_interrupt): Likewise.
* lib/objc.exp (set_lang_objc): Likewise.
* lib/pascal.exp (set_lang_pascal): Likewise.
* lib/prompt.exp (default_prompt_gdb_start): Likewise.
* lib/trace-support.exp (gdb_trace_setactions, gdb_tfind_test): Likewise.
(gdb_readexpr, gdb_gettpnum, gdb_find_recursion_test_baseline): Likewise.
2013-03-14 14:34:06 +01:00
|
|
|
|
return 0
|
1999-04-16 03:35:26 +02:00
|
|
|
|
}
|
|
|
|
|
-re "$gdb_prompt $" {
|
|
|
|
|
warning "couldn't check debug format (no valid response)."
|
gdb/testsuite/
* config/monitor.exp (gdb_target_cmd): Remove semicolon after
'return'.
(gdb_target_monitor, gdb_load): Likewise.
* config/sid.exp (gdb_load): Likewise.
* config/slite.exp (gdb_load): Likewise.
* config/vx.exp (gdb_start, spawn_vxgdb): Likewise.
* gdb.ada/arrayidx.exp, gdb.ada/null_array.exp: Likewise.
* gdb.arch/mips-octeon-bbit.exp (single_step): Likewise.
(single_step_until): Likewise.
* gdb.arch/powerpc-d128-regs.exp: Likewise.
* gdb.arch/system-gcore.exp: Likewise.
* gdb.base/bigcore.exp (extract_heap): Likewise.
* gdb.base/break-on-linker-gcd-function.exp: Likewise.
* gdb.base/call-ar-st.exp: Likewise.
* gdb.base/call-rt-st.exp: Likewise.
* gdb.base/call-sc.exp, gdb.base/call-strs.exp: Likewise.
* gdb.base/callfuncs.exp, gdb.base/completion.exp: Likewise.
* gdb.base/condbreak.exp, gdb.base/constvars.exp: Likewise.
* gdb.base/corefile.exp: Likewise.
* gdb.base/dbx.exp (gdb_file_cmd): Likewise.
* gdb.base/exprs.exp, gdb.base/fileio.exp: Likewise.
* gdb.base/fixsection.exp: Likewise.
* gdb.base/funcargs.exp: Likewise.
* gdb.base/gcore-buffer-overflow.exp: Likewise.
* gdb.base/gcore-relro.exp: Likewise.
* gdb.base/gcore.exp, gdb.base/gdb11530.exp: Likewise.
* gdb.base/gdb11531.exp, gdb.base/gnu-ifunc.exp: Likewise.
* gdb.base/info-os.exp, gdb.base/info-proc.exp: Likewise.
* gdb.base/interp.exp, gdb.base/langs.exp:: Likewise.
* gdb.base/list.exp: Likewise.
(set_listsize): Likewise.
* gdb.base/logical.exp, gdb.base/mips_pro.exp: Likewise.
* gdb.base/miscexprs.exp, gdb.base/nodebug.exp: Likewise.
* gdb.base/opaque.exp, gdb.base/pointers.exp: Likewise.
* gdb.base/psymtab.exp, gdb.base/ptype.exp: Likewise.
* gdb.base/relational.exp, gdb.base/scope.exp: Likewise.
* gdb.base/setvar.exp: Likewise.
(test_set): Likewise.
* gdb.base/signals.exp, gdb.base/sizeof.exp: Likewise.
* gdb.base/solib-overlap.exp: Likewise.
* gdb.base/store.exp, gdb.base/structs.exp: Likewise.
* gdb.base/structs2.exp, gdb.base/volatile.exp: Likewise.
* gdb.base/watchpoint.exp (initialize): Likewise.
(test_simple_watchpoint): Likewise.
(test_disabling_watchpoints): Likewise.
(test_watchpoint_triggered_in_syscall): Likewise.
* gdb.base/whatis.exp, gdb.cp/ambiguous.exp: Likewise.
* gdb.cp/casts.exp, gdb.cp/ctti.exp: Likewise.
* gdb.cp/namespace.exp, gdb.cp/nsdecl.exp: Likewise.
* gdb.cp/psmang.exp, gdb.dwarf2/dw2-ranges.exp: Likewise.
* gdb.hp/gdb.aCC/optimize.exp: Likewise.
* gdb.hp/gdb.aCC/watch-cmd.exp: Likewise.
* gdb.hp/gdb.base-hp/callfwmall.exp: Likewise.
* gdb.hp/gdb.base-hp/pxdb.exp: Likewise.
* gdb.hp/gdb.compat/xdb1.exp: Likewise.
* gdb.hp/gdb.compat/xdb2.exp: Likewise.
* gdb.hp/gdb.compat/xdb3.exp: Likewise.
* gdb.hp/gdb.defects/bs14602.exp: Likewise.
* gdb.hp/gdb.defects/solib-d.exp: Likewise.
* gdb.mi/gdb792.exp: Likewise.
* gdb.mi/mi-inheritance-syntax-error.exp: Likewise.
* gdb.mi/mi-logging.exp, gdb.mi/mi-var-cp.exp : Likewise.
* gdb.mi/mi-var-rtti.exp, gdb.python/py-type.exp: Likewise.
* gdb.threads/gcore-thread.exp: Likewise.
(load_core): Likewise.
* gdb.threads/pthreads.exp (all_threads_running): Likewise.
(test_startup, check_control_c): Likewise.
* gdb.threads/sigstep-threads.exp: Likewise.
* gdb.threads/thread_check.exp: Likewise.
* gdb.trace/backtrace.exp, gdb.trace/change-loc.exp: Likewise.
* gdb.trace/circ.exp (run_trace_experiment): Likewise.
(set_a_tracepoint, trace_buffer_normal): Likewise.
(gdb_trace_circular_tests): Likewise.
* gdb.trace/collection.exp: Likewise.
* gdb.trace/disconnected-tracing.exp: Likewise.
* gdb.trace/infotrace.exp: Likewise.
* gdb.trace/mi-traceframe-changed.exp: Likewise.
* gdb.trace/mi-tracepoint-changed.exp: Likewise.
* gdb.trace/mi-tsv-changed.exp (test_create_delete_modify_tsv): Likewise.
* gdb.trace/packetlen.exp, gdb.trace/passc-dyn.exp: Likewise.
* gdb.trace/pending.exp, gdb.trace/report.exp: Likewise.
* gdb.trace/stap-trace.exp: Likewise.
* gdb.trace/status-stop.exp,gdb.trace/strace.exp: Likewise.
* gdb.trace/tfind.exp, gdb.trace/trace-break.exp: Likewise.
* gdb.trace/trace-buffer-size.exp: Likewise.
* gdb.trace/tspeed.exp, gdb.trace/tsv.exp: Likewise.
* gdb.trace/unavailable.exp: Likewise.
* gdb.trace/while-dyn.exp: Likewise.
* lib/fortran.exp (set_lang_fortran): Likewise.
* lib/gdb.exp (default_gdb_version, gdb_start_cmd): Likewise.
(gdb_breakpoint, gdb_reinitialize_dir): Likewise.
(default_gdb_start, get_compiler_info): Likewise.
(gdb_compile, gdb_compile_objc, gdb_reload, gdb_init): Likewise.
(get_debug_format, setup_xfail_format): Likewise.
(rerun_to_main, gdb_skip_float_test): Likewise.
(build_id_debug_filename_get, get_remotetimeout): Likewise.
* lib/java.exp (set_lang_java): Likewise.
* lib/mi-support.exp (default_mi_gdb_start): Likewise.
(mi_gdb_reinitialize_dir, mi_gdb_target_cmd): Likewise.
(mi_gdb_file_cmd, mi_gdb_test): Likewise.
(mi_run_cmd_full, mi_expect_interrupt): Likewise.
* lib/objc.exp (set_lang_objc): Likewise.
* lib/pascal.exp (set_lang_pascal): Likewise.
* lib/prompt.exp (default_prompt_gdb_start): Likewise.
* lib/trace-support.exp (gdb_trace_setactions, gdb_tfind_test): Likewise.
(gdb_readexpr, gdb_gettpnum, gdb_find_recursion_test_baseline): Likewise.
2013-03-14 14:34:06 +01:00
|
|
|
|
return 1
|
1999-04-16 03:35:26 +02:00
|
|
|
|
}
|
|
|
|
|
timeout {
|
2012-10-02 19:17:45 +02:00
|
|
|
|
warning "couldn't check debug format (timeout)."
|
gdb/testsuite/
* config/monitor.exp (gdb_target_cmd): Remove semicolon after
'return'.
(gdb_target_monitor, gdb_load): Likewise.
* config/sid.exp (gdb_load): Likewise.
* config/slite.exp (gdb_load): Likewise.
* config/vx.exp (gdb_start, spawn_vxgdb): Likewise.
* gdb.ada/arrayidx.exp, gdb.ada/null_array.exp: Likewise.
* gdb.arch/mips-octeon-bbit.exp (single_step): Likewise.
(single_step_until): Likewise.
* gdb.arch/powerpc-d128-regs.exp: Likewise.
* gdb.arch/system-gcore.exp: Likewise.
* gdb.base/bigcore.exp (extract_heap): Likewise.
* gdb.base/break-on-linker-gcd-function.exp: Likewise.
* gdb.base/call-ar-st.exp: Likewise.
* gdb.base/call-rt-st.exp: Likewise.
* gdb.base/call-sc.exp, gdb.base/call-strs.exp: Likewise.
* gdb.base/callfuncs.exp, gdb.base/completion.exp: Likewise.
* gdb.base/condbreak.exp, gdb.base/constvars.exp: Likewise.
* gdb.base/corefile.exp: Likewise.
* gdb.base/dbx.exp (gdb_file_cmd): Likewise.
* gdb.base/exprs.exp, gdb.base/fileio.exp: Likewise.
* gdb.base/fixsection.exp: Likewise.
* gdb.base/funcargs.exp: Likewise.
* gdb.base/gcore-buffer-overflow.exp: Likewise.
* gdb.base/gcore-relro.exp: Likewise.
* gdb.base/gcore.exp, gdb.base/gdb11530.exp: Likewise.
* gdb.base/gdb11531.exp, gdb.base/gnu-ifunc.exp: Likewise.
* gdb.base/info-os.exp, gdb.base/info-proc.exp: Likewise.
* gdb.base/interp.exp, gdb.base/langs.exp:: Likewise.
* gdb.base/list.exp: Likewise.
(set_listsize): Likewise.
* gdb.base/logical.exp, gdb.base/mips_pro.exp: Likewise.
* gdb.base/miscexprs.exp, gdb.base/nodebug.exp: Likewise.
* gdb.base/opaque.exp, gdb.base/pointers.exp: Likewise.
* gdb.base/psymtab.exp, gdb.base/ptype.exp: Likewise.
* gdb.base/relational.exp, gdb.base/scope.exp: Likewise.
* gdb.base/setvar.exp: Likewise.
(test_set): Likewise.
* gdb.base/signals.exp, gdb.base/sizeof.exp: Likewise.
* gdb.base/solib-overlap.exp: Likewise.
* gdb.base/store.exp, gdb.base/structs.exp: Likewise.
* gdb.base/structs2.exp, gdb.base/volatile.exp: Likewise.
* gdb.base/watchpoint.exp (initialize): Likewise.
(test_simple_watchpoint): Likewise.
(test_disabling_watchpoints): Likewise.
(test_watchpoint_triggered_in_syscall): Likewise.
* gdb.base/whatis.exp, gdb.cp/ambiguous.exp: Likewise.
* gdb.cp/casts.exp, gdb.cp/ctti.exp: Likewise.
* gdb.cp/namespace.exp, gdb.cp/nsdecl.exp: Likewise.
* gdb.cp/psmang.exp, gdb.dwarf2/dw2-ranges.exp: Likewise.
* gdb.hp/gdb.aCC/optimize.exp: Likewise.
* gdb.hp/gdb.aCC/watch-cmd.exp: Likewise.
* gdb.hp/gdb.base-hp/callfwmall.exp: Likewise.
* gdb.hp/gdb.base-hp/pxdb.exp: Likewise.
* gdb.hp/gdb.compat/xdb1.exp: Likewise.
* gdb.hp/gdb.compat/xdb2.exp: Likewise.
* gdb.hp/gdb.compat/xdb3.exp: Likewise.
* gdb.hp/gdb.defects/bs14602.exp: Likewise.
* gdb.hp/gdb.defects/solib-d.exp: Likewise.
* gdb.mi/gdb792.exp: Likewise.
* gdb.mi/mi-inheritance-syntax-error.exp: Likewise.
* gdb.mi/mi-logging.exp, gdb.mi/mi-var-cp.exp : Likewise.
* gdb.mi/mi-var-rtti.exp, gdb.python/py-type.exp: Likewise.
* gdb.threads/gcore-thread.exp: Likewise.
(load_core): Likewise.
* gdb.threads/pthreads.exp (all_threads_running): Likewise.
(test_startup, check_control_c): Likewise.
* gdb.threads/sigstep-threads.exp: Likewise.
* gdb.threads/thread_check.exp: Likewise.
* gdb.trace/backtrace.exp, gdb.trace/change-loc.exp: Likewise.
* gdb.trace/circ.exp (run_trace_experiment): Likewise.
(set_a_tracepoint, trace_buffer_normal): Likewise.
(gdb_trace_circular_tests): Likewise.
* gdb.trace/collection.exp: Likewise.
* gdb.trace/disconnected-tracing.exp: Likewise.
* gdb.trace/infotrace.exp: Likewise.
* gdb.trace/mi-traceframe-changed.exp: Likewise.
* gdb.trace/mi-tracepoint-changed.exp: Likewise.
* gdb.trace/mi-tsv-changed.exp (test_create_delete_modify_tsv): Likewise.
* gdb.trace/packetlen.exp, gdb.trace/passc-dyn.exp: Likewise.
* gdb.trace/pending.exp, gdb.trace/report.exp: Likewise.
* gdb.trace/stap-trace.exp: Likewise.
* gdb.trace/status-stop.exp,gdb.trace/strace.exp: Likewise.
* gdb.trace/tfind.exp, gdb.trace/trace-break.exp: Likewise.
* gdb.trace/trace-buffer-size.exp: Likewise.
* gdb.trace/tspeed.exp, gdb.trace/tsv.exp: Likewise.
* gdb.trace/unavailable.exp: Likewise.
* gdb.trace/while-dyn.exp: Likewise.
* lib/fortran.exp (set_lang_fortran): Likewise.
* lib/gdb.exp (default_gdb_version, gdb_start_cmd): Likewise.
(gdb_breakpoint, gdb_reinitialize_dir): Likewise.
(default_gdb_start, get_compiler_info): Likewise.
(gdb_compile, gdb_compile_objc, gdb_reload, gdb_init): Likewise.
(get_debug_format, setup_xfail_format): Likewise.
(rerun_to_main, gdb_skip_float_test): Likewise.
(build_id_debug_filename_get, get_remotetimeout): Likewise.
* lib/java.exp (set_lang_java): Likewise.
* lib/mi-support.exp (default_mi_gdb_start): Likewise.
(mi_gdb_reinitialize_dir, mi_gdb_target_cmd): Likewise.
(mi_gdb_file_cmd, mi_gdb_test): Likewise.
(mi_run_cmd_full, mi_expect_interrupt): Likewise.
* lib/objc.exp (set_lang_objc): Likewise.
* lib/pascal.exp (set_lang_pascal): Likewise.
* lib/prompt.exp (default_prompt_gdb_start): Likewise.
* lib/trace-support.exp (gdb_trace_setactions, gdb_tfind_test): Likewise.
(gdb_readexpr, gdb_gettpnum, gdb_find_recursion_test_baseline): Likewise.
2013-03-14 14:34:06 +01:00
|
|
|
|
return 1
|
1999-04-16 03:35:26 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2001-10-02 21:42:10 +02:00
|
|
|
|
# Return true if FORMAT matches the debug format the current test was
|
|
|
|
|
# compiled with. FORMAT is a shell-style globbing pattern; it can use
|
|
|
|
|
# `*', `[...]', and so on.
|
|
|
|
|
#
|
|
|
|
|
# This function depends on variables set by `get_debug_format', above.
|
|
|
|
|
|
|
|
|
|
proc test_debug_format {format} {
|
|
|
|
|
global debug_format
|
|
|
|
|
|
|
|
|
|
return [expr [string match $format $debug_format] != 0]
|
|
|
|
|
}
|
|
|
|
|
|
1999-04-16 03:35:26 +02:00
|
|
|
|
# Like setup_xfail, but takes the name of a debug format (DWARF 1,
|
|
|
|
|
# COFF, stabs, etc). If that format matches the format that the
|
|
|
|
|
# current test was compiled with, then the next test is expected to
|
|
|
|
|
# fail for any target. Returns 1 if the next test or set of tests is
|
|
|
|
|
# expected to fail, 0 otherwise (or if it is unknown). Must have
|
|
|
|
|
# previously called get_debug_format.
|
2001-09-27 23:35:56 +02:00
|
|
|
|
proc setup_xfail_format { format } {
|
2013-06-07 19:31:09 +02:00
|
|
|
|
set ret [test_debug_format $format]
|
2001-09-27 23:35:56 +02:00
|
|
|
|
|
2001-10-02 21:42:10 +02:00
|
|
|
|
if {$ret} then {
|
2001-09-27 23:35:56 +02:00
|
|
|
|
setup_xfail "*-*-*"
|
|
|
|
|
}
|
gdb/testsuite/
* config/monitor.exp (gdb_target_cmd): Remove semicolon after
'return'.
(gdb_target_monitor, gdb_load): Likewise.
* config/sid.exp (gdb_load): Likewise.
* config/slite.exp (gdb_load): Likewise.
* config/vx.exp (gdb_start, spawn_vxgdb): Likewise.
* gdb.ada/arrayidx.exp, gdb.ada/null_array.exp: Likewise.
* gdb.arch/mips-octeon-bbit.exp (single_step): Likewise.
(single_step_until): Likewise.
* gdb.arch/powerpc-d128-regs.exp: Likewise.
* gdb.arch/system-gcore.exp: Likewise.
* gdb.base/bigcore.exp (extract_heap): Likewise.
* gdb.base/break-on-linker-gcd-function.exp: Likewise.
* gdb.base/call-ar-st.exp: Likewise.
* gdb.base/call-rt-st.exp: Likewise.
* gdb.base/call-sc.exp, gdb.base/call-strs.exp: Likewise.
* gdb.base/callfuncs.exp, gdb.base/completion.exp: Likewise.
* gdb.base/condbreak.exp, gdb.base/constvars.exp: Likewise.
* gdb.base/corefile.exp: Likewise.
* gdb.base/dbx.exp (gdb_file_cmd): Likewise.
* gdb.base/exprs.exp, gdb.base/fileio.exp: Likewise.
* gdb.base/fixsection.exp: Likewise.
* gdb.base/funcargs.exp: Likewise.
* gdb.base/gcore-buffer-overflow.exp: Likewise.
* gdb.base/gcore-relro.exp: Likewise.
* gdb.base/gcore.exp, gdb.base/gdb11530.exp: Likewise.
* gdb.base/gdb11531.exp, gdb.base/gnu-ifunc.exp: Likewise.
* gdb.base/info-os.exp, gdb.base/info-proc.exp: Likewise.
* gdb.base/interp.exp, gdb.base/langs.exp:: Likewise.
* gdb.base/list.exp: Likewise.
(set_listsize): Likewise.
* gdb.base/logical.exp, gdb.base/mips_pro.exp: Likewise.
* gdb.base/miscexprs.exp, gdb.base/nodebug.exp: Likewise.
* gdb.base/opaque.exp, gdb.base/pointers.exp: Likewise.
* gdb.base/psymtab.exp, gdb.base/ptype.exp: Likewise.
* gdb.base/relational.exp, gdb.base/scope.exp: Likewise.
* gdb.base/setvar.exp: Likewise.
(test_set): Likewise.
* gdb.base/signals.exp, gdb.base/sizeof.exp: Likewise.
* gdb.base/solib-overlap.exp: Likewise.
* gdb.base/store.exp, gdb.base/structs.exp: Likewise.
* gdb.base/structs2.exp, gdb.base/volatile.exp: Likewise.
* gdb.base/watchpoint.exp (initialize): Likewise.
(test_simple_watchpoint): Likewise.
(test_disabling_watchpoints): Likewise.
(test_watchpoint_triggered_in_syscall): Likewise.
* gdb.base/whatis.exp, gdb.cp/ambiguous.exp: Likewise.
* gdb.cp/casts.exp, gdb.cp/ctti.exp: Likewise.
* gdb.cp/namespace.exp, gdb.cp/nsdecl.exp: Likewise.
* gdb.cp/psmang.exp, gdb.dwarf2/dw2-ranges.exp: Likewise.
* gdb.hp/gdb.aCC/optimize.exp: Likewise.
* gdb.hp/gdb.aCC/watch-cmd.exp: Likewise.
* gdb.hp/gdb.base-hp/callfwmall.exp: Likewise.
* gdb.hp/gdb.base-hp/pxdb.exp: Likewise.
* gdb.hp/gdb.compat/xdb1.exp: Likewise.
* gdb.hp/gdb.compat/xdb2.exp: Likewise.
* gdb.hp/gdb.compat/xdb3.exp: Likewise.
* gdb.hp/gdb.defects/bs14602.exp: Likewise.
* gdb.hp/gdb.defects/solib-d.exp: Likewise.
* gdb.mi/gdb792.exp: Likewise.
* gdb.mi/mi-inheritance-syntax-error.exp: Likewise.
* gdb.mi/mi-logging.exp, gdb.mi/mi-var-cp.exp : Likewise.
* gdb.mi/mi-var-rtti.exp, gdb.python/py-type.exp: Likewise.
* gdb.threads/gcore-thread.exp: Likewise.
(load_core): Likewise.
* gdb.threads/pthreads.exp (all_threads_running): Likewise.
(test_startup, check_control_c): Likewise.
* gdb.threads/sigstep-threads.exp: Likewise.
* gdb.threads/thread_check.exp: Likewise.
* gdb.trace/backtrace.exp, gdb.trace/change-loc.exp: Likewise.
* gdb.trace/circ.exp (run_trace_experiment): Likewise.
(set_a_tracepoint, trace_buffer_normal): Likewise.
(gdb_trace_circular_tests): Likewise.
* gdb.trace/collection.exp: Likewise.
* gdb.trace/disconnected-tracing.exp: Likewise.
* gdb.trace/infotrace.exp: Likewise.
* gdb.trace/mi-traceframe-changed.exp: Likewise.
* gdb.trace/mi-tracepoint-changed.exp: Likewise.
* gdb.trace/mi-tsv-changed.exp (test_create_delete_modify_tsv): Likewise.
* gdb.trace/packetlen.exp, gdb.trace/passc-dyn.exp: Likewise.
* gdb.trace/pending.exp, gdb.trace/report.exp: Likewise.
* gdb.trace/stap-trace.exp: Likewise.
* gdb.trace/status-stop.exp,gdb.trace/strace.exp: Likewise.
* gdb.trace/tfind.exp, gdb.trace/trace-break.exp: Likewise.
* gdb.trace/trace-buffer-size.exp: Likewise.
* gdb.trace/tspeed.exp, gdb.trace/tsv.exp: Likewise.
* gdb.trace/unavailable.exp: Likewise.
* gdb.trace/while-dyn.exp: Likewise.
* lib/fortran.exp (set_lang_fortran): Likewise.
* lib/gdb.exp (default_gdb_version, gdb_start_cmd): Likewise.
(gdb_breakpoint, gdb_reinitialize_dir): Likewise.
(default_gdb_start, get_compiler_info): Likewise.
(gdb_compile, gdb_compile_objc, gdb_reload, gdb_init): Likewise.
(get_debug_format, setup_xfail_format): Likewise.
(rerun_to_main, gdb_skip_float_test): Likewise.
(build_id_debug_filename_get, get_remotetimeout): Likewise.
* lib/java.exp (set_lang_java): Likewise.
* lib/mi-support.exp (default_mi_gdb_start): Likewise.
(mi_gdb_reinitialize_dir, mi_gdb_target_cmd): Likewise.
(mi_gdb_file_cmd, mi_gdb_test): Likewise.
(mi_run_cmd_full, mi_expect_interrupt): Likewise.
* lib/objc.exp (set_lang_objc): Likewise.
* lib/pascal.exp (set_lang_pascal): Likewise.
* lib/prompt.exp (default_prompt_gdb_start): Likewise.
* lib/trace-support.exp (gdb_trace_setactions, gdb_tfind_test): Likewise.
(gdb_readexpr, gdb_gettpnum, gdb_find_recursion_test_baseline): Likewise.
2013-03-14 14:34:06 +01:00
|
|
|
|
return $ret
|
2001-09-27 23:35:56 +02:00
|
|
|
|
}
|
1999-04-16 03:35:26 +02:00
|
|
|
|
|
2004-08-08 18:16:42 +02:00
|
|
|
|
# gdb_get_line_number TEXT [FILE]
|
|
|
|
|
#
|
|
|
|
|
# Search the source file FILE, and return the line number of the
|
2012-03-09 05:38:53 +01:00
|
|
|
|
# first line containing TEXT. If no match is found, an error is thrown.
|
2004-08-08 18:16:42 +02:00
|
|
|
|
#
|
|
|
|
|
# TEXT is a string literal, not a regular expression.
|
|
|
|
|
#
|
|
|
|
|
# The default value of FILE is "$srcdir/$subdir/$srcfile". If FILE is
|
|
|
|
|
# specified, and does not start with "/", then it is assumed to be in
|
|
|
|
|
# "$srcdir/$subdir". This is awkward, and can be fixed in the future,
|
|
|
|
|
# by changing the callers and the interface at the same time.
|
|
|
|
|
# In particular: gdb.base/break.exp, gdb.base/condbreak.exp,
|
|
|
|
|
# gdb.base/ena-dis-br.exp.
|
|
|
|
|
#
|
|
|
|
|
# Use this function to keep your test scripts independent of the
|
|
|
|
|
# exact line numbering of the source file. Don't write:
|
|
|
|
|
#
|
|
|
|
|
# send_gdb "break 20"
|
|
|
|
|
#
|
|
|
|
|
# This means that if anyone ever edits your test's source file,
|
|
|
|
|
# your test could break. Instead, put a comment like this on the
|
|
|
|
|
# source file line you want to break at:
|
|
|
|
|
#
|
|
|
|
|
# /* breakpoint spot: frotz.exp: test name */
|
|
|
|
|
#
|
|
|
|
|
# and then write, in your test script (which we assume is named
|
|
|
|
|
# frotz.exp):
|
|
|
|
|
#
|
|
|
|
|
# send_gdb "break [gdb_get_line_number "frotz.exp: test name"]\n"
|
|
|
|
|
#
|
|
|
|
|
# (Yes, Tcl knows how to handle the nested quotes and brackets.
|
|
|
|
|
# Try this:
|
|
|
|
|
# $ tclsh
|
|
|
|
|
# % puts "foo [lindex "bar baz" 1]"
|
|
|
|
|
# foo baz
|
|
|
|
|
# %
|
|
|
|
|
# Tcl is quite clever, for a little stringy language.)
|
|
|
|
|
#
|
|
|
|
|
# ===
|
|
|
|
|
#
|
|
|
|
|
# The previous implementation of this procedure used the gdb search command.
|
|
|
|
|
# This version is different:
|
|
|
|
|
#
|
|
|
|
|
# . It works with MI, and it also works when gdb is not running.
|
|
|
|
|
#
|
|
|
|
|
# . It operates on the build machine, not the host machine.
|
|
|
|
|
#
|
|
|
|
|
# . For now, this implementation fakes a current directory of
|
|
|
|
|
# $srcdir/$subdir to be compatible with the old implementation.
|
|
|
|
|
# This will go away eventually and some callers will need to
|
|
|
|
|
# be changed.
|
|
|
|
|
#
|
|
|
|
|
# . The TEXT argument is literal text and matches literally,
|
|
|
|
|
# not a regular expression as it was before.
|
|
|
|
|
#
|
|
|
|
|
# . State changes in gdb, such as changing the current file
|
|
|
|
|
# and setting $_, no longer happen.
|
|
|
|
|
#
|
|
|
|
|
# After a bit of time we can forget about the differences from the
|
|
|
|
|
# old implementation.
|
|
|
|
|
#
|
|
|
|
|
# --chastain 2004-08-05
|
|
|
|
|
|
|
|
|
|
proc gdb_get_line_number { text { file "" } } {
|
|
|
|
|
global srcdir
|
|
|
|
|
global subdir
|
|
|
|
|
global srcfile
|
1999-04-16 03:35:26 +02:00
|
|
|
|
|
2004-08-08 18:16:42 +02:00
|
|
|
|
if { "$file" == "" } then {
|
|
|
|
|
set file "$srcfile"
|
|
|
|
|
}
|
|
|
|
|
if { ! [regexp "^/" "$file"] } then {
|
|
|
|
|
set file "$srcdir/$subdir/$file"
|
1999-04-16 03:35:26 +02:00
|
|
|
|
}
|
|
|
|
|
|
2004-08-08 18:16:42 +02:00
|
|
|
|
if { [ catch { set fd [open "$file"] } message ] } then {
|
2012-03-09 05:38:53 +01:00
|
|
|
|
error "$message"
|
1999-04-16 03:35:26 +02:00
|
|
|
|
}
|
2004-08-08 18:16:42 +02:00
|
|
|
|
|
|
|
|
|
set found -1
|
|
|
|
|
for { set line 1 } { 1 } { incr line } {
|
|
|
|
|
if { [ catch { set nchar [gets "$fd" body] } message ] } then {
|
2012-03-09 05:38:53 +01:00
|
|
|
|
error "$message"
|
2004-08-08 18:16:42 +02:00
|
|
|
|
}
|
|
|
|
|
if { $nchar < 0 } then {
|
|
|
|
|
break
|
|
|
|
|
}
|
|
|
|
|
if { [string first "$text" "$body"] >= 0 } then {
|
|
|
|
|
set found $line
|
|
|
|
|
break
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if { [ catch { close "$fd" } message ] } then {
|
2012-03-09 05:38:53 +01:00
|
|
|
|
error "$message"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if {$found == -1} {
|
|
|
|
|
error "undefined tag \"$text\""
|
2004-08-08 18:16:42 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return $found
|
1999-04-16 03:35:26 +02:00
|
|
|
|
}
|
|
|
|
|
|
Teach the testsuite that GDBserver reliably reports program exits.
Running catch-syscall.exp against a gdbserver that actually supports
it, we get:
FAIL: gdb.base/catch-syscall.exp: continue until exit (the program exited)
FAIL: gdb.base/catch-syscall.exp: continue until exit (the program exited)
FAIL: gdb.base/catch-syscall.exp: continue until exit (the program exited)
FAIL: gdb.base/catch-syscall.exp: continue until exit at catch syscall with unused syscall (mlock) (the program exited)
FAIL: gdb.base/catch-syscall.exp: continue until exit (the program exited)
The fail pattern is:
Catchpoint 2 (call to syscall exit_group), 0x000000323d4baa29 in _exit () from /lib64/libc.so.6
(gdb) PASS: gdb.base/catch-syscall.exp: program has called exit_group
delete breakpoints
Delete all breakpoints? (y or n) y
(gdb) info breakpoints
No breakpoints or watchpoints.
(gdb) break exit
Breakpoint 3 at 0x323d438bf0
(gdb) continue
Continuing.
[Inferior 1 (process 21081) exited normally]
That "break exit" + "continue" comes from:
> # gdb_continue_to_end:
> # The case where the target uses stubs has to be handled specially. If a
> # stub is used, we set a breakpoint at exit because we cannot rely on
> # exit() behavior of a remote target.
> #
The native-gdbserver.exp board, used to test against gdbserver in
"target remote" mode, triggers that case ($use_gdb_stub is true). So
gdb_continue_to_end doesn't work for catch-syscall.exp as here we
catch the exit_group and continue from that, expecting to see a real
program exit. I was about to post a patch that changes
catch-syscall.exp to call a new function that just always does what
gdb_continue_to_end does in the !$use_gdb_stub case. But, since
GDBserver doesn't really need this, in the end I thought it better to
teach the testsuite that there are stubs that know how to report
program exits, by adding a new "exit_is_reliable" board variable that
then gdb_continue_to_end checks.
Tested on x86_64 Fedora 17, native and gdbserver.
gdb/testsuite/
2013-10-02 Pedro Alves <palves@redhat.com>
* README (Board Settings): Document "exit_is_reliable".
* lib/gdb.exp (gdb_continue_to_end): Check whether the board says
running to exit reliably reports program exits.
* boards/native-gdbserver.exp: Set exit_is_reliable in the board
info.
* boards/native-stdio-gdbserver.exp: Likewise.
2013-10-02 13:44:20 +02:00
|
|
|
|
# Continue the program until it ends.
|
|
|
|
|
#
|
2011-03-07 17:03:04 +01:00
|
|
|
|
# MSSG is the error message that gets printed. If not given, a
|
|
|
|
|
# default is used.
|
|
|
|
|
# COMMAND is the command to invoke. If not given, "continue" is
|
|
|
|
|
# used.
|
2011-03-09 15:17:05 +01:00
|
|
|
|
# ALLOW_EXTRA is a flag indicating whether the test should expect
|
|
|
|
|
# extra output between the "Continuing." line and the program
|
|
|
|
|
# exiting. By default it is zero; if nonzero, any extra output
|
|
|
|
|
# is accepted.
|
2011-03-07 17:03:04 +01:00
|
|
|
|
|
2011-03-09 15:17:05 +01:00
|
|
|
|
proc gdb_continue_to_end {{mssg ""} {command continue} {allow_extra 0}} {
|
2011-12-03 21:20:29 +01:00
|
|
|
|
global inferior_exited_re use_gdb_stub
|
1999-04-26 20:34:20 +02:00
|
|
|
|
|
2011-03-07 17:03:04 +01:00
|
|
|
|
if {$mssg == ""} {
|
|
|
|
|
set text "continue until exit"
|
|
|
|
|
} else {
|
|
|
|
|
set text "continue until exit at $mssg"
|
|
|
|
|
}
|
2011-03-09 15:17:05 +01:00
|
|
|
|
if {$allow_extra} {
|
|
|
|
|
set extra ".*"
|
|
|
|
|
} else {
|
|
|
|
|
set extra ""
|
|
|
|
|
}
|
Teach the testsuite that GDBserver reliably reports program exits.
Running catch-syscall.exp against a gdbserver that actually supports
it, we get:
FAIL: gdb.base/catch-syscall.exp: continue until exit (the program exited)
FAIL: gdb.base/catch-syscall.exp: continue until exit (the program exited)
FAIL: gdb.base/catch-syscall.exp: continue until exit (the program exited)
FAIL: gdb.base/catch-syscall.exp: continue until exit at catch syscall with unused syscall (mlock) (the program exited)
FAIL: gdb.base/catch-syscall.exp: continue until exit (the program exited)
The fail pattern is:
Catchpoint 2 (call to syscall exit_group), 0x000000323d4baa29 in _exit () from /lib64/libc.so.6
(gdb) PASS: gdb.base/catch-syscall.exp: program has called exit_group
delete breakpoints
Delete all breakpoints? (y or n) y
(gdb) info breakpoints
No breakpoints or watchpoints.
(gdb) break exit
Breakpoint 3 at 0x323d438bf0
(gdb) continue
Continuing.
[Inferior 1 (process 21081) exited normally]
That "break exit" + "continue" comes from:
> # gdb_continue_to_end:
> # The case where the target uses stubs has to be handled specially. If a
> # stub is used, we set a breakpoint at exit because we cannot rely on
> # exit() behavior of a remote target.
> #
The native-gdbserver.exp board, used to test against gdbserver in
"target remote" mode, triggers that case ($use_gdb_stub is true). So
gdb_continue_to_end doesn't work for catch-syscall.exp as here we
catch the exit_group and continue from that, expecting to see a real
program exit. I was about to post a patch that changes
catch-syscall.exp to call a new function that just always does what
gdb_continue_to_end does in the !$use_gdb_stub case. But, since
GDBserver doesn't really need this, in the end I thought it better to
teach the testsuite that there are stubs that know how to report
program exits, by adding a new "exit_is_reliable" board variable that
then gdb_continue_to_end checks.
Tested on x86_64 Fedora 17, native and gdbserver.
gdb/testsuite/
2013-10-02 Pedro Alves <palves@redhat.com>
* README (Board Settings): Document "exit_is_reliable".
* lib/gdb.exp (gdb_continue_to_end): Check whether the board says
running to exit reliably reports program exits.
* boards/native-gdbserver.exp: Set exit_is_reliable in the board
info.
* boards/native-stdio-gdbserver.exp: Likewise.
2013-10-02 13:44:20 +02:00
|
|
|
|
|
|
|
|
|
# By default, we don't rely on exit() behavior of remote stubs --
|
|
|
|
|
# it's common for exit() to be implemented as a simple infinite
|
|
|
|
|
# loop, or a forced crash/reset. For native targets, by default, we
|
|
|
|
|
# assume process exit is reported as such. If a non-reliable target
|
|
|
|
|
# is used, we set a breakpoint at exit, and continue to that.
|
|
|
|
|
if { [target_info exists exit_is_reliable] } {
|
|
|
|
|
set exit_is_reliable [target_info exit_is_reliable]
|
|
|
|
|
} else {
|
|
|
|
|
set exit_is_reliable [expr ! $use_gdb_stub]
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if { ! $exit_is_reliable } {
|
1999-04-26 20:34:20 +02:00
|
|
|
|
if {![gdb_breakpoint "exit"]} {
|
|
|
|
|
return 0
|
|
|
|
|
}
|
2011-03-09 15:17:05 +01:00
|
|
|
|
gdb_test $command "Continuing..*Breakpoint .*exit.*" \
|
2011-03-07 17:03:04 +01:00
|
|
|
|
$text
|
1999-04-26 20:34:20 +02:00
|
|
|
|
} else {
|
|
|
|
|
# Continue until we exit. Should not stop again.
|
|
|
|
|
# Don't bother to check the output of the program, that may be
|
|
|
|
|
# extremely tough for some remote systems.
|
2011-03-09 15:17:05 +01:00
|
|
|
|
gdb_test $command \
|
|
|
|
|
"Continuing.\[\r\n0-9\]+${extra}(... EXIT code 0\[\r\n\]+|$inferior_exited_re normally).*"\
|
2011-03-07 17:03:04 +01:00
|
|
|
|
$text
|
1999-04-26 20:34:20 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
proc rerun_to_main {} {
|
2011-12-03 21:20:29 +01:00
|
|
|
|
global gdb_prompt use_gdb_stub
|
1999-04-26 20:34:20 +02:00
|
|
|
|
|
2011-12-03 21:20:29 +01:00
|
|
|
|
if $use_gdb_stub {
|
1999-04-26 20:34:20 +02:00
|
|
|
|
gdb_run_cmd
|
|
|
|
|
gdb_expect {
|
|
|
|
|
-re ".*Breakpoint .*main .*$gdb_prompt $"\
|
|
|
|
|
{pass "rerun to main" ; return 0}
|
|
|
|
|
-re "$gdb_prompt $"\
|
|
|
|
|
{fail "rerun to main" ; return 0}
|
|
|
|
|
timeout {fail "(timeout) rerun to main" ; return 0}
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
send_gdb "run\n"
|
|
|
|
|
gdb_expect {
|
2002-09-18 17:34:10 +02:00
|
|
|
|
-re "The program .* has been started already.*y or n. $" {
|
2019-05-17 17:30:09 +02:00
|
|
|
|
send_gdb "y\n" answer
|
2002-09-18 17:34:10 +02:00
|
|
|
|
exp_continue
|
|
|
|
|
}
|
1999-04-26 20:34:20 +02:00
|
|
|
|
-re "Starting program.*$gdb_prompt $"\
|
|
|
|
|
{pass "rerun to main" ; return 0}
|
|
|
|
|
-re "$gdb_prompt $"\
|
|
|
|
|
{fail "rerun to main" ; return 0}
|
|
|
|
|
timeout {fail "(timeout) rerun to main" ; return 0}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
1999-04-16 03:35:26 +02:00
|
|
|
|
|
2019-05-06 08:42:24 +02:00
|
|
|
|
# Return true if EXECUTABLE contains a .gdb_index or .debug_names index section.
|
|
|
|
|
|
|
|
|
|
proc exec_has_index_section { executable } {
|
|
|
|
|
set readelf_program [gdb_find_readelf]
|
|
|
|
|
set res [catch {exec $readelf_program -S $executable \
|
|
|
|
|
| grep -E "\.gdb_index|\.debug_names" }]
|
|
|
|
|
if { $res == 0 } {
|
|
|
|
|
return 1
|
|
|
|
|
}
|
|
|
|
|
return 0
|
|
|
|
|
}
|
|
|
|
|
|
2019-08-05 12:51:58 +02:00
|
|
|
|
# Return list with major and minor version of readelf, or an empty list.
|
|
|
|
|
gdb_caching_proc readelf_version {
|
|
|
|
|
set readelf_program [gdb_find_readelf]
|
|
|
|
|
set res [catch {exec $readelf_program --version} output]
|
|
|
|
|
if { $res != 0 } {
|
|
|
|
|
return [list]
|
|
|
|
|
}
|
|
|
|
|
set lines [split $output \n]
|
|
|
|
|
set line [lindex $lines 0]
|
|
|
|
|
set res [regexp {[ \t]+([0-9]+)[.]([0-9]+)[^ \t]*$} \
|
|
|
|
|
$line dummy major minor]
|
|
|
|
|
if { $res != 1 } {
|
|
|
|
|
return [list]
|
|
|
|
|
}
|
|
|
|
|
return [list $major $minor]
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# Return 1 if readelf prints the PIE flag, 0 if is doesn't, and -1 if unknown.
|
|
|
|
|
proc readelf_prints_pie { } {
|
|
|
|
|
set version [readelf_version]
|
|
|
|
|
if { [llength $version] == 0 } {
|
|
|
|
|
return -1
|
|
|
|
|
}
|
|
|
|
|
set major [lindex $version 0]
|
|
|
|
|
set minor [lindex $version 1]
|
|
|
|
|
# It would be better to construct a PIE executable and test if the PIE
|
|
|
|
|
# flag is printed by readelf, but we cannot reliably construct a PIE
|
|
|
|
|
# executable if the multilib_flags dictate otherwise
|
|
|
|
|
# (--target_board=unix/-no-pie/-fno-PIE).
|
|
|
|
|
return [version_at_least $major $minor 2 26]
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# Return 1 if EXECUTABLE is a Position Independent Executable, 0 if it is not,
|
|
|
|
|
# and -1 if unknown.
|
2019-07-30 09:42:07 +02:00
|
|
|
|
|
|
|
|
|
proc exec_is_pie { executable } {
|
2019-08-05 12:51:58 +02:00
|
|
|
|
set res [readelf_prints_pie]
|
|
|
|
|
if { $res != 1 } {
|
|
|
|
|
return -1
|
|
|
|
|
}
|
2019-07-30 09:42:07 +02:00
|
|
|
|
set readelf_program [gdb_find_readelf]
|
2019-08-05 12:51:58 +02:00
|
|
|
|
set res [catch {exec $readelf_program -d $executable} output]
|
|
|
|
|
if { $res != 0 } {
|
|
|
|
|
return -1
|
|
|
|
|
}
|
|
|
|
|
set res [regexp -line {\(FLAGS_1\).*Flags:.* PIE($| )} $output]
|
|
|
|
|
if { $res == 1 } {
|
2019-07-30 09:42:07 +02:00
|
|
|
|
return 1
|
|
|
|
|
}
|
|
|
|
|
return 0
|
|
|
|
|
}
|
|
|
|
|
|
2016-09-02 10:22:13 +02:00
|
|
|
|
# Return true if a test should be skipped due to lack of floating
|
|
|
|
|
# point support or GDB can't fetch the contents from floating point
|
|
|
|
|
# registers.
|
2000-10-17 22:00:21 +02:00
|
|
|
|
|
2016-09-02 10:22:13 +02:00
|
|
|
|
gdb_caching_proc gdb_skip_float_test {
|
2000-10-17 22:00:21 +02:00
|
|
|
|
if [target_info exists gdb,skip_float_tests] {
|
gdb/testsuite/
* config/monitor.exp (gdb_target_cmd): Remove semicolon after
'return'.
(gdb_target_monitor, gdb_load): Likewise.
* config/sid.exp (gdb_load): Likewise.
* config/slite.exp (gdb_load): Likewise.
* config/vx.exp (gdb_start, spawn_vxgdb): Likewise.
* gdb.ada/arrayidx.exp, gdb.ada/null_array.exp: Likewise.
* gdb.arch/mips-octeon-bbit.exp (single_step): Likewise.
(single_step_until): Likewise.
* gdb.arch/powerpc-d128-regs.exp: Likewise.
* gdb.arch/system-gcore.exp: Likewise.
* gdb.base/bigcore.exp (extract_heap): Likewise.
* gdb.base/break-on-linker-gcd-function.exp: Likewise.
* gdb.base/call-ar-st.exp: Likewise.
* gdb.base/call-rt-st.exp: Likewise.
* gdb.base/call-sc.exp, gdb.base/call-strs.exp: Likewise.
* gdb.base/callfuncs.exp, gdb.base/completion.exp: Likewise.
* gdb.base/condbreak.exp, gdb.base/constvars.exp: Likewise.
* gdb.base/corefile.exp: Likewise.
* gdb.base/dbx.exp (gdb_file_cmd): Likewise.
* gdb.base/exprs.exp, gdb.base/fileio.exp: Likewise.
* gdb.base/fixsection.exp: Likewise.
* gdb.base/funcargs.exp: Likewise.
* gdb.base/gcore-buffer-overflow.exp: Likewise.
* gdb.base/gcore-relro.exp: Likewise.
* gdb.base/gcore.exp, gdb.base/gdb11530.exp: Likewise.
* gdb.base/gdb11531.exp, gdb.base/gnu-ifunc.exp: Likewise.
* gdb.base/info-os.exp, gdb.base/info-proc.exp: Likewise.
* gdb.base/interp.exp, gdb.base/langs.exp:: Likewise.
* gdb.base/list.exp: Likewise.
(set_listsize): Likewise.
* gdb.base/logical.exp, gdb.base/mips_pro.exp: Likewise.
* gdb.base/miscexprs.exp, gdb.base/nodebug.exp: Likewise.
* gdb.base/opaque.exp, gdb.base/pointers.exp: Likewise.
* gdb.base/psymtab.exp, gdb.base/ptype.exp: Likewise.
* gdb.base/relational.exp, gdb.base/scope.exp: Likewise.
* gdb.base/setvar.exp: Likewise.
(test_set): Likewise.
* gdb.base/signals.exp, gdb.base/sizeof.exp: Likewise.
* gdb.base/solib-overlap.exp: Likewise.
* gdb.base/store.exp, gdb.base/structs.exp: Likewise.
* gdb.base/structs2.exp, gdb.base/volatile.exp: Likewise.
* gdb.base/watchpoint.exp (initialize): Likewise.
(test_simple_watchpoint): Likewise.
(test_disabling_watchpoints): Likewise.
(test_watchpoint_triggered_in_syscall): Likewise.
* gdb.base/whatis.exp, gdb.cp/ambiguous.exp: Likewise.
* gdb.cp/casts.exp, gdb.cp/ctti.exp: Likewise.
* gdb.cp/namespace.exp, gdb.cp/nsdecl.exp: Likewise.
* gdb.cp/psmang.exp, gdb.dwarf2/dw2-ranges.exp: Likewise.
* gdb.hp/gdb.aCC/optimize.exp: Likewise.
* gdb.hp/gdb.aCC/watch-cmd.exp: Likewise.
* gdb.hp/gdb.base-hp/callfwmall.exp: Likewise.
* gdb.hp/gdb.base-hp/pxdb.exp: Likewise.
* gdb.hp/gdb.compat/xdb1.exp: Likewise.
* gdb.hp/gdb.compat/xdb2.exp: Likewise.
* gdb.hp/gdb.compat/xdb3.exp: Likewise.
* gdb.hp/gdb.defects/bs14602.exp: Likewise.
* gdb.hp/gdb.defects/solib-d.exp: Likewise.
* gdb.mi/gdb792.exp: Likewise.
* gdb.mi/mi-inheritance-syntax-error.exp: Likewise.
* gdb.mi/mi-logging.exp, gdb.mi/mi-var-cp.exp : Likewise.
* gdb.mi/mi-var-rtti.exp, gdb.python/py-type.exp: Likewise.
* gdb.threads/gcore-thread.exp: Likewise.
(load_core): Likewise.
* gdb.threads/pthreads.exp (all_threads_running): Likewise.
(test_startup, check_control_c): Likewise.
* gdb.threads/sigstep-threads.exp: Likewise.
* gdb.threads/thread_check.exp: Likewise.
* gdb.trace/backtrace.exp, gdb.trace/change-loc.exp: Likewise.
* gdb.trace/circ.exp (run_trace_experiment): Likewise.
(set_a_tracepoint, trace_buffer_normal): Likewise.
(gdb_trace_circular_tests): Likewise.
* gdb.trace/collection.exp: Likewise.
* gdb.trace/disconnected-tracing.exp: Likewise.
* gdb.trace/infotrace.exp: Likewise.
* gdb.trace/mi-traceframe-changed.exp: Likewise.
* gdb.trace/mi-tracepoint-changed.exp: Likewise.
* gdb.trace/mi-tsv-changed.exp (test_create_delete_modify_tsv): Likewise.
* gdb.trace/packetlen.exp, gdb.trace/passc-dyn.exp: Likewise.
* gdb.trace/pending.exp, gdb.trace/report.exp: Likewise.
* gdb.trace/stap-trace.exp: Likewise.
* gdb.trace/status-stop.exp,gdb.trace/strace.exp: Likewise.
* gdb.trace/tfind.exp, gdb.trace/trace-break.exp: Likewise.
* gdb.trace/trace-buffer-size.exp: Likewise.
* gdb.trace/tspeed.exp, gdb.trace/tsv.exp: Likewise.
* gdb.trace/unavailable.exp: Likewise.
* gdb.trace/while-dyn.exp: Likewise.
* lib/fortran.exp (set_lang_fortran): Likewise.
* lib/gdb.exp (default_gdb_version, gdb_start_cmd): Likewise.
(gdb_breakpoint, gdb_reinitialize_dir): Likewise.
(default_gdb_start, get_compiler_info): Likewise.
(gdb_compile, gdb_compile_objc, gdb_reload, gdb_init): Likewise.
(get_debug_format, setup_xfail_format): Likewise.
(rerun_to_main, gdb_skip_float_test): Likewise.
(build_id_debug_filename_get, get_remotetimeout): Likewise.
* lib/java.exp (set_lang_java): Likewise.
* lib/mi-support.exp (default_mi_gdb_start): Likewise.
(mi_gdb_reinitialize_dir, mi_gdb_target_cmd): Likewise.
(mi_gdb_file_cmd, mi_gdb_test): Likewise.
(mi_run_cmd_full, mi_expect_interrupt): Likewise.
* lib/objc.exp (set_lang_objc): Likewise.
* lib/pascal.exp (set_lang_pascal): Likewise.
* lib/prompt.exp (default_prompt_gdb_start): Likewise.
* lib/trace-support.exp (gdb_trace_setactions, gdb_tfind_test): Likewise.
(gdb_readexpr, gdb_gettpnum, gdb_find_recursion_test_baseline): Likewise.
2013-03-14 14:34:06 +01:00
|
|
|
|
return 1
|
2000-10-17 22:00:21 +02:00
|
|
|
|
}
|
2016-09-02 10:22:13 +02:00
|
|
|
|
|
|
|
|
|
# There is an ARM kernel ptrace bug that hardware VFP registers
|
|
|
|
|
# are not updated after GDB ptrace set VFP registers. The bug
|
|
|
|
|
# was introduced by kernel commit 8130b9d7b9d858aa04ce67805e8951e3cb6e9b2f
|
|
|
|
|
# in 2012 and is fixed in e2dfb4b880146bfd4b6aa8e138c0205407cebbaf
|
|
|
|
|
# in May 2016. In other words, kernels older than 4.6.3, 4.4.14,
|
|
|
|
|
# 4.1.27, 3.18.36, and 3.14.73 have this bug.
|
|
|
|
|
# This kernel bug is detected by check how does GDB change the
|
|
|
|
|
# program result by changing one VFP register.
|
|
|
|
|
if { [istarget "arm*-*-linux*"] } {
|
|
|
|
|
|
|
|
|
|
set compile_flags {debug nowarnings }
|
|
|
|
|
|
|
|
|
|
# Set up, compile, and execute a test program having VFP
|
|
|
|
|
# operations.
|
|
|
|
|
set src [standard_temp_file arm_vfp[pid].c]
|
|
|
|
|
set exe [standard_temp_file arm_vfp[pid].x]
|
|
|
|
|
|
|
|
|
|
gdb_produce_source $src {
|
|
|
|
|
int main() {
|
|
|
|
|
double d = 4.0;
|
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
|
|
asm ("vldr d0, [%0]" : : "r" (&d));
|
|
|
|
|
asm ("vldr d1, [%0]" : : "r" (&d));
|
|
|
|
|
asm (".global break_here\n"
|
|
|
|
|
"break_here:");
|
|
|
|
|
asm ("vcmp.f64 d0, d1\n"
|
|
|
|
|
"vmrs APSR_nzcv, fpscr\n"
|
|
|
|
|
"bne L_value_different\n"
|
|
|
|
|
"movs %0, #0\n"
|
|
|
|
|
"b L_end\n"
|
|
|
|
|
"L_value_different:\n"
|
|
|
|
|
"movs %0, #1\n"
|
|
|
|
|
"L_end:\n" : "=r" (ret) :);
|
|
|
|
|
|
|
|
|
|
/* Return $d0 != $d1. */
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
verbose "compiling testfile $src" 2
|
|
|
|
|
set lines [gdb_compile $src $exe executable $compile_flags]
|
|
|
|
|
file delete $src
|
|
|
|
|
|
|
|
|
|
if ![string match "" $lines] then {
|
|
|
|
|
verbose "testfile compilation failed, returning 1" 2
|
|
|
|
|
return 0
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# No error message, compilation succeeded so now run it via gdb.
|
|
|
|
|
# Run the test up to 5 times to detect whether ptrace can
|
|
|
|
|
# correctly update VFP registers or not.
|
|
|
|
|
set skip_vfp_test 0
|
|
|
|
|
for {set i 0} {$i < 5} {incr i} {
|
|
|
|
|
global gdb_prompt srcdir subdir
|
|
|
|
|
|
|
|
|
|
gdb_exit
|
|
|
|
|
gdb_start
|
|
|
|
|
gdb_reinitialize_dir $srcdir/$subdir
|
|
|
|
|
gdb_load "$exe"
|
|
|
|
|
|
|
|
|
|
runto_main
|
|
|
|
|
gdb_test "break *break_here"
|
|
|
|
|
gdb_continue_to_breakpoint "break_here"
|
|
|
|
|
|
|
|
|
|
# Modify $d0 to a different value, so the exit code should
|
|
|
|
|
# be 1.
|
|
|
|
|
gdb_test "set \$d0 = 5.0"
|
|
|
|
|
|
|
|
|
|
set test "continue to exit"
|
|
|
|
|
gdb_test_multiple "continue" "$test" {
|
|
|
|
|
-re "exited with code 01.*$gdb_prompt $" {
|
|
|
|
|
}
|
|
|
|
|
-re "exited normally.*$gdb_prompt $" {
|
|
|
|
|
# However, the exit code is 0. That means something
|
|
|
|
|
# wrong in setting VFP registers.
|
|
|
|
|
set skip_vfp_test 1
|
|
|
|
|
break
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
gdb_exit
|
|
|
|
|
remote_file build delete $exe
|
|
|
|
|
|
|
|
|
|
return $skip_vfp_test
|
|
|
|
|
}
|
gdb/testsuite/
* config/monitor.exp (gdb_target_cmd): Remove semicolon after
'return'.
(gdb_target_monitor, gdb_load): Likewise.
* config/sid.exp (gdb_load): Likewise.
* config/slite.exp (gdb_load): Likewise.
* config/vx.exp (gdb_start, spawn_vxgdb): Likewise.
* gdb.ada/arrayidx.exp, gdb.ada/null_array.exp: Likewise.
* gdb.arch/mips-octeon-bbit.exp (single_step): Likewise.
(single_step_until): Likewise.
* gdb.arch/powerpc-d128-regs.exp: Likewise.
* gdb.arch/system-gcore.exp: Likewise.
* gdb.base/bigcore.exp (extract_heap): Likewise.
* gdb.base/break-on-linker-gcd-function.exp: Likewise.
* gdb.base/call-ar-st.exp: Likewise.
* gdb.base/call-rt-st.exp: Likewise.
* gdb.base/call-sc.exp, gdb.base/call-strs.exp: Likewise.
* gdb.base/callfuncs.exp, gdb.base/completion.exp: Likewise.
* gdb.base/condbreak.exp, gdb.base/constvars.exp: Likewise.
* gdb.base/corefile.exp: Likewise.
* gdb.base/dbx.exp (gdb_file_cmd): Likewise.
* gdb.base/exprs.exp, gdb.base/fileio.exp: Likewise.
* gdb.base/fixsection.exp: Likewise.
* gdb.base/funcargs.exp: Likewise.
* gdb.base/gcore-buffer-overflow.exp: Likewise.
* gdb.base/gcore-relro.exp: Likewise.
* gdb.base/gcore.exp, gdb.base/gdb11530.exp: Likewise.
* gdb.base/gdb11531.exp, gdb.base/gnu-ifunc.exp: Likewise.
* gdb.base/info-os.exp, gdb.base/info-proc.exp: Likewise.
* gdb.base/interp.exp, gdb.base/langs.exp:: Likewise.
* gdb.base/list.exp: Likewise.
(set_listsize): Likewise.
* gdb.base/logical.exp, gdb.base/mips_pro.exp: Likewise.
* gdb.base/miscexprs.exp, gdb.base/nodebug.exp: Likewise.
* gdb.base/opaque.exp, gdb.base/pointers.exp: Likewise.
* gdb.base/psymtab.exp, gdb.base/ptype.exp: Likewise.
* gdb.base/relational.exp, gdb.base/scope.exp: Likewise.
* gdb.base/setvar.exp: Likewise.
(test_set): Likewise.
* gdb.base/signals.exp, gdb.base/sizeof.exp: Likewise.
* gdb.base/solib-overlap.exp: Likewise.
* gdb.base/store.exp, gdb.base/structs.exp: Likewise.
* gdb.base/structs2.exp, gdb.base/volatile.exp: Likewise.
* gdb.base/watchpoint.exp (initialize): Likewise.
(test_simple_watchpoint): Likewise.
(test_disabling_watchpoints): Likewise.
(test_watchpoint_triggered_in_syscall): Likewise.
* gdb.base/whatis.exp, gdb.cp/ambiguous.exp: Likewise.
* gdb.cp/casts.exp, gdb.cp/ctti.exp: Likewise.
* gdb.cp/namespace.exp, gdb.cp/nsdecl.exp: Likewise.
* gdb.cp/psmang.exp, gdb.dwarf2/dw2-ranges.exp: Likewise.
* gdb.hp/gdb.aCC/optimize.exp: Likewise.
* gdb.hp/gdb.aCC/watch-cmd.exp: Likewise.
* gdb.hp/gdb.base-hp/callfwmall.exp: Likewise.
* gdb.hp/gdb.base-hp/pxdb.exp: Likewise.
* gdb.hp/gdb.compat/xdb1.exp: Likewise.
* gdb.hp/gdb.compat/xdb2.exp: Likewise.
* gdb.hp/gdb.compat/xdb3.exp: Likewise.
* gdb.hp/gdb.defects/bs14602.exp: Likewise.
* gdb.hp/gdb.defects/solib-d.exp: Likewise.
* gdb.mi/gdb792.exp: Likewise.
* gdb.mi/mi-inheritance-syntax-error.exp: Likewise.
* gdb.mi/mi-logging.exp, gdb.mi/mi-var-cp.exp : Likewise.
* gdb.mi/mi-var-rtti.exp, gdb.python/py-type.exp: Likewise.
* gdb.threads/gcore-thread.exp: Likewise.
(load_core): Likewise.
* gdb.threads/pthreads.exp (all_threads_running): Likewise.
(test_startup, check_control_c): Likewise.
* gdb.threads/sigstep-threads.exp: Likewise.
* gdb.threads/thread_check.exp: Likewise.
* gdb.trace/backtrace.exp, gdb.trace/change-loc.exp: Likewise.
* gdb.trace/circ.exp (run_trace_experiment): Likewise.
(set_a_tracepoint, trace_buffer_normal): Likewise.
(gdb_trace_circular_tests): Likewise.
* gdb.trace/collection.exp: Likewise.
* gdb.trace/disconnected-tracing.exp: Likewise.
* gdb.trace/infotrace.exp: Likewise.
* gdb.trace/mi-traceframe-changed.exp: Likewise.
* gdb.trace/mi-tracepoint-changed.exp: Likewise.
* gdb.trace/mi-tsv-changed.exp (test_create_delete_modify_tsv): Likewise.
* gdb.trace/packetlen.exp, gdb.trace/passc-dyn.exp: Likewise.
* gdb.trace/pending.exp, gdb.trace/report.exp: Likewise.
* gdb.trace/stap-trace.exp: Likewise.
* gdb.trace/status-stop.exp,gdb.trace/strace.exp: Likewise.
* gdb.trace/tfind.exp, gdb.trace/trace-break.exp: Likewise.
* gdb.trace/trace-buffer-size.exp: Likewise.
* gdb.trace/tspeed.exp, gdb.trace/tsv.exp: Likewise.
* gdb.trace/unavailable.exp: Likewise.
* gdb.trace/while-dyn.exp: Likewise.
* lib/fortran.exp (set_lang_fortran): Likewise.
* lib/gdb.exp (default_gdb_version, gdb_start_cmd): Likewise.
(gdb_breakpoint, gdb_reinitialize_dir): Likewise.
(default_gdb_start, get_compiler_info): Likewise.
(gdb_compile, gdb_compile_objc, gdb_reload, gdb_init): Likewise.
(get_debug_format, setup_xfail_format): Likewise.
(rerun_to_main, gdb_skip_float_test): Likewise.
(build_id_debug_filename_get, get_remotetimeout): Likewise.
* lib/java.exp (set_lang_java): Likewise.
* lib/mi-support.exp (default_mi_gdb_start): Likewise.
(mi_gdb_reinitialize_dir, mi_gdb_target_cmd): Likewise.
(mi_gdb_file_cmd, mi_gdb_test): Likewise.
(mi_run_cmd_full, mi_expect_interrupt): Likewise.
* lib/objc.exp (set_lang_objc): Likewise.
* lib/pascal.exp (set_lang_pascal): Likewise.
* lib/prompt.exp (default_prompt_gdb_start): Likewise.
* lib/trace-support.exp (gdb_trace_setactions, gdb_tfind_test): Likewise.
(gdb_readexpr, gdb_gettpnum, gdb_find_recursion_test_baseline): Likewise.
2013-03-14 14:34:06 +01:00
|
|
|
|
return 0
|
2000-10-17 22:00:21 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# Print a message and return true if a test should be skipped
|
|
|
|
|
# due to lack of stdio support.
|
|
|
|
|
|
|
|
|
|
proc gdb_skip_stdio_test { msg } {
|
|
|
|
|
if [target_info exists gdb,noinferiorio] {
|
2013-06-07 19:31:09 +02:00
|
|
|
|
verbose "Skipping test '$msg': no inferior i/o."
|
gdb/testsuite/
* config/monitor.exp (gdb_target_cmd): Remove semicolon after
'return'.
(gdb_target_monitor, gdb_load): Likewise.
* config/sid.exp (gdb_load): Likewise.
* config/slite.exp (gdb_load): Likewise.
* config/vx.exp (gdb_start, spawn_vxgdb): Likewise.
* gdb.ada/arrayidx.exp, gdb.ada/null_array.exp: Likewise.
* gdb.arch/mips-octeon-bbit.exp (single_step): Likewise.
(single_step_until): Likewise.
* gdb.arch/powerpc-d128-regs.exp: Likewise.
* gdb.arch/system-gcore.exp: Likewise.
* gdb.base/bigcore.exp (extract_heap): Likewise.
* gdb.base/break-on-linker-gcd-function.exp: Likewise.
* gdb.base/call-ar-st.exp: Likewise.
* gdb.base/call-rt-st.exp: Likewise.
* gdb.base/call-sc.exp, gdb.base/call-strs.exp: Likewise.
* gdb.base/callfuncs.exp, gdb.base/completion.exp: Likewise.
* gdb.base/condbreak.exp, gdb.base/constvars.exp: Likewise.
* gdb.base/corefile.exp: Likewise.
* gdb.base/dbx.exp (gdb_file_cmd): Likewise.
* gdb.base/exprs.exp, gdb.base/fileio.exp: Likewise.
* gdb.base/fixsection.exp: Likewise.
* gdb.base/funcargs.exp: Likewise.
* gdb.base/gcore-buffer-overflow.exp: Likewise.
* gdb.base/gcore-relro.exp: Likewise.
* gdb.base/gcore.exp, gdb.base/gdb11530.exp: Likewise.
* gdb.base/gdb11531.exp, gdb.base/gnu-ifunc.exp: Likewise.
* gdb.base/info-os.exp, gdb.base/info-proc.exp: Likewise.
* gdb.base/interp.exp, gdb.base/langs.exp:: Likewise.
* gdb.base/list.exp: Likewise.
(set_listsize): Likewise.
* gdb.base/logical.exp, gdb.base/mips_pro.exp: Likewise.
* gdb.base/miscexprs.exp, gdb.base/nodebug.exp: Likewise.
* gdb.base/opaque.exp, gdb.base/pointers.exp: Likewise.
* gdb.base/psymtab.exp, gdb.base/ptype.exp: Likewise.
* gdb.base/relational.exp, gdb.base/scope.exp: Likewise.
* gdb.base/setvar.exp: Likewise.
(test_set): Likewise.
* gdb.base/signals.exp, gdb.base/sizeof.exp: Likewise.
* gdb.base/solib-overlap.exp: Likewise.
* gdb.base/store.exp, gdb.base/structs.exp: Likewise.
* gdb.base/structs2.exp, gdb.base/volatile.exp: Likewise.
* gdb.base/watchpoint.exp (initialize): Likewise.
(test_simple_watchpoint): Likewise.
(test_disabling_watchpoints): Likewise.
(test_watchpoint_triggered_in_syscall): Likewise.
* gdb.base/whatis.exp, gdb.cp/ambiguous.exp: Likewise.
* gdb.cp/casts.exp, gdb.cp/ctti.exp: Likewise.
* gdb.cp/namespace.exp, gdb.cp/nsdecl.exp: Likewise.
* gdb.cp/psmang.exp, gdb.dwarf2/dw2-ranges.exp: Likewise.
* gdb.hp/gdb.aCC/optimize.exp: Likewise.
* gdb.hp/gdb.aCC/watch-cmd.exp: Likewise.
* gdb.hp/gdb.base-hp/callfwmall.exp: Likewise.
* gdb.hp/gdb.base-hp/pxdb.exp: Likewise.
* gdb.hp/gdb.compat/xdb1.exp: Likewise.
* gdb.hp/gdb.compat/xdb2.exp: Likewise.
* gdb.hp/gdb.compat/xdb3.exp: Likewise.
* gdb.hp/gdb.defects/bs14602.exp: Likewise.
* gdb.hp/gdb.defects/solib-d.exp: Likewise.
* gdb.mi/gdb792.exp: Likewise.
* gdb.mi/mi-inheritance-syntax-error.exp: Likewise.
* gdb.mi/mi-logging.exp, gdb.mi/mi-var-cp.exp : Likewise.
* gdb.mi/mi-var-rtti.exp, gdb.python/py-type.exp: Likewise.
* gdb.threads/gcore-thread.exp: Likewise.
(load_core): Likewise.
* gdb.threads/pthreads.exp (all_threads_running): Likewise.
(test_startup, check_control_c): Likewise.
* gdb.threads/sigstep-threads.exp: Likewise.
* gdb.threads/thread_check.exp: Likewise.
* gdb.trace/backtrace.exp, gdb.trace/change-loc.exp: Likewise.
* gdb.trace/circ.exp (run_trace_experiment): Likewise.
(set_a_tracepoint, trace_buffer_normal): Likewise.
(gdb_trace_circular_tests): Likewise.
* gdb.trace/collection.exp: Likewise.
* gdb.trace/disconnected-tracing.exp: Likewise.
* gdb.trace/infotrace.exp: Likewise.
* gdb.trace/mi-traceframe-changed.exp: Likewise.
* gdb.trace/mi-tracepoint-changed.exp: Likewise.
* gdb.trace/mi-tsv-changed.exp (test_create_delete_modify_tsv): Likewise.
* gdb.trace/packetlen.exp, gdb.trace/passc-dyn.exp: Likewise.
* gdb.trace/pending.exp, gdb.trace/report.exp: Likewise.
* gdb.trace/stap-trace.exp: Likewise.
* gdb.trace/status-stop.exp,gdb.trace/strace.exp: Likewise.
* gdb.trace/tfind.exp, gdb.trace/trace-break.exp: Likewise.
* gdb.trace/trace-buffer-size.exp: Likewise.
* gdb.trace/tspeed.exp, gdb.trace/tsv.exp: Likewise.
* gdb.trace/unavailable.exp: Likewise.
* gdb.trace/while-dyn.exp: Likewise.
* lib/fortran.exp (set_lang_fortran): Likewise.
* lib/gdb.exp (default_gdb_version, gdb_start_cmd): Likewise.
(gdb_breakpoint, gdb_reinitialize_dir): Likewise.
(default_gdb_start, get_compiler_info): Likewise.
(gdb_compile, gdb_compile_objc, gdb_reload, gdb_init): Likewise.
(get_debug_format, setup_xfail_format): Likewise.
(rerun_to_main, gdb_skip_float_test): Likewise.
(build_id_debug_filename_get, get_remotetimeout): Likewise.
* lib/java.exp (set_lang_java): Likewise.
* lib/mi-support.exp (default_mi_gdb_start): Likewise.
(mi_gdb_reinitialize_dir, mi_gdb_target_cmd): Likewise.
(mi_gdb_file_cmd, mi_gdb_test): Likewise.
(mi_run_cmd_full, mi_expect_interrupt): Likewise.
* lib/objc.exp (set_lang_objc): Likewise.
* lib/pascal.exp (set_lang_pascal): Likewise.
* lib/prompt.exp (default_prompt_gdb_start): Likewise.
* lib/trace-support.exp (gdb_trace_setactions, gdb_tfind_test): Likewise.
(gdb_readexpr, gdb_gettpnum, gdb_find_recursion_test_baseline): Likewise.
2013-03-14 14:34:06 +01:00
|
|
|
|
return 1
|
2000-10-17 22:00:21 +02:00
|
|
|
|
}
|
gdb/testsuite/
* config/monitor.exp (gdb_target_cmd): Remove semicolon after
'return'.
(gdb_target_monitor, gdb_load): Likewise.
* config/sid.exp (gdb_load): Likewise.
* config/slite.exp (gdb_load): Likewise.
* config/vx.exp (gdb_start, spawn_vxgdb): Likewise.
* gdb.ada/arrayidx.exp, gdb.ada/null_array.exp: Likewise.
* gdb.arch/mips-octeon-bbit.exp (single_step): Likewise.
(single_step_until): Likewise.
* gdb.arch/powerpc-d128-regs.exp: Likewise.
* gdb.arch/system-gcore.exp: Likewise.
* gdb.base/bigcore.exp (extract_heap): Likewise.
* gdb.base/break-on-linker-gcd-function.exp: Likewise.
* gdb.base/call-ar-st.exp: Likewise.
* gdb.base/call-rt-st.exp: Likewise.
* gdb.base/call-sc.exp, gdb.base/call-strs.exp: Likewise.
* gdb.base/callfuncs.exp, gdb.base/completion.exp: Likewise.
* gdb.base/condbreak.exp, gdb.base/constvars.exp: Likewise.
* gdb.base/corefile.exp: Likewise.
* gdb.base/dbx.exp (gdb_file_cmd): Likewise.
* gdb.base/exprs.exp, gdb.base/fileio.exp: Likewise.
* gdb.base/fixsection.exp: Likewise.
* gdb.base/funcargs.exp: Likewise.
* gdb.base/gcore-buffer-overflow.exp: Likewise.
* gdb.base/gcore-relro.exp: Likewise.
* gdb.base/gcore.exp, gdb.base/gdb11530.exp: Likewise.
* gdb.base/gdb11531.exp, gdb.base/gnu-ifunc.exp: Likewise.
* gdb.base/info-os.exp, gdb.base/info-proc.exp: Likewise.
* gdb.base/interp.exp, gdb.base/langs.exp:: Likewise.
* gdb.base/list.exp: Likewise.
(set_listsize): Likewise.
* gdb.base/logical.exp, gdb.base/mips_pro.exp: Likewise.
* gdb.base/miscexprs.exp, gdb.base/nodebug.exp: Likewise.
* gdb.base/opaque.exp, gdb.base/pointers.exp: Likewise.
* gdb.base/psymtab.exp, gdb.base/ptype.exp: Likewise.
* gdb.base/relational.exp, gdb.base/scope.exp: Likewise.
* gdb.base/setvar.exp: Likewise.
(test_set): Likewise.
* gdb.base/signals.exp, gdb.base/sizeof.exp: Likewise.
* gdb.base/solib-overlap.exp: Likewise.
* gdb.base/store.exp, gdb.base/structs.exp: Likewise.
* gdb.base/structs2.exp, gdb.base/volatile.exp: Likewise.
* gdb.base/watchpoint.exp (initialize): Likewise.
(test_simple_watchpoint): Likewise.
(test_disabling_watchpoints): Likewise.
(test_watchpoint_triggered_in_syscall): Likewise.
* gdb.base/whatis.exp, gdb.cp/ambiguous.exp: Likewise.
* gdb.cp/casts.exp, gdb.cp/ctti.exp: Likewise.
* gdb.cp/namespace.exp, gdb.cp/nsdecl.exp: Likewise.
* gdb.cp/psmang.exp, gdb.dwarf2/dw2-ranges.exp: Likewise.
* gdb.hp/gdb.aCC/optimize.exp: Likewise.
* gdb.hp/gdb.aCC/watch-cmd.exp: Likewise.
* gdb.hp/gdb.base-hp/callfwmall.exp: Likewise.
* gdb.hp/gdb.base-hp/pxdb.exp: Likewise.
* gdb.hp/gdb.compat/xdb1.exp: Likewise.
* gdb.hp/gdb.compat/xdb2.exp: Likewise.
* gdb.hp/gdb.compat/xdb3.exp: Likewise.
* gdb.hp/gdb.defects/bs14602.exp: Likewise.
* gdb.hp/gdb.defects/solib-d.exp: Likewise.
* gdb.mi/gdb792.exp: Likewise.
* gdb.mi/mi-inheritance-syntax-error.exp: Likewise.
* gdb.mi/mi-logging.exp, gdb.mi/mi-var-cp.exp : Likewise.
* gdb.mi/mi-var-rtti.exp, gdb.python/py-type.exp: Likewise.
* gdb.threads/gcore-thread.exp: Likewise.
(load_core): Likewise.
* gdb.threads/pthreads.exp (all_threads_running): Likewise.
(test_startup, check_control_c): Likewise.
* gdb.threads/sigstep-threads.exp: Likewise.
* gdb.threads/thread_check.exp: Likewise.
* gdb.trace/backtrace.exp, gdb.trace/change-loc.exp: Likewise.
* gdb.trace/circ.exp (run_trace_experiment): Likewise.
(set_a_tracepoint, trace_buffer_normal): Likewise.
(gdb_trace_circular_tests): Likewise.
* gdb.trace/collection.exp: Likewise.
* gdb.trace/disconnected-tracing.exp: Likewise.
* gdb.trace/infotrace.exp: Likewise.
* gdb.trace/mi-traceframe-changed.exp: Likewise.
* gdb.trace/mi-tracepoint-changed.exp: Likewise.
* gdb.trace/mi-tsv-changed.exp (test_create_delete_modify_tsv): Likewise.
* gdb.trace/packetlen.exp, gdb.trace/passc-dyn.exp: Likewise.
* gdb.trace/pending.exp, gdb.trace/report.exp: Likewise.
* gdb.trace/stap-trace.exp: Likewise.
* gdb.trace/status-stop.exp,gdb.trace/strace.exp: Likewise.
* gdb.trace/tfind.exp, gdb.trace/trace-break.exp: Likewise.
* gdb.trace/trace-buffer-size.exp: Likewise.
* gdb.trace/tspeed.exp, gdb.trace/tsv.exp: Likewise.
* gdb.trace/unavailable.exp: Likewise.
* gdb.trace/while-dyn.exp: Likewise.
* lib/fortran.exp (set_lang_fortran): Likewise.
* lib/gdb.exp (default_gdb_version, gdb_start_cmd): Likewise.
(gdb_breakpoint, gdb_reinitialize_dir): Likewise.
(default_gdb_start, get_compiler_info): Likewise.
(gdb_compile, gdb_compile_objc, gdb_reload, gdb_init): Likewise.
(get_debug_format, setup_xfail_format): Likewise.
(rerun_to_main, gdb_skip_float_test): Likewise.
(build_id_debug_filename_get, get_remotetimeout): Likewise.
* lib/java.exp (set_lang_java): Likewise.
* lib/mi-support.exp (default_mi_gdb_start): Likewise.
(mi_gdb_reinitialize_dir, mi_gdb_target_cmd): Likewise.
(mi_gdb_file_cmd, mi_gdb_test): Likewise.
(mi_run_cmd_full, mi_expect_interrupt): Likewise.
* lib/objc.exp (set_lang_objc): Likewise.
* lib/pascal.exp (set_lang_pascal): Likewise.
* lib/prompt.exp (default_prompt_gdb_start): Likewise.
* lib/trace-support.exp (gdb_trace_setactions, gdb_tfind_test): Likewise.
(gdb_readexpr, gdb_gettpnum, gdb_find_recursion_test_baseline): Likewise.
2013-03-14 14:34:06 +01:00
|
|
|
|
return 0
|
2000-10-17 22:00:21 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
proc gdb_skip_bogus_test { msg } {
|
gdb/testsuite/
* config/monitor.exp (gdb_target_cmd): Remove semicolon after
'return'.
(gdb_target_monitor, gdb_load): Likewise.
* config/sid.exp (gdb_load): Likewise.
* config/slite.exp (gdb_load): Likewise.
* config/vx.exp (gdb_start, spawn_vxgdb): Likewise.
* gdb.ada/arrayidx.exp, gdb.ada/null_array.exp: Likewise.
* gdb.arch/mips-octeon-bbit.exp (single_step): Likewise.
(single_step_until): Likewise.
* gdb.arch/powerpc-d128-regs.exp: Likewise.
* gdb.arch/system-gcore.exp: Likewise.
* gdb.base/bigcore.exp (extract_heap): Likewise.
* gdb.base/break-on-linker-gcd-function.exp: Likewise.
* gdb.base/call-ar-st.exp: Likewise.
* gdb.base/call-rt-st.exp: Likewise.
* gdb.base/call-sc.exp, gdb.base/call-strs.exp: Likewise.
* gdb.base/callfuncs.exp, gdb.base/completion.exp: Likewise.
* gdb.base/condbreak.exp, gdb.base/constvars.exp: Likewise.
* gdb.base/corefile.exp: Likewise.
* gdb.base/dbx.exp (gdb_file_cmd): Likewise.
* gdb.base/exprs.exp, gdb.base/fileio.exp: Likewise.
* gdb.base/fixsection.exp: Likewise.
* gdb.base/funcargs.exp: Likewise.
* gdb.base/gcore-buffer-overflow.exp: Likewise.
* gdb.base/gcore-relro.exp: Likewise.
* gdb.base/gcore.exp, gdb.base/gdb11530.exp: Likewise.
* gdb.base/gdb11531.exp, gdb.base/gnu-ifunc.exp: Likewise.
* gdb.base/info-os.exp, gdb.base/info-proc.exp: Likewise.
* gdb.base/interp.exp, gdb.base/langs.exp:: Likewise.
* gdb.base/list.exp: Likewise.
(set_listsize): Likewise.
* gdb.base/logical.exp, gdb.base/mips_pro.exp: Likewise.
* gdb.base/miscexprs.exp, gdb.base/nodebug.exp: Likewise.
* gdb.base/opaque.exp, gdb.base/pointers.exp: Likewise.
* gdb.base/psymtab.exp, gdb.base/ptype.exp: Likewise.
* gdb.base/relational.exp, gdb.base/scope.exp: Likewise.
* gdb.base/setvar.exp: Likewise.
(test_set): Likewise.
* gdb.base/signals.exp, gdb.base/sizeof.exp: Likewise.
* gdb.base/solib-overlap.exp: Likewise.
* gdb.base/store.exp, gdb.base/structs.exp: Likewise.
* gdb.base/structs2.exp, gdb.base/volatile.exp: Likewise.
* gdb.base/watchpoint.exp (initialize): Likewise.
(test_simple_watchpoint): Likewise.
(test_disabling_watchpoints): Likewise.
(test_watchpoint_triggered_in_syscall): Likewise.
* gdb.base/whatis.exp, gdb.cp/ambiguous.exp: Likewise.
* gdb.cp/casts.exp, gdb.cp/ctti.exp: Likewise.
* gdb.cp/namespace.exp, gdb.cp/nsdecl.exp: Likewise.
* gdb.cp/psmang.exp, gdb.dwarf2/dw2-ranges.exp: Likewise.
* gdb.hp/gdb.aCC/optimize.exp: Likewise.
* gdb.hp/gdb.aCC/watch-cmd.exp: Likewise.
* gdb.hp/gdb.base-hp/callfwmall.exp: Likewise.
* gdb.hp/gdb.base-hp/pxdb.exp: Likewise.
* gdb.hp/gdb.compat/xdb1.exp: Likewise.
* gdb.hp/gdb.compat/xdb2.exp: Likewise.
* gdb.hp/gdb.compat/xdb3.exp: Likewise.
* gdb.hp/gdb.defects/bs14602.exp: Likewise.
* gdb.hp/gdb.defects/solib-d.exp: Likewise.
* gdb.mi/gdb792.exp: Likewise.
* gdb.mi/mi-inheritance-syntax-error.exp: Likewise.
* gdb.mi/mi-logging.exp, gdb.mi/mi-var-cp.exp : Likewise.
* gdb.mi/mi-var-rtti.exp, gdb.python/py-type.exp: Likewise.
* gdb.threads/gcore-thread.exp: Likewise.
(load_core): Likewise.
* gdb.threads/pthreads.exp (all_threads_running): Likewise.
(test_startup, check_control_c): Likewise.
* gdb.threads/sigstep-threads.exp: Likewise.
* gdb.threads/thread_check.exp: Likewise.
* gdb.trace/backtrace.exp, gdb.trace/change-loc.exp: Likewise.
* gdb.trace/circ.exp (run_trace_experiment): Likewise.
(set_a_tracepoint, trace_buffer_normal): Likewise.
(gdb_trace_circular_tests): Likewise.
* gdb.trace/collection.exp: Likewise.
* gdb.trace/disconnected-tracing.exp: Likewise.
* gdb.trace/infotrace.exp: Likewise.
* gdb.trace/mi-traceframe-changed.exp: Likewise.
* gdb.trace/mi-tracepoint-changed.exp: Likewise.
* gdb.trace/mi-tsv-changed.exp (test_create_delete_modify_tsv): Likewise.
* gdb.trace/packetlen.exp, gdb.trace/passc-dyn.exp: Likewise.
* gdb.trace/pending.exp, gdb.trace/report.exp: Likewise.
* gdb.trace/stap-trace.exp: Likewise.
* gdb.trace/status-stop.exp,gdb.trace/strace.exp: Likewise.
* gdb.trace/tfind.exp, gdb.trace/trace-break.exp: Likewise.
* gdb.trace/trace-buffer-size.exp: Likewise.
* gdb.trace/tspeed.exp, gdb.trace/tsv.exp: Likewise.
* gdb.trace/unavailable.exp: Likewise.
* gdb.trace/while-dyn.exp: Likewise.
* lib/fortran.exp (set_lang_fortran): Likewise.
* lib/gdb.exp (default_gdb_version, gdb_start_cmd): Likewise.
(gdb_breakpoint, gdb_reinitialize_dir): Likewise.
(default_gdb_start, get_compiler_info): Likewise.
(gdb_compile, gdb_compile_objc, gdb_reload, gdb_init): Likewise.
(get_debug_format, setup_xfail_format): Likewise.
(rerun_to_main, gdb_skip_float_test): Likewise.
(build_id_debug_filename_get, get_remotetimeout): Likewise.
* lib/java.exp (set_lang_java): Likewise.
* lib/mi-support.exp (default_mi_gdb_start): Likewise.
(mi_gdb_reinitialize_dir, mi_gdb_target_cmd): Likewise.
(mi_gdb_file_cmd, mi_gdb_test): Likewise.
(mi_run_cmd_full, mi_expect_interrupt): Likewise.
* lib/objc.exp (set_lang_objc): Likewise.
* lib/pascal.exp (set_lang_pascal): Likewise.
* lib/prompt.exp (default_prompt_gdb_start): Likewise.
* lib/trace-support.exp (gdb_trace_setactions, gdb_tfind_test): Likewise.
(gdb_readexpr, gdb_gettpnum, gdb_find_recursion_test_baseline): Likewise.
2013-03-14 14:34:06 +01:00
|
|
|
|
return 0
|
2000-10-17 22:00:21 +02:00
|
|
|
|
}
|
|
|
|
|
|
2007-01-23 18:11:55 +01:00
|
|
|
|
# Return true if a test should be skipped due to lack of XML support
|
|
|
|
|
# in the host GDB.
|
2010-01-08 00:26:39 +01:00
|
|
|
|
# NOTE: This must be called while gdb is *not* running.
|
2007-01-23 18:11:55 +01:00
|
|
|
|
|
2013-08-13 17:55:52 +02:00
|
|
|
|
gdb_caching_proc gdb_skip_xml_test {
|
2017-01-31 17:13:46 +01:00
|
|
|
|
global gdb_spawn_id
|
2007-01-23 18:11:55 +01:00
|
|
|
|
global gdb_prompt
|
|
|
|
|
global srcdir
|
|
|
|
|
|
2017-01-31 17:13:46 +01:00
|
|
|
|
if { [info exists gdb_spawn_id] } {
|
|
|
|
|
error "GDB must not be running in gdb_skip_xml_tests."
|
|
|
|
|
}
|
|
|
|
|
|
2014-08-15 05:28:39 +02:00
|
|
|
|
set xml_file [gdb_remote_download host "${srcdir}/gdb.xml/trivial.xml"]
|
|
|
|
|
|
2007-01-23 18:11:55 +01:00
|
|
|
|
gdb_start
|
2013-08-13 17:55:52 +02:00
|
|
|
|
set xml_missing 0
|
2014-08-15 05:28:39 +02:00
|
|
|
|
gdb_test_multiple "set tdesc filename $xml_file" "" {
|
2007-01-23 18:11:55 +01:00
|
|
|
|
-re ".*XML support was disabled at compile time.*$gdb_prompt $" {
|
2013-08-13 17:55:52 +02:00
|
|
|
|
set xml_missing 1
|
2007-01-23 18:11:55 +01:00
|
|
|
|
}
|
|
|
|
|
-re ".*$gdb_prompt $" { }
|
|
|
|
|
}
|
|
|
|
|
gdb_exit
|
2013-08-13 17:55:52 +02:00
|
|
|
|
return $xml_missing
|
2007-01-23 18:11:55 +01:00
|
|
|
|
}
|
2004-01-12 18:20:41 +01:00
|
|
|
|
|
Skip testing argv[0] on target argv[0] isn't available
I see the following two fails on arm-none-eabi target, because argv[0]
isn't available.
print argv[0]^M
$1 = 0x1f78 "/dev/null"^M
(gdb) FAIL: gdb.base/argv0-symlink.exp: kept file symbolic link name
print argv[0]^M
$1 = 0x1f78 "/dev/null"^M
(gdb) FAIL: gdb.base/argv0-symlink.exp: kept directory symbolic link name
My first thought is to check [target_info exists noargs], and skip the
test if it returns true. However, noargs is set in gdbserver board
files, so argv0-symlink.exp will be skipped on gdbserver board file.
The change is too aggressive.
When the program is running with gdbserver, argv[1] to argv[N] aren't
available, but argv[0] is. Fortunately, argv0-symlink.exp only
requires argv[0]. argv0-symlink.exp can be run with gdbserver board
file, as what we do now.
What we need to check is whether argv[0] is available, so I add a new
proc gdb_has_argv0 to do so by starting a program, and check
argc/argv[0] to see whether argv[0] is available.
Dan fixed the similar problem by checking noargs, which is too strong.
https://sourceware.org/ml/gdb-patches/2010-02/msg00398.html as a
result, the test is skipped on gdbserver. This patch fixed it too.
gdb/testsuite:
2014-10-18 Yao Qi <yao@codesourcery.com>
* gdb.base/argv0-symlink.exp: Check argv[0] value if
gdb_has_argv0 return true.
* gdb.guile/scm-value.exp (test_value_in_inferior): Don't
check [target_info exists noargs], check [gdb_has_argv0]
instead.
* gdb.python/py-value.exp (test_value_in_inferior): Likewise.
* lib/gdb.exp (gdb_has_argv0, gdb_has_argv0_1): New
procedures.
2014-10-14 09:40:15 +02:00
|
|
|
|
# Return true if argv[0] is available.
|
|
|
|
|
|
|
|
|
|
gdb_caching_proc gdb_has_argv0 {
|
|
|
|
|
set result 0
|
|
|
|
|
|
2018-09-05 11:11:32 +02:00
|
|
|
|
# Compile and execute a test program to check whether argv[0] is available.
|
|
|
|
|
gdb_simple_compile has_argv0 {
|
Skip testing argv[0] on target argv[0] isn't available
I see the following two fails on arm-none-eabi target, because argv[0]
isn't available.
print argv[0]^M
$1 = 0x1f78 "/dev/null"^M
(gdb) FAIL: gdb.base/argv0-symlink.exp: kept file symbolic link name
print argv[0]^M
$1 = 0x1f78 "/dev/null"^M
(gdb) FAIL: gdb.base/argv0-symlink.exp: kept directory symbolic link name
My first thought is to check [target_info exists noargs], and skip the
test if it returns true. However, noargs is set in gdbserver board
files, so argv0-symlink.exp will be skipped on gdbserver board file.
The change is too aggressive.
When the program is running with gdbserver, argv[1] to argv[N] aren't
available, but argv[0] is. Fortunately, argv0-symlink.exp only
requires argv[0]. argv0-symlink.exp can be run with gdbserver board
file, as what we do now.
What we need to check is whether argv[0] is available, so I add a new
proc gdb_has_argv0 to do so by starting a program, and check
argc/argv[0] to see whether argv[0] is available.
Dan fixed the similar problem by checking noargs, which is too strong.
https://sourceware.org/ml/gdb-patches/2010-02/msg00398.html as a
result, the test is skipped on gdbserver. This patch fixed it too.
gdb/testsuite:
2014-10-18 Yao Qi <yao@codesourcery.com>
* gdb.base/argv0-symlink.exp: Check argv[0] value if
gdb_has_argv0 return true.
* gdb.guile/scm-value.exp (test_value_in_inferior): Don't
check [target_info exists noargs], check [gdb_has_argv0]
instead.
* gdb.python/py-value.exp (test_value_in_inferior): Likewise.
* lib/gdb.exp (gdb_has_argv0, gdb_has_argv0_1): New
procedures.
2014-10-14 09:40:15 +02:00
|
|
|
|
int main (int argc, char **argv) {
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
2018-09-05 11:11:32 +02:00
|
|
|
|
} executable
|
Skip testing argv[0] on target argv[0] isn't available
I see the following two fails on arm-none-eabi target, because argv[0]
isn't available.
print argv[0]^M
$1 = 0x1f78 "/dev/null"^M
(gdb) FAIL: gdb.base/argv0-symlink.exp: kept file symbolic link name
print argv[0]^M
$1 = 0x1f78 "/dev/null"^M
(gdb) FAIL: gdb.base/argv0-symlink.exp: kept directory symbolic link name
My first thought is to check [target_info exists noargs], and skip the
test if it returns true. However, noargs is set in gdbserver board
files, so argv0-symlink.exp will be skipped on gdbserver board file.
The change is too aggressive.
When the program is running with gdbserver, argv[1] to argv[N] aren't
available, but argv[0] is. Fortunately, argv0-symlink.exp only
requires argv[0]. argv0-symlink.exp can be run with gdbserver board
file, as what we do now.
What we need to check is whether argv[0] is available, so I add a new
proc gdb_has_argv0 to do so by starting a program, and check
argc/argv[0] to see whether argv[0] is available.
Dan fixed the similar problem by checking noargs, which is too strong.
https://sourceware.org/ml/gdb-patches/2010-02/msg00398.html as a
result, the test is skipped on gdbserver. This patch fixed it too.
gdb/testsuite:
2014-10-18 Yao Qi <yao@codesourcery.com>
* gdb.base/argv0-symlink.exp: Check argv[0] value if
gdb_has_argv0 return true.
* gdb.guile/scm-value.exp (test_value_in_inferior): Don't
check [target_info exists noargs], check [gdb_has_argv0]
instead.
* gdb.python/py-value.exp (test_value_in_inferior): Likewise.
* lib/gdb.exp (gdb_has_argv0, gdb_has_argv0_1): New
procedures.
2014-10-14 09:40:15 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Helper proc.
|
|
|
|
|
proc gdb_has_argv0_1 { exe } {
|
|
|
|
|
global srcdir subdir
|
|
|
|
|
global gdb_prompt hex
|
|
|
|
|
|
|
|
|
|
gdb_exit
|
|
|
|
|
gdb_start
|
|
|
|
|
gdb_reinitialize_dir $srcdir/$subdir
|
|
|
|
|
gdb_load "$exe"
|
|
|
|
|
|
|
|
|
|
# Set breakpoint on main.
|
|
|
|
|
gdb_test_multiple "break main" "break main" {
|
|
|
|
|
-re "Breakpoint.*${gdb_prompt} $" {
|
|
|
|
|
}
|
|
|
|
|
-re "${gdb_prompt} $" {
|
|
|
|
|
return 0
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# Run to main.
|
|
|
|
|
gdb_run_cmd
|
|
|
|
|
gdb_test_multiple "" "run to main" {
|
|
|
|
|
-re "Breakpoint.*${gdb_prompt} $" {
|
|
|
|
|
}
|
|
|
|
|
-re "${gdb_prompt} $" {
|
|
|
|
|
return 0
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-01-11 22:12:16 +01:00
|
|
|
|
set old_elements "200"
|
|
|
|
|
set test "show print elements"
|
|
|
|
|
gdb_test_multiple $test $test {
|
|
|
|
|
-re "Limit on string chars or array elements to print is (\[^\r\n\]+)\\.\r\n$gdb_prompt $" {
|
|
|
|
|
set old_elements $expect_out(1,string)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
set old_repeats "200"
|
|
|
|
|
set test "show print repeats"
|
|
|
|
|
gdb_test_multiple $test $test {
|
|
|
|
|
-re "Threshold for repeated print elements is (\[^\r\n\]+)\\.\r\n$gdb_prompt $" {
|
|
|
|
|
set old_repeats $expect_out(1,string)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
gdb_test_no_output "set print elements unlimited" ""
|
|
|
|
|
gdb_test_no_output "set print repeats unlimited" ""
|
|
|
|
|
|
|
|
|
|
set retval 0
|
Skip testing argv[0] on target argv[0] isn't available
I see the following two fails on arm-none-eabi target, because argv[0]
isn't available.
print argv[0]^M
$1 = 0x1f78 "/dev/null"^M
(gdb) FAIL: gdb.base/argv0-symlink.exp: kept file symbolic link name
print argv[0]^M
$1 = 0x1f78 "/dev/null"^M
(gdb) FAIL: gdb.base/argv0-symlink.exp: kept directory symbolic link name
My first thought is to check [target_info exists noargs], and skip the
test if it returns true. However, noargs is set in gdbserver board
files, so argv0-symlink.exp will be skipped on gdbserver board file.
The change is too aggressive.
When the program is running with gdbserver, argv[1] to argv[N] aren't
available, but argv[0] is. Fortunately, argv0-symlink.exp only
requires argv[0]. argv0-symlink.exp can be run with gdbserver board
file, as what we do now.
What we need to check is whether argv[0] is available, so I add a new
proc gdb_has_argv0 to do so by starting a program, and check
argc/argv[0] to see whether argv[0] is available.
Dan fixed the similar problem by checking noargs, which is too strong.
https://sourceware.org/ml/gdb-patches/2010-02/msg00398.html as a
result, the test is skipped on gdbserver. This patch fixed it too.
gdb/testsuite:
2014-10-18 Yao Qi <yao@codesourcery.com>
* gdb.base/argv0-symlink.exp: Check argv[0] value if
gdb_has_argv0 return true.
* gdb.guile/scm-value.exp (test_value_in_inferior): Don't
check [target_info exists noargs], check [gdb_has_argv0]
instead.
* gdb.python/py-value.exp (test_value_in_inferior): Likewise.
* lib/gdb.exp (gdb_has_argv0, gdb_has_argv0_1): New
procedures.
2014-10-14 09:40:15 +02:00
|
|
|
|
# Check whether argc is 1.
|
|
|
|
|
gdb_test_multiple "p argc" "p argc" {
|
|
|
|
|
-re " = 1\r\n${gdb_prompt} $" {
|
|
|
|
|
|
|
|
|
|
gdb_test_multiple "p argv\[0\]" "p argv\[0\]" {
|
|
|
|
|
-re " = $hex \".*[file tail $exe]\"\r\n${gdb_prompt} $" {
|
2016-01-11 22:12:16 +01:00
|
|
|
|
set retval 1
|
Skip testing argv[0] on target argv[0] isn't available
I see the following two fails on arm-none-eabi target, because argv[0]
isn't available.
print argv[0]^M
$1 = 0x1f78 "/dev/null"^M
(gdb) FAIL: gdb.base/argv0-symlink.exp: kept file symbolic link name
print argv[0]^M
$1 = 0x1f78 "/dev/null"^M
(gdb) FAIL: gdb.base/argv0-symlink.exp: kept directory symbolic link name
My first thought is to check [target_info exists noargs], and skip the
test if it returns true. However, noargs is set in gdbserver board
files, so argv0-symlink.exp will be skipped on gdbserver board file.
The change is too aggressive.
When the program is running with gdbserver, argv[1] to argv[N] aren't
available, but argv[0] is. Fortunately, argv0-symlink.exp only
requires argv[0]. argv0-symlink.exp can be run with gdbserver board
file, as what we do now.
What we need to check is whether argv[0] is available, so I add a new
proc gdb_has_argv0 to do so by starting a program, and check
argc/argv[0] to see whether argv[0] is available.
Dan fixed the similar problem by checking noargs, which is too strong.
https://sourceware.org/ml/gdb-patches/2010-02/msg00398.html as a
result, the test is skipped on gdbserver. This patch fixed it too.
gdb/testsuite:
2014-10-18 Yao Qi <yao@codesourcery.com>
* gdb.base/argv0-symlink.exp: Check argv[0] value if
gdb_has_argv0 return true.
* gdb.guile/scm-value.exp (test_value_in_inferior): Don't
check [target_info exists noargs], check [gdb_has_argv0]
instead.
* gdb.python/py-value.exp (test_value_in_inferior): Likewise.
* lib/gdb.exp (gdb_has_argv0, gdb_has_argv0_1): New
procedures.
2014-10-14 09:40:15 +02:00
|
|
|
|
}
|
|
|
|
|
-re "${gdb_prompt} $" {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
-re "${gdb_prompt} $" {
|
|
|
|
|
}
|
|
|
|
|
}
|
2016-01-11 22:12:16 +01:00
|
|
|
|
|
|
|
|
|
gdb_test_no_output "set print elements $old_elements" ""
|
|
|
|
|
gdb_test_no_output "set print repeats $old_repeats" ""
|
|
|
|
|
|
|
|
|
|
return $retval
|
Skip testing argv[0] on target argv[0] isn't available
I see the following two fails on arm-none-eabi target, because argv[0]
isn't available.
print argv[0]^M
$1 = 0x1f78 "/dev/null"^M
(gdb) FAIL: gdb.base/argv0-symlink.exp: kept file symbolic link name
print argv[0]^M
$1 = 0x1f78 "/dev/null"^M
(gdb) FAIL: gdb.base/argv0-symlink.exp: kept directory symbolic link name
My first thought is to check [target_info exists noargs], and skip the
test if it returns true. However, noargs is set in gdbserver board
files, so argv0-symlink.exp will be skipped on gdbserver board file.
The change is too aggressive.
When the program is running with gdbserver, argv[1] to argv[N] aren't
available, but argv[0] is. Fortunately, argv0-symlink.exp only
requires argv[0]. argv0-symlink.exp can be run with gdbserver board
file, as what we do now.
What we need to check is whether argv[0] is available, so I add a new
proc gdb_has_argv0 to do so by starting a program, and check
argc/argv[0] to see whether argv[0] is available.
Dan fixed the similar problem by checking noargs, which is too strong.
https://sourceware.org/ml/gdb-patches/2010-02/msg00398.html as a
result, the test is skipped on gdbserver. This patch fixed it too.
gdb/testsuite:
2014-10-18 Yao Qi <yao@codesourcery.com>
* gdb.base/argv0-symlink.exp: Check argv[0] value if
gdb_has_argv0 return true.
* gdb.guile/scm-value.exp (test_value_in_inferior): Don't
check [target_info exists noargs], check [gdb_has_argv0]
instead.
* gdb.python/py-value.exp (test_value_in_inferior): Likewise.
* lib/gdb.exp (gdb_has_argv0, gdb_has_argv0_1): New
procedures.
2014-10-14 09:40:15 +02:00
|
|
|
|
}
|
|
|
|
|
|
2018-09-05 11:11:32 +02:00
|
|
|
|
set result [gdb_has_argv0_1 $obj]
|
Skip testing argv[0] on target argv[0] isn't available
I see the following two fails on arm-none-eabi target, because argv[0]
isn't available.
print argv[0]^M
$1 = 0x1f78 "/dev/null"^M
(gdb) FAIL: gdb.base/argv0-symlink.exp: kept file symbolic link name
print argv[0]^M
$1 = 0x1f78 "/dev/null"^M
(gdb) FAIL: gdb.base/argv0-symlink.exp: kept directory symbolic link name
My first thought is to check [target_info exists noargs], and skip the
test if it returns true. However, noargs is set in gdbserver board
files, so argv0-symlink.exp will be skipped on gdbserver board file.
The change is too aggressive.
When the program is running with gdbserver, argv[1] to argv[N] aren't
available, but argv[0] is. Fortunately, argv0-symlink.exp only
requires argv[0]. argv0-symlink.exp can be run with gdbserver board
file, as what we do now.
What we need to check is whether argv[0] is available, so I add a new
proc gdb_has_argv0 to do so by starting a program, and check
argc/argv[0] to see whether argv[0] is available.
Dan fixed the similar problem by checking noargs, which is too strong.
https://sourceware.org/ml/gdb-patches/2010-02/msg00398.html as a
result, the test is skipped on gdbserver. This patch fixed it too.
gdb/testsuite:
2014-10-18 Yao Qi <yao@codesourcery.com>
* gdb.base/argv0-symlink.exp: Check argv[0] value if
gdb_has_argv0 return true.
* gdb.guile/scm-value.exp (test_value_in_inferior): Don't
check [target_info exists noargs], check [gdb_has_argv0]
instead.
* gdb.python/py-value.exp (test_value_in_inferior): Likewise.
* lib/gdb.exp (gdb_has_argv0, gdb_has_argv0_1): New
procedures.
2014-10-14 09:40:15 +02:00
|
|
|
|
|
|
|
|
|
gdb_exit
|
2018-09-05 11:11:32 +02:00
|
|
|
|
file delete $obj
|
Skip testing argv[0] on target argv[0] isn't available
I see the following two fails on arm-none-eabi target, because argv[0]
isn't available.
print argv[0]^M
$1 = 0x1f78 "/dev/null"^M
(gdb) FAIL: gdb.base/argv0-symlink.exp: kept file symbolic link name
print argv[0]^M
$1 = 0x1f78 "/dev/null"^M
(gdb) FAIL: gdb.base/argv0-symlink.exp: kept directory symbolic link name
My first thought is to check [target_info exists noargs], and skip the
test if it returns true. However, noargs is set in gdbserver board
files, so argv0-symlink.exp will be skipped on gdbserver board file.
The change is too aggressive.
When the program is running with gdbserver, argv[1] to argv[N] aren't
available, but argv[0] is. Fortunately, argv0-symlink.exp only
requires argv[0]. argv0-symlink.exp can be run with gdbserver board
file, as what we do now.
What we need to check is whether argv[0] is available, so I add a new
proc gdb_has_argv0 to do so by starting a program, and check
argc/argv[0] to see whether argv[0] is available.
Dan fixed the similar problem by checking noargs, which is too strong.
https://sourceware.org/ml/gdb-patches/2010-02/msg00398.html as a
result, the test is skipped on gdbserver. This patch fixed it too.
gdb/testsuite:
2014-10-18 Yao Qi <yao@codesourcery.com>
* gdb.base/argv0-symlink.exp: Check argv[0] value if
gdb_has_argv0 return true.
* gdb.guile/scm-value.exp (test_value_in_inferior): Don't
check [target_info exists noargs], check [gdb_has_argv0]
instead.
* gdb.python/py-value.exp (test_value_in_inferior): Likewise.
* lib/gdb.exp (gdb_has_argv0, gdb_has_argv0_1): New
procedures.
2014-10-14 09:40:15 +02:00
|
|
|
|
|
|
|
|
|
if { !$result
|
|
|
|
|
&& ([istarget *-*-linux*]
|
|
|
|
|
|| [istarget *-*-freebsd*] || [istarget *-*-kfreebsd*]
|
|
|
|
|
|| [istarget *-*-netbsd*] || [istarget *-*-knetbsd*]
|
|
|
|
|
|| [istarget *-*-openbsd*]
|
|
|
|
|
|| [istarget *-*-darwin*]
|
|
|
|
|
|| [istarget *-*-solaris*]
|
|
|
|
|
|| [istarget *-*-aix*]
|
|
|
|
|
|| [istarget *-*-gnu*]
|
|
|
|
|
|| [istarget *-*-cygwin*] || [istarget *-*-mingw32*]
|
|
|
|
|
|| [istarget *-*-*djgpp*] || [istarget *-*-go32*]
|
|
|
|
|
|| [istarget *-wince-pe] || [istarget *-*-mingw32ce*]
|
|
|
|
|
|| [istarget *-*-symbianelf*]
|
|
|
|
|
|| [istarget *-*-osf*]
|
|
|
|
|
|| [istarget *-*-dicos*]
|
|
|
|
|
|| [istarget *-*-nto*]
|
|
|
|
|
|| [istarget *-*-*vms*]
|
|
|
|
|
|| [istarget *-*-lynx*178]) } {
|
|
|
|
|
fail "argv\[0\] should be available on this target"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return $result
|
|
|
|
|
}
|
|
|
|
|
|
2004-01-12 18:20:41 +01:00
|
|
|
|
# Note: the procedure gdb_gnu_strip_debug will produce an executable called
|
|
|
|
|
# ${binfile}.dbglnk, which is just like the executable ($binfile) but without
|
|
|
|
|
# the debuginfo. Instead $binfile has a .gnu_debuglink section which contains
|
2010-05-02 11:08:59 +02:00
|
|
|
|
# the name of a debuginfo only file. This file will be stored in the same
|
|
|
|
|
# subdirectory.
|
2004-01-12 18:20:41 +01:00
|
|
|
|
|
|
|
|
|
# Functions for separate debug info testing
|
|
|
|
|
|
|
|
|
|
# starting with an executable:
|
|
|
|
|
# foo --> original executable
|
|
|
|
|
|
|
|
|
|
# at the end of the process we have:
|
|
|
|
|
# foo.stripped --> foo w/o debug info
|
2010-05-02 11:08:59 +02:00
|
|
|
|
# foo.debug --> foo's debug info
|
2004-01-12 18:20:41 +01:00
|
|
|
|
# foo --> like foo, but with a new .gnu_debuglink section pointing to foo.debug.
|
|
|
|
|
|
2014-12-04 20:32:24 +01:00
|
|
|
|
# Fetch the build id from the file.
|
|
|
|
|
# Returns "" if there is none.
|
|
|
|
|
|
|
|
|
|
proc get_build_id { filename } {
|
2015-04-07 21:49:08 +02:00
|
|
|
|
if { ([istarget "*-*-mingw*"]
|
|
|
|
|
|| [istarget *-*-cygwin*]) } {
|
|
|
|
|
set objdump_program [gdb_find_objdump]
|
|
|
|
|
set result [catch {set data [exec $objdump_program -p $filename | grep signature | cut "-d " -f4]} output]
|
|
|
|
|
verbose "result is $result"
|
|
|
|
|
verbose "output is $output"
|
|
|
|
|
if {$result == 1} {
|
|
|
|
|
return ""
|
|
|
|
|
}
|
|
|
|
|
return $data
|
2015-06-17 18:03:03 +02:00
|
|
|
|
} else {
|
2015-04-07 21:49:08 +02:00
|
|
|
|
set tmp [standard_output_file "${filename}-tmp"]
|
|
|
|
|
set objcopy_program [gdb_find_objcopy]
|
|
|
|
|
set result [catch "exec $objcopy_program -j .note.gnu.build-id -O binary $filename $tmp" output]
|
|
|
|
|
verbose "result is $result"
|
|
|
|
|
verbose "output is $output"
|
|
|
|
|
if {$result == 1} {
|
|
|
|
|
return ""
|
|
|
|
|
}
|
|
|
|
|
set fi [open $tmp]
|
|
|
|
|
fconfigure $fi -translation binary
|
|
|
|
|
# Skip the NOTE header.
|
|
|
|
|
read $fi 16
|
|
|
|
|
set data [read $fi]
|
|
|
|
|
close $fi
|
|
|
|
|
file delete $tmp
|
|
|
|
|
if ![string compare $data ""] then {
|
|
|
|
|
return ""
|
|
|
|
|
}
|
|
|
|
|
# Convert it to hex.
|
|
|
|
|
binary scan $data H* data
|
|
|
|
|
return $data
|
2007-09-01 10:16:16 +02:00
|
|
|
|
}
|
2014-12-04 20:32:24 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# Return the build-id hex string (usually 160 bits as 40 hex characters)
|
|
|
|
|
# converted to the form: .build-id/ab/cdef1234...89.debug
|
|
|
|
|
# Return "" if no build-id found.
|
|
|
|
|
proc build_id_debug_filename_get { filename } {
|
|
|
|
|
set data [get_build_id $filename]
|
|
|
|
|
if { $data == "" } {
|
|
|
|
|
return ""
|
|
|
|
|
}
|
2010-02-18 00:07:24 +01:00
|
|
|
|
regsub {^..} $data {\0/} data
|
gdb/testsuite/
* config/monitor.exp (gdb_target_cmd): Remove semicolon after
'return'.
(gdb_target_monitor, gdb_load): Likewise.
* config/sid.exp (gdb_load): Likewise.
* config/slite.exp (gdb_load): Likewise.
* config/vx.exp (gdb_start, spawn_vxgdb): Likewise.
* gdb.ada/arrayidx.exp, gdb.ada/null_array.exp: Likewise.
* gdb.arch/mips-octeon-bbit.exp (single_step): Likewise.
(single_step_until): Likewise.
* gdb.arch/powerpc-d128-regs.exp: Likewise.
* gdb.arch/system-gcore.exp: Likewise.
* gdb.base/bigcore.exp (extract_heap): Likewise.
* gdb.base/break-on-linker-gcd-function.exp: Likewise.
* gdb.base/call-ar-st.exp: Likewise.
* gdb.base/call-rt-st.exp: Likewise.
* gdb.base/call-sc.exp, gdb.base/call-strs.exp: Likewise.
* gdb.base/callfuncs.exp, gdb.base/completion.exp: Likewise.
* gdb.base/condbreak.exp, gdb.base/constvars.exp: Likewise.
* gdb.base/corefile.exp: Likewise.
* gdb.base/dbx.exp (gdb_file_cmd): Likewise.
* gdb.base/exprs.exp, gdb.base/fileio.exp: Likewise.
* gdb.base/fixsection.exp: Likewise.
* gdb.base/funcargs.exp: Likewise.
* gdb.base/gcore-buffer-overflow.exp: Likewise.
* gdb.base/gcore-relro.exp: Likewise.
* gdb.base/gcore.exp, gdb.base/gdb11530.exp: Likewise.
* gdb.base/gdb11531.exp, gdb.base/gnu-ifunc.exp: Likewise.
* gdb.base/info-os.exp, gdb.base/info-proc.exp: Likewise.
* gdb.base/interp.exp, gdb.base/langs.exp:: Likewise.
* gdb.base/list.exp: Likewise.
(set_listsize): Likewise.
* gdb.base/logical.exp, gdb.base/mips_pro.exp: Likewise.
* gdb.base/miscexprs.exp, gdb.base/nodebug.exp: Likewise.
* gdb.base/opaque.exp, gdb.base/pointers.exp: Likewise.
* gdb.base/psymtab.exp, gdb.base/ptype.exp: Likewise.
* gdb.base/relational.exp, gdb.base/scope.exp: Likewise.
* gdb.base/setvar.exp: Likewise.
(test_set): Likewise.
* gdb.base/signals.exp, gdb.base/sizeof.exp: Likewise.
* gdb.base/solib-overlap.exp: Likewise.
* gdb.base/store.exp, gdb.base/structs.exp: Likewise.
* gdb.base/structs2.exp, gdb.base/volatile.exp: Likewise.
* gdb.base/watchpoint.exp (initialize): Likewise.
(test_simple_watchpoint): Likewise.
(test_disabling_watchpoints): Likewise.
(test_watchpoint_triggered_in_syscall): Likewise.
* gdb.base/whatis.exp, gdb.cp/ambiguous.exp: Likewise.
* gdb.cp/casts.exp, gdb.cp/ctti.exp: Likewise.
* gdb.cp/namespace.exp, gdb.cp/nsdecl.exp: Likewise.
* gdb.cp/psmang.exp, gdb.dwarf2/dw2-ranges.exp: Likewise.
* gdb.hp/gdb.aCC/optimize.exp: Likewise.
* gdb.hp/gdb.aCC/watch-cmd.exp: Likewise.
* gdb.hp/gdb.base-hp/callfwmall.exp: Likewise.
* gdb.hp/gdb.base-hp/pxdb.exp: Likewise.
* gdb.hp/gdb.compat/xdb1.exp: Likewise.
* gdb.hp/gdb.compat/xdb2.exp: Likewise.
* gdb.hp/gdb.compat/xdb3.exp: Likewise.
* gdb.hp/gdb.defects/bs14602.exp: Likewise.
* gdb.hp/gdb.defects/solib-d.exp: Likewise.
* gdb.mi/gdb792.exp: Likewise.
* gdb.mi/mi-inheritance-syntax-error.exp: Likewise.
* gdb.mi/mi-logging.exp, gdb.mi/mi-var-cp.exp : Likewise.
* gdb.mi/mi-var-rtti.exp, gdb.python/py-type.exp: Likewise.
* gdb.threads/gcore-thread.exp: Likewise.
(load_core): Likewise.
* gdb.threads/pthreads.exp (all_threads_running): Likewise.
(test_startup, check_control_c): Likewise.
* gdb.threads/sigstep-threads.exp: Likewise.
* gdb.threads/thread_check.exp: Likewise.
* gdb.trace/backtrace.exp, gdb.trace/change-loc.exp: Likewise.
* gdb.trace/circ.exp (run_trace_experiment): Likewise.
(set_a_tracepoint, trace_buffer_normal): Likewise.
(gdb_trace_circular_tests): Likewise.
* gdb.trace/collection.exp: Likewise.
* gdb.trace/disconnected-tracing.exp: Likewise.
* gdb.trace/infotrace.exp: Likewise.
* gdb.trace/mi-traceframe-changed.exp: Likewise.
* gdb.trace/mi-tracepoint-changed.exp: Likewise.
* gdb.trace/mi-tsv-changed.exp (test_create_delete_modify_tsv): Likewise.
* gdb.trace/packetlen.exp, gdb.trace/passc-dyn.exp: Likewise.
* gdb.trace/pending.exp, gdb.trace/report.exp: Likewise.
* gdb.trace/stap-trace.exp: Likewise.
* gdb.trace/status-stop.exp,gdb.trace/strace.exp: Likewise.
* gdb.trace/tfind.exp, gdb.trace/trace-break.exp: Likewise.
* gdb.trace/trace-buffer-size.exp: Likewise.
* gdb.trace/tspeed.exp, gdb.trace/tsv.exp: Likewise.
* gdb.trace/unavailable.exp: Likewise.
* gdb.trace/while-dyn.exp: Likewise.
* lib/fortran.exp (set_lang_fortran): Likewise.
* lib/gdb.exp (default_gdb_version, gdb_start_cmd): Likewise.
(gdb_breakpoint, gdb_reinitialize_dir): Likewise.
(default_gdb_start, get_compiler_info): Likewise.
(gdb_compile, gdb_compile_objc, gdb_reload, gdb_init): Likewise.
(get_debug_format, setup_xfail_format): Likewise.
(rerun_to_main, gdb_skip_float_test): Likewise.
(build_id_debug_filename_get, get_remotetimeout): Likewise.
* lib/java.exp (set_lang_java): Likewise.
* lib/mi-support.exp (default_mi_gdb_start): Likewise.
(mi_gdb_reinitialize_dir, mi_gdb_target_cmd): Likewise.
(mi_gdb_file_cmd, mi_gdb_test): Likewise.
(mi_run_cmd_full, mi_expect_interrupt): Likewise.
* lib/objc.exp (set_lang_objc): Likewise.
* lib/pascal.exp (set_lang_pascal): Likewise.
* lib/prompt.exp (default_prompt_gdb_start): Likewise.
* lib/trace-support.exp (gdb_trace_setactions, gdb_tfind_test): Likewise.
(gdb_readexpr, gdb_gettpnum, gdb_find_recursion_test_baseline): Likewise.
2013-03-14 14:34:06 +01:00
|
|
|
|
return ".build-id/${data}.debug"
|
2007-09-01 10:16:16 +02:00
|
|
|
|
}
|
|
|
|
|
|
2006-10-17 22:17:45 +02:00
|
|
|
|
# Create stripped files for DEST, replacing it. If ARGS is passed, it is a
|
|
|
|
|
# list of optional flags. The only currently supported flag is no-main,
|
|
|
|
|
# which removes the symbol entry for main from the separate debug file.
|
2010-04-23 01:15:43 +02:00
|
|
|
|
#
|
|
|
|
|
# Function returns zero on success. Function will return non-zero failure code
|
|
|
|
|
# on some targets not supporting separate debug info (such as i386-msdos).
|
2004-01-12 18:20:41 +01:00
|
|
|
|
|
2006-10-17 22:17:45 +02:00
|
|
|
|
proc gdb_gnu_strip_debug { dest args } {
|
|
|
|
|
|
2010-05-02 11:08:59 +02:00
|
|
|
|
# Use the first separate debug info file location searched by GDB so the
|
|
|
|
|
# run cannot be broken by some stale file searched with higher precedence.
|
|
|
|
|
set debug_file "${dest}.debug"
|
|
|
|
|
|
2007-03-27 19:59:38 +02:00
|
|
|
|
set strip_to_file_program [transform strip]
|
2013-09-20 23:47:06 +02:00
|
|
|
|
set objcopy_program [gdb_find_objcopy]
|
2004-01-12 18:20:41 +01:00
|
|
|
|
|
|
|
|
|
set debug_link [file tail $debug_file]
|
|
|
|
|
set stripped_file "${dest}.stripped"
|
|
|
|
|
|
|
|
|
|
# Get rid of the debug info, and store result in stripped_file
|
|
|
|
|
# something like gdb/testsuite/gdb.base/blah.stripped.
|
|
|
|
|
set result [catch "exec $strip_to_file_program --strip-debug ${dest} -o ${stripped_file}" output]
|
|
|
|
|
verbose "result is $result"
|
|
|
|
|
verbose "output is $output"
|
|
|
|
|
if {$result == 1} {
|
|
|
|
|
return 1
|
|
|
|
|
}
|
|
|
|
|
|
2010-01-08 23:59:47 +01:00
|
|
|
|
# Workaround PR binutils/10802:
|
|
|
|
|
# Preserve the 'x' bit also for PIEs (Position Independent Executables).
|
|
|
|
|
set perm [file attributes ${dest} -permissions]
|
|
|
|
|
file attributes ${stripped_file} -permissions $perm
|
|
|
|
|
|
2004-01-12 18:20:41 +01:00
|
|
|
|
# Get rid of everything but the debug info, and store result in debug_file
|
|
|
|
|
# This will be in the .debug subdirectory, see above.
|
|
|
|
|
set result [catch "exec $strip_to_file_program --only-keep-debug ${dest} -o ${debug_file}" output]
|
|
|
|
|
verbose "result is $result"
|
|
|
|
|
verbose "output is $output"
|
|
|
|
|
if {$result == 1} {
|
|
|
|
|
return 1
|
|
|
|
|
}
|
|
|
|
|
|
2006-10-17 22:17:45 +02:00
|
|
|
|
# If no-main is passed, strip the symbol for main from the separate
|
|
|
|
|
# file. This is to simulate the behavior of elfutils's eu-strip, which
|
|
|
|
|
# leaves the symtab in the original file only. There's no way to get
|
|
|
|
|
# objcopy or strip to remove the symbol table without also removing the
|
|
|
|
|
# debugging sections, so this is as close as we can get.
|
|
|
|
|
if { [llength $args] == 1 && [lindex $args 0] == "no-main" } {
|
|
|
|
|
set result [catch "exec $objcopy_program -N main ${debug_file} ${debug_file}-tmp" output]
|
|
|
|
|
verbose "result is $result"
|
|
|
|
|
verbose "output is $output"
|
|
|
|
|
if {$result == 1} {
|
|
|
|
|
return 1
|
|
|
|
|
}
|
|
|
|
|
file delete "${debug_file}"
|
|
|
|
|
file rename "${debug_file}-tmp" "${debug_file}"
|
|
|
|
|
}
|
|
|
|
|
|
2004-01-12 18:20:41 +01:00
|
|
|
|
# Link the two previous output files together, adding the .gnu_debuglink
|
|
|
|
|
# section to the stripped_file, containing a pointer to the debug_file,
|
|
|
|
|
# save the new file in dest.
|
|
|
|
|
# This will be the regular executable filename, in the usual location.
|
|
|
|
|
set result [catch "exec $objcopy_program --add-gnu-debuglink=${debug_file} ${stripped_file} ${dest}" output]
|
|
|
|
|
verbose "result is $result"
|
|
|
|
|
verbose "output is $output"
|
|
|
|
|
if {$result == 1} {
|
|
|
|
|
return 1
|
|
|
|
|
}
|
|
|
|
|
|
2010-01-08 23:59:47 +01:00
|
|
|
|
# Workaround PR binutils/10802:
|
|
|
|
|
# Preserve the 'x' bit also for PIEs (Position Independent Executables).
|
|
|
|
|
set perm [file attributes ${stripped_file} -permissions]
|
|
|
|
|
file attributes ${dest} -permissions $perm
|
|
|
|
|
|
|
|
|
|
return 0
|
2004-01-12 18:20:41 +01:00
|
|
|
|
}
|
|
|
|
|
|
2006-11-10 17:58:53 +01:00
|
|
|
|
# Test the output of GDB_COMMAND matches the pattern obtained
|
|
|
|
|
# by concatenating all elements of EXPECTED_LINES. This makes
|
|
|
|
|
# it possible to split otherwise very long string into pieces.
|
2019-06-03 21:50:22 +02:00
|
|
|
|
# If third argument TESTNAME is not empty, it's used as the name of the
|
2006-11-10 17:58:53 +01:00
|
|
|
|
# test to be printed on pass/fail.
|
2019-06-03 21:50:22 +02:00
|
|
|
|
proc help_test_raw { gdb_command expected_lines {testname {}} } {
|
2006-11-10 17:58:53 +01:00
|
|
|
|
set expected_output [join $expected_lines ""]
|
2019-10-31 23:03:25 +01:00
|
|
|
|
if {$testname != {}} {
|
|
|
|
|
gdb_test "${gdb_command}" "${expected_output}" $testname
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
gdb_test "${gdb_command}" "${expected_output}"
|
2006-11-10 17:58:53 +01:00
|
|
|
|
}
|
|
|
|
|
|
2019-06-03 21:50:22 +02:00
|
|
|
|
# A regexp that matches the end of help CLASS|PREFIX_COMMAND
|
|
|
|
|
set help_list_trailer {
|
|
|
|
|
"Type \"apropos word\" to search for commands related to \"word\"\.[\r\n]+"
|
|
|
|
|
"Type \"apropos -v word\" for full documentation of commands related to \"word\"\.[\r\n]+"
|
|
|
|
|
"Command name abbreviations are allowed if unambiguous\."
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# Test the output of "help COMMAND_CLASS". EXPECTED_INITIAL_LINES
|
2006-11-10 17:58:53 +01:00
|
|
|
|
# are regular expressions that should match the beginning of output,
|
2019-06-03 21:50:22 +02:00
|
|
|
|
# before the list of commands in that class.
|
|
|
|
|
# LIST_OF_COMMANDS are regular expressions that should match the
|
|
|
|
|
# list of commands in that class. If empty, the command list will be
|
|
|
|
|
# matched automatically. The presence of standard epilogue will be tested
|
|
|
|
|
# automatically.
|
|
|
|
|
# If last argument TESTNAME is not empty, it's used as the name of the
|
|
|
|
|
# test to be printed on pass/fail.
|
2015-06-30 23:20:47 +02:00
|
|
|
|
# Notice that the '[' and ']' characters don't need to be escaped for strings
|
|
|
|
|
# wrapped in {} braces.
|
2019-06-03 21:50:22 +02:00
|
|
|
|
proc test_class_help { command_class expected_initial_lines {list_of_commands {}} {testname {}} } {
|
|
|
|
|
global help_list_trailer
|
|
|
|
|
if {[llength $list_of_commands]>0} {
|
|
|
|
|
set l_list_of_commands {"List of commands:[\r\n]+[\r\n]+"}
|
|
|
|
|
set l_list_of_commands [concat $l_list_of_commands $list_of_commands]
|
|
|
|
|
set l_list_of_commands [concat $l_list_of_commands {"[\r\n]+[\r\n]+"}]
|
|
|
|
|
} else {
|
|
|
|
|
set l_list_of_commands {"List of commands\:.*[\r\n]+"}
|
|
|
|
|
}
|
2006-11-10 17:58:53 +01:00
|
|
|
|
set l_stock_body {
|
2015-06-30 23:20:47 +02:00
|
|
|
|
"Type \"help\" followed by command name for full documentation\.[\r\n]+"
|
2006-11-10 17:58:53 +01:00
|
|
|
|
}
|
2019-06-03 21:50:22 +02:00
|
|
|
|
set l_entire_body [concat $expected_initial_lines $l_list_of_commands \
|
|
|
|
|
$l_stock_body $help_list_trailer]
|
2006-11-10 17:58:53 +01:00
|
|
|
|
|
2019-06-03 21:50:22 +02:00
|
|
|
|
help_test_raw "help ${command_class}" $l_entire_body $testname
|
2006-11-10 17:58:53 +01:00
|
|
|
|
}
|
|
|
|
|
|
2019-06-03 21:50:22 +02:00
|
|
|
|
# Like test_class_help but specialised to test "help user-defined".
|
|
|
|
|
proc test_user_defined_class_help { {list_of_commands {}} {testname {}} } {
|
|
|
|
|
test_class_help "user-defined" {
|
|
|
|
|
"User-defined commands\.[\r\n]+"
|
|
|
|
|
"The commands in this class are those defined by the user\.[\r\n]+"
|
|
|
|
|
"Use the \"define\" command to define a command\.[\r\n]+"
|
|
|
|
|
} $list_of_commands $testname
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2006-11-10 17:58:53 +01:00
|
|
|
|
# COMMAND_LIST should have either one element -- command to test, or
|
|
|
|
|
# two elements -- abbreviated command to test, and full command the first
|
|
|
|
|
# element is abbreviation of.
|
|
|
|
|
# The command must be a prefix command. EXPECTED_INITIAL_LINES
|
|
|
|
|
# are regular expressions that should match the beginning of output,
|
|
|
|
|
# before the list of subcommands. The presence of
|
|
|
|
|
# subcommand list and standard epilogue will be tested automatically.
|
|
|
|
|
proc test_prefix_command_help { command_list expected_initial_lines args } {
|
2019-06-03 21:50:22 +02:00
|
|
|
|
global help_list_trailer
|
2006-11-10 17:58:53 +01:00
|
|
|
|
set command [lindex $command_list 0]
|
|
|
|
|
if {[llength $command_list]>1} {
|
|
|
|
|
set full_command [lindex $command_list 1]
|
|
|
|
|
} else {
|
|
|
|
|
set full_command $command
|
|
|
|
|
}
|
|
|
|
|
# Use 'list' and not just {} because we want variables to
|
|
|
|
|
# be expanded in this list.
|
|
|
|
|
set l_stock_body [list\
|
|
|
|
|
"List of $full_command subcommands\:.*\[\r\n\]+"\
|
2019-06-03 21:50:22 +02:00
|
|
|
|
"Type \"help $full_command\" followed by $full_command subcommand name for full documentation\.\[\r\n\]+"]
|
|
|
|
|
set l_entire_body [concat $expected_initial_lines $l_stock_body $help_list_trailer]
|
2006-11-10 17:58:53 +01:00
|
|
|
|
if {[llength $args]>0} {
|
|
|
|
|
help_test_raw "help ${command}" $l_entire_body [lindex $args 0]
|
|
|
|
|
} else {
|
|
|
|
|
help_test_raw "help ${command}" $l_entire_body
|
|
|
|
|
}
|
|
|
|
|
}
|
2008-04-07 18:32:44 +02:00
|
|
|
|
|
2012-07-12 17:09:41 +02:00
|
|
|
|
# Build executable named EXECUTABLE from specifications that allow
|
|
|
|
|
# different options to be passed to different sub-compilations.
|
|
|
|
|
# TESTNAME is the name of the test; this is passed to 'untested' if
|
|
|
|
|
# something fails.
|
2013-04-15 22:37:37 +02:00
|
|
|
|
# OPTIONS is passed to the final link, using gdb_compile. If OPTIONS
|
|
|
|
|
# contains the option "pthreads", then gdb_compile_pthreads is used.
|
2012-07-12 17:09:41 +02:00
|
|
|
|
# ARGS is a flat list of source specifications, of the form:
|
|
|
|
|
# { SOURCE1 OPTIONS1 [ SOURCE2 OPTIONS2 ]... }
|
|
|
|
|
# Each SOURCE is compiled to an object file using its OPTIONS,
|
|
|
|
|
# using gdb_compile.
|
|
|
|
|
# Returns 0 on success, -1 on failure.
|
|
|
|
|
proc build_executable_from_specs {testname executable options args} {
|
2008-04-07 18:32:44 +02:00
|
|
|
|
global subdir
|
|
|
|
|
global srcdir
|
|
|
|
|
|
2012-06-22 18:39:11 +02:00
|
|
|
|
set binfile [standard_output_file $executable]
|
2008-04-07 18:32:44 +02:00
|
|
|
|
|
2010-07-30 21:59:42 +02:00
|
|
|
|
set info_options ""
|
|
|
|
|
if { [lsearch -exact $options "c++"] >= 0 } {
|
|
|
|
|
set info_options "c++"
|
|
|
|
|
}
|
2012-06-21 22:46:25 +02:00
|
|
|
|
if [get_compiler_info ${info_options}] {
|
2008-04-07 18:32:44 +02:00
|
|
|
|
return -1
|
|
|
|
|
}
|
2013-06-04 15:23:32 +02:00
|
|
|
|
|
|
|
|
|
set func gdb_compile
|
2019-08-22 04:32:12 +02:00
|
|
|
|
set func_index [lsearch -regexp $options {^(pthreads|shlib|shlib_pthreads|openmp)$}]
|
2013-06-04 15:23:32 +02:00
|
|
|
|
if {$func_index != -1} {
|
|
|
|
|
set func "${func}_[lindex $options $func_index]"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# gdb_compile_shlib and gdb_compile_shlib_pthreads do not use the 3rd
|
|
|
|
|
# parameter. They also requires $sources while gdb_compile and
|
|
|
|
|
# gdb_compile_pthreads require $objects. Moreover they ignore any options.
|
|
|
|
|
if [string match gdb_compile_shlib* $func] {
|
|
|
|
|
set sources_path {}
|
|
|
|
|
foreach {s local_options} $args {
|
2014-03-07 11:23:42 +01:00
|
|
|
|
if { [regexp "^/" "$s"] } then {
|
|
|
|
|
lappend sources_path "$s"
|
|
|
|
|
} else {
|
|
|
|
|
lappend sources_path "$srcdir/$subdir/$s"
|
|
|
|
|
}
|
2013-06-04 15:23:32 +02:00
|
|
|
|
}
|
|
|
|
|
set ret [$func $sources_path "${binfile}" $options]
|
2016-04-27 03:38:43 +02:00
|
|
|
|
} elseif {[lsearch -exact $options rust] != -1} {
|
|
|
|
|
set sources_path {}
|
|
|
|
|
foreach {s local_options} $args {
|
|
|
|
|
if { [regexp "^/" "$s"] } then {
|
|
|
|
|
lappend sources_path "$s"
|
|
|
|
|
} else {
|
|
|
|
|
lappend sources_path "$srcdir/$subdir/$s"
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
set ret [gdb_compile_rust $sources_path "${binfile}" $options]
|
2013-06-04 15:23:32 +02:00
|
|
|
|
} else {
|
|
|
|
|
set objects {}
|
|
|
|
|
set i 0
|
|
|
|
|
foreach {s local_options} $args {
|
2014-03-07 11:23:42 +01:00
|
|
|
|
if { ! [regexp "^/" "$s"] } then {
|
|
|
|
|
set s "$srcdir/$subdir/$s"
|
|
|
|
|
}
|
2019-08-22 04:32:12 +02:00
|
|
|
|
if { [$func "${s}" "${binfile}${i}.o" object $local_options] != "" } {
|
2013-06-04 15:23:32 +02:00
|
|
|
|
untested $testname
|
|
|
|
|
return -1
|
|
|
|
|
}
|
|
|
|
|
lappend objects "${binfile}${i}.o"
|
|
|
|
|
incr i
|
|
|
|
|
}
|
|
|
|
|
set ret [$func $objects "${binfile}" executable $options]
|
|
|
|
|
}
|
|
|
|
|
if { $ret != "" } {
|
|
|
|
|
untested $testname
|
|
|
|
|
return -1
|
|
|
|
|
}
|
|
|
|
|
|
2008-04-07 18:32:44 +02:00
|
|
|
|
return 0
|
|
|
|
|
}
|
|
|
|
|
|
2012-07-12 17:09:41 +02:00
|
|
|
|
# Build executable named EXECUTABLE, from SOURCES. If SOURCES are not
|
|
|
|
|
# provided, uses $EXECUTABLE.c. The TESTNAME paramer is the name of test
|
|
|
|
|
# to pass to untested, if something is wrong. OPTIONS are passed
|
|
|
|
|
# to gdb_compile directly.
|
|
|
|
|
proc build_executable { testname executable {sources ""} {options {debug}} } {
|
|
|
|
|
if {[llength $sources]==0} {
|
|
|
|
|
set sources ${executable}.c
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
set arglist [list $testname $executable $options]
|
|
|
|
|
foreach source $sources {
|
|
|
|
|
lappend arglist $source $options
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return [eval build_executable_from_specs $arglist]
|
|
|
|
|
}
|
|
|
|
|
|
2015-07-25 00:35:12 +02:00
|
|
|
|
# Starts fresh GDB binary and loads an optional executable into GDB.
|
|
|
|
|
# Usage: clean_restart [executable]
|
|
|
|
|
# EXECUTABLE is the basename of the binary.
|
|
|
|
|
|
|
|
|
|
proc clean_restart { args } {
|
2008-04-07 18:32:44 +02:00
|
|
|
|
global srcdir
|
|
|
|
|
global subdir
|
2015-07-25 00:35:12 +02:00
|
|
|
|
|
|
|
|
|
if { [llength $args] > 1 } {
|
|
|
|
|
error "bad number of args: [llength $args]"
|
|
|
|
|
}
|
2008-04-07 18:32:44 +02:00
|
|
|
|
|
|
|
|
|
gdb_exit
|
|
|
|
|
gdb_start
|
|
|
|
|
gdb_reinitialize_dir $srcdir/$subdir
|
2015-07-25 00:35:12 +02:00
|
|
|
|
|
|
|
|
|
if { [llength $args] >= 1 } {
|
|
|
|
|
set executable [lindex $args 0]
|
|
|
|
|
set binfile [standard_output_file ${executable}]
|
|
|
|
|
gdb_load ${binfile}
|
|
|
|
|
}
|
2008-04-07 18:32:44 +02:00
|
|
|
|
}
|
|
|
|
|
|
2012-07-12 17:09:41 +02:00
|
|
|
|
# Prepares for testing by calling build_executable_full, then
|
|
|
|
|
# clean_restart.
|
|
|
|
|
# TESTNAME is the name of the test.
|
|
|
|
|
# Each element in ARGS is a list of the form
|
|
|
|
|
# { EXECUTABLE OPTIONS SOURCE_SPEC... }
|
|
|
|
|
# These are passed to build_executable_from_specs, which see.
|
|
|
|
|
# The last EXECUTABLE is passed to clean_restart.
|
|
|
|
|
# Returns 0 on success, non-zero on failure.
|
|
|
|
|
proc prepare_for_testing_full {testname args} {
|
|
|
|
|
foreach spec $args {
|
|
|
|
|
if {[eval build_executable_from_specs [list $testname] $spec] == -1} {
|
|
|
|
|
return -1
|
|
|
|
|
}
|
|
|
|
|
set executable [lindex $spec 0]
|
|
|
|
|
}
|
|
|
|
|
clean_restart $executable
|
|
|
|
|
return 0
|
|
|
|
|
}
|
|
|
|
|
|
2008-04-07 18:32:44 +02:00
|
|
|
|
# Prepares for testing, by calling build_executable, and then clean_restart.
|
|
|
|
|
# Please refer to build_executable for parameter description.
|
|
|
|
|
proc prepare_for_testing { testname executable {sources ""} {options {debug}}} {
|
|
|
|
|
|
2008-06-25 17:52:15 +02:00
|
|
|
|
if {[build_executable $testname $executable $sources $options] == -1} {
|
2008-04-07 18:32:44 +02:00
|
|
|
|
return -1
|
|
|
|
|
}
|
|
|
|
|
clean_restart $executable
|
|
|
|
|
|
|
|
|
|
return 0
|
|
|
|
|
}
|
2009-02-13 17:13:47 +01:00
|
|
|
|
|
2017-03-06 19:24:38 +01:00
|
|
|
|
# Retrieve the value of EXP in the inferior, represented in format
|
|
|
|
|
# specified in FMT (using "printFMT"). DEFAULT is used as fallback if
|
|
|
|
|
# print fails. TEST is the test message to use. It can be omitted,
|
|
|
|
|
# in which case a test message is built from EXP.
|
|
|
|
|
|
|
|
|
|
proc get_valueof { fmt exp default {test ""} } {
|
2009-02-13 17:13:47 +01:00
|
|
|
|
global gdb_prompt
|
|
|
|
|
|
2017-03-06 19:24:38 +01:00
|
|
|
|
if {$test == "" } {
|
|
|
|
|
set test "get valueof \"${exp}\""
|
|
|
|
|
}
|
|
|
|
|
|
2009-02-13 17:13:47 +01:00
|
|
|
|
set val ${default}
|
|
|
|
|
gdb_test_multiple "print${fmt} ${exp}" "$test" {
|
2017-08-12 10:33:00 +02:00
|
|
|
|
-re "\\$\[0-9\]* = (\[^\r\n\]*)\[\r\n\]*$gdb_prompt $" {
|
2009-02-14 00:37:24 +01:00
|
|
|
|
set val $expect_out(1,string)
|
2018-10-31 16:33:46 +01:00
|
|
|
|
pass "$test"
|
2009-02-14 00:37:24 +01:00
|
|
|
|
}
|
|
|
|
|
timeout {
|
|
|
|
|
fail "$test (timeout)"
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return ${val}
|
|
|
|
|
}
|
|
|
|
|
|
2017-03-06 19:24:38 +01:00
|
|
|
|
# Retrieve the value of EXP in the inferior, as a signed decimal value
|
|
|
|
|
# (using "print /d"). DEFAULT is used as fallback if print fails.
|
|
|
|
|
# TEST is the test message to use. It can be omitted, in which case
|
|
|
|
|
# a test message is built from EXP.
|
|
|
|
|
|
|
|
|
|
proc get_integer_valueof { exp default {test ""} } {
|
2009-02-14 00:37:24 +01:00
|
|
|
|
global gdb_prompt
|
|
|
|
|
|
2017-03-06 19:24:38 +01:00
|
|
|
|
if {$test == ""} {
|
|
|
|
|
set test "get integer valueof \"${exp}\""
|
|
|
|
|
}
|
|
|
|
|
|
2009-02-14 00:37:24 +01:00
|
|
|
|
set val ${default}
|
|
|
|
|
gdb_test_multiple "print /d ${exp}" "$test" {
|
2009-02-13 17:13:47 +01:00
|
|
|
|
-re "\\$\[0-9\]* = (\[-\]*\[0-9\]*).*$gdb_prompt $" {
|
|
|
|
|
set val $expect_out(1,string)
|
2017-10-10 21:10:25 +02:00
|
|
|
|
pass "$test"
|
2009-02-13 17:13:47 +01:00
|
|
|
|
}
|
|
|
|
|
timeout {
|
2009-02-14 00:37:24 +01:00
|
|
|
|
fail "$test (timeout)"
|
2009-02-13 17:13:47 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return ${val}
|
|
|
|
|
}
|
|
|
|
|
|
Extend JIT-reader test and fix GDB problems that exposes
The jit-reader.exp test isn't really exercising the jit-reader's
unwinder API at all. This commit address that, and then fixes GDB
problems exposed.
- The custom JIT reader provided for the jit-reader.exp testcase
always rejects the jitted function's frame...
This is because the custom JIT reader in the testcase never ever
sets state->code_begin/end, so the bounds check in
gdb.base/jitreader.c:unwind_frame:
if (this_ip >= state->code_end || this_ip < state->code_begin)
return GDB_FAIL;
tends to fail, unless you're "lucky" (because it references
uninitialized data).
The result is that GDB is always actually using a built-in unwinder
for the jitted function.
- The provided unwinder doesn't do anything that GDB's built-in
unwinder can't do.
IOW, we can't really tell whether the JIT reader's unwinder is
working or not.
I fixed that by making the jitted function mangle its own stack
pointer with a xor, and then teaching the jit unwinder to demangle
it back (another xor). So now "backtrace" with GDB's built-in
unwinder fails while with the jit unwinder, it succeeds.
- GDB crashes after unloading the JIT reader, and flushing frames...
I made the testcase use the "flushregs" command after unloading the
JIT reader, to force the JIT frames to be flushed. However, that
crashes GDB...
When reinit_frame_cache tears down a frame's cache, it calls its
unwinder's dealloc_cache method, which for JIT frames ends up in
jit.c:jit_dealloc_cache. This function calls each of the frame's
gdb_reg_value's "free" pointer:
for (i = 0; i < gdbarch_num_regs (frame_arch); i++)
if (priv_data->registers[i] && priv_data->registers[i]->free)
priv_data->registers[i]->free (priv_data->registers[i]);
and the problem is these gdb_reg_value instances have been returned
by the JIT reader that has been already unloaded, and their "free"
function pointers likely point to functions in the DSO that has
already been unloaded...
A fix for that could be to call reinit_frame_cache in
jit_reader_unload_command _before_ unloading the jit reader DSO so
that the jit reader is given a chance to clean up the gdb_reg_values
before it is unloaded. However, the fix for the point below makes
this unnecessary, because it stops jit.c from keeping around
gdb_reg_values in the first place.
- However, it still makes sense to clear the frame cache when loading
or unloading a JIT unwinder.
This makes testing a JIT unwinder a bit simpler.
- Not only the frame cache actually -- gdb is not unloading the
jit-registered objfiles when the JIT reader is unloaded, and not
loading the already-registered descriptors when a JIT reader is
loaded.
The new test exercises unloading the jit reader, loading it back
again, and then making sure the JIT reader's unwinder works again.
Without the unload/re-load of already-read descriptors, the newly
loaded JIT would have no idea where the new function is, because
it's stored at symbol read time.
- I added a couple "info frame" calls to the test, and that
crashes GDB...
The problem is that jit_frame_prev_register assumes it'll only be
called for raw registers, so when it gets a pseudo register number,
the "priv->registers[reg]" access is really an out-of-bounds access.
To fix that, I made jit_frame_prev_register use
gdbarch_pseudo_register_read_value for reading the pseudo-registers.
However, that works with a regcache and we don't have one. To fix
that, I made the JIT unwinder store a regcache in its cache instead
of an array of gdb_reg_value pointers.
gdb/ChangeLog:
2016-07-01 Pedro Alves <palves@redhat.com>
Tom Tromey <tom@tromey.com>
* jit.c (jit_reader_load_command): Call reinit_frame_cache and
jit_inferior_created_hook.
(jit_reader_unload_command): Call reinit_frame_cache and
jit_inferior_exit_hook.
* jit.c (struct jit_unwind_private) <registers>: Delete field.
<regcache>: New field.
(jit_unwind_reg_set_impl): Set the register's value in the
regcache. Free the passed-in gdb_reg_value.
(jit_dealloc_cache): Adjust to free the regcache.
(jit_frame_sniffer): Allocate a regcache instead of an array of
gdb_reg_value pointers.
(jit_frame_this_id): Adjust.
(jit_frame_prev_register): Read raw registers off of the regcache
instead of from the gdb_reg_value pointer array. Use
gdbarch_pseudo_register_read_value to read pseudo registers.
* regcache.c (regcache_raw_set_cached_value): New function,
factored out from ...
(regcache_raw_write): ... here.
* regcache.h (regcache_raw_set_cached_value): Declare.
gdb/testsuite/ChangeLog:
2016-07-01 Pedro Alves <palves@redhat.com>
* gdb.base/jit-reader.exp (info_registers_current_frame): New
procedure.
(jit_reader_test): Test the jit reader's unwinder.
* gdb.base/jithost.c (jit_function_00_code): New global.
(main): Use memcpy to fill in the mmapped code, instead of poking
bytes manually here.
* gdb.base/jitreader.c (enum register_mapping) <AMD64_RBP>: New
value.
(read_debug_info): Save the function's range.
(read_sp): New function.
(unwind_frame): Use it. Also unwind RBP.
(get_frame_id): Use read_sp.
(gdb_init_reader): Use calloc instead of malloc.
* lib/gdb.exp (get_hexadecimal_valueof): Add optional 'test'
parameter. Use gdb_test_multiple.
2016-07-01 12:56:39 +02:00
|
|
|
|
# Retrieve the value of EXP in the inferior, as an hexadecimal value
|
|
|
|
|
# (using "print /x"). DEFAULT is used as fallback if print fails.
|
2017-03-06 19:24:38 +01:00
|
|
|
|
# TEST is the test message to use. It can be omitted, in which case
|
Extend JIT-reader test and fix GDB problems that exposes
The jit-reader.exp test isn't really exercising the jit-reader's
unwinder API at all. This commit address that, and then fixes GDB
problems exposed.
- The custom JIT reader provided for the jit-reader.exp testcase
always rejects the jitted function's frame...
This is because the custom JIT reader in the testcase never ever
sets state->code_begin/end, so the bounds check in
gdb.base/jitreader.c:unwind_frame:
if (this_ip >= state->code_end || this_ip < state->code_begin)
return GDB_FAIL;
tends to fail, unless you're "lucky" (because it references
uninitialized data).
The result is that GDB is always actually using a built-in unwinder
for the jitted function.
- The provided unwinder doesn't do anything that GDB's built-in
unwinder can't do.
IOW, we can't really tell whether the JIT reader's unwinder is
working or not.
I fixed that by making the jitted function mangle its own stack
pointer with a xor, and then teaching the jit unwinder to demangle
it back (another xor). So now "backtrace" with GDB's built-in
unwinder fails while with the jit unwinder, it succeeds.
- GDB crashes after unloading the JIT reader, and flushing frames...
I made the testcase use the "flushregs" command after unloading the
JIT reader, to force the JIT frames to be flushed. However, that
crashes GDB...
When reinit_frame_cache tears down a frame's cache, it calls its
unwinder's dealloc_cache method, which for JIT frames ends up in
jit.c:jit_dealloc_cache. This function calls each of the frame's
gdb_reg_value's "free" pointer:
for (i = 0; i < gdbarch_num_regs (frame_arch); i++)
if (priv_data->registers[i] && priv_data->registers[i]->free)
priv_data->registers[i]->free (priv_data->registers[i]);
and the problem is these gdb_reg_value instances have been returned
by the JIT reader that has been already unloaded, and their "free"
function pointers likely point to functions in the DSO that has
already been unloaded...
A fix for that could be to call reinit_frame_cache in
jit_reader_unload_command _before_ unloading the jit reader DSO so
that the jit reader is given a chance to clean up the gdb_reg_values
before it is unloaded. However, the fix for the point below makes
this unnecessary, because it stops jit.c from keeping around
gdb_reg_values in the first place.
- However, it still makes sense to clear the frame cache when loading
or unloading a JIT unwinder.
This makes testing a JIT unwinder a bit simpler.
- Not only the frame cache actually -- gdb is not unloading the
jit-registered objfiles when the JIT reader is unloaded, and not
loading the already-registered descriptors when a JIT reader is
loaded.
The new test exercises unloading the jit reader, loading it back
again, and then making sure the JIT reader's unwinder works again.
Without the unload/re-load of already-read descriptors, the newly
loaded JIT would have no idea where the new function is, because
it's stored at symbol read time.
- I added a couple "info frame" calls to the test, and that
crashes GDB...
The problem is that jit_frame_prev_register assumes it'll only be
called for raw registers, so when it gets a pseudo register number,
the "priv->registers[reg]" access is really an out-of-bounds access.
To fix that, I made jit_frame_prev_register use
gdbarch_pseudo_register_read_value for reading the pseudo-registers.
However, that works with a regcache and we don't have one. To fix
that, I made the JIT unwinder store a regcache in its cache instead
of an array of gdb_reg_value pointers.
gdb/ChangeLog:
2016-07-01 Pedro Alves <palves@redhat.com>
Tom Tromey <tom@tromey.com>
* jit.c (jit_reader_load_command): Call reinit_frame_cache and
jit_inferior_created_hook.
(jit_reader_unload_command): Call reinit_frame_cache and
jit_inferior_exit_hook.
* jit.c (struct jit_unwind_private) <registers>: Delete field.
<regcache>: New field.
(jit_unwind_reg_set_impl): Set the register's value in the
regcache. Free the passed-in gdb_reg_value.
(jit_dealloc_cache): Adjust to free the regcache.
(jit_frame_sniffer): Allocate a regcache instead of an array of
gdb_reg_value pointers.
(jit_frame_this_id): Adjust.
(jit_frame_prev_register): Read raw registers off of the regcache
instead of from the gdb_reg_value pointer array. Use
gdbarch_pseudo_register_read_value to read pseudo registers.
* regcache.c (regcache_raw_set_cached_value): New function,
factored out from ...
(regcache_raw_write): ... here.
* regcache.h (regcache_raw_set_cached_value): Declare.
gdb/testsuite/ChangeLog:
2016-07-01 Pedro Alves <palves@redhat.com>
* gdb.base/jit-reader.exp (info_registers_current_frame): New
procedure.
(jit_reader_test): Test the jit reader's unwinder.
* gdb.base/jithost.c (jit_function_00_code): New global.
(main): Use memcpy to fill in the mmapped code, instead of poking
bytes manually here.
* gdb.base/jitreader.c (enum register_mapping) <AMD64_RBP>: New
value.
(read_debug_info): Save the function's range.
(read_sp): New function.
(unwind_frame): Use it. Also unwind RBP.
(get_frame_id): Use read_sp.
(gdb_init_reader): Use calloc instead of malloc.
* lib/gdb.exp (get_hexadecimal_valueof): Add optional 'test'
parameter. Use gdb_test_multiple.
2016-07-01 12:56:39 +02:00
|
|
|
|
# a test message is built from EXP.
|
|
|
|
|
|
|
|
|
|
proc get_hexadecimal_valueof { exp default {test ""} } {
|
2009-02-14 01:27:56 +01:00
|
|
|
|
global gdb_prompt
|
Extend JIT-reader test and fix GDB problems that exposes
The jit-reader.exp test isn't really exercising the jit-reader's
unwinder API at all. This commit address that, and then fixes GDB
problems exposed.
- The custom JIT reader provided for the jit-reader.exp testcase
always rejects the jitted function's frame...
This is because the custom JIT reader in the testcase never ever
sets state->code_begin/end, so the bounds check in
gdb.base/jitreader.c:unwind_frame:
if (this_ip >= state->code_end || this_ip < state->code_begin)
return GDB_FAIL;
tends to fail, unless you're "lucky" (because it references
uninitialized data).
The result is that GDB is always actually using a built-in unwinder
for the jitted function.
- The provided unwinder doesn't do anything that GDB's built-in
unwinder can't do.
IOW, we can't really tell whether the JIT reader's unwinder is
working or not.
I fixed that by making the jitted function mangle its own stack
pointer with a xor, and then teaching the jit unwinder to demangle
it back (another xor). So now "backtrace" with GDB's built-in
unwinder fails while with the jit unwinder, it succeeds.
- GDB crashes after unloading the JIT reader, and flushing frames...
I made the testcase use the "flushregs" command after unloading the
JIT reader, to force the JIT frames to be flushed. However, that
crashes GDB...
When reinit_frame_cache tears down a frame's cache, it calls its
unwinder's dealloc_cache method, which for JIT frames ends up in
jit.c:jit_dealloc_cache. This function calls each of the frame's
gdb_reg_value's "free" pointer:
for (i = 0; i < gdbarch_num_regs (frame_arch); i++)
if (priv_data->registers[i] && priv_data->registers[i]->free)
priv_data->registers[i]->free (priv_data->registers[i]);
and the problem is these gdb_reg_value instances have been returned
by the JIT reader that has been already unloaded, and their "free"
function pointers likely point to functions in the DSO that has
already been unloaded...
A fix for that could be to call reinit_frame_cache in
jit_reader_unload_command _before_ unloading the jit reader DSO so
that the jit reader is given a chance to clean up the gdb_reg_values
before it is unloaded. However, the fix for the point below makes
this unnecessary, because it stops jit.c from keeping around
gdb_reg_values in the first place.
- However, it still makes sense to clear the frame cache when loading
or unloading a JIT unwinder.
This makes testing a JIT unwinder a bit simpler.
- Not only the frame cache actually -- gdb is not unloading the
jit-registered objfiles when the JIT reader is unloaded, and not
loading the already-registered descriptors when a JIT reader is
loaded.
The new test exercises unloading the jit reader, loading it back
again, and then making sure the JIT reader's unwinder works again.
Without the unload/re-load of already-read descriptors, the newly
loaded JIT would have no idea where the new function is, because
it's stored at symbol read time.
- I added a couple "info frame" calls to the test, and that
crashes GDB...
The problem is that jit_frame_prev_register assumes it'll only be
called for raw registers, so when it gets a pseudo register number,
the "priv->registers[reg]" access is really an out-of-bounds access.
To fix that, I made jit_frame_prev_register use
gdbarch_pseudo_register_read_value for reading the pseudo-registers.
However, that works with a regcache and we don't have one. To fix
that, I made the JIT unwinder store a regcache in its cache instead
of an array of gdb_reg_value pointers.
gdb/ChangeLog:
2016-07-01 Pedro Alves <palves@redhat.com>
Tom Tromey <tom@tromey.com>
* jit.c (jit_reader_load_command): Call reinit_frame_cache and
jit_inferior_created_hook.
(jit_reader_unload_command): Call reinit_frame_cache and
jit_inferior_exit_hook.
* jit.c (struct jit_unwind_private) <registers>: Delete field.
<regcache>: New field.
(jit_unwind_reg_set_impl): Set the register's value in the
regcache. Free the passed-in gdb_reg_value.
(jit_dealloc_cache): Adjust to free the regcache.
(jit_frame_sniffer): Allocate a regcache instead of an array of
gdb_reg_value pointers.
(jit_frame_this_id): Adjust.
(jit_frame_prev_register): Read raw registers off of the regcache
instead of from the gdb_reg_value pointer array. Use
gdbarch_pseudo_register_read_value to read pseudo registers.
* regcache.c (regcache_raw_set_cached_value): New function,
factored out from ...
(regcache_raw_write): ... here.
* regcache.h (regcache_raw_set_cached_value): Declare.
gdb/testsuite/ChangeLog:
2016-07-01 Pedro Alves <palves@redhat.com>
* gdb.base/jit-reader.exp (info_registers_current_frame): New
procedure.
(jit_reader_test): Test the jit reader's unwinder.
* gdb.base/jithost.c (jit_function_00_code): New global.
(main): Use memcpy to fill in the mmapped code, instead of poking
bytes manually here.
* gdb.base/jitreader.c (enum register_mapping) <AMD64_RBP>: New
value.
(read_debug_info): Save the function's range.
(read_sp): New function.
(unwind_frame): Use it. Also unwind RBP.
(get_frame_id): Use read_sp.
(gdb_init_reader): Use calloc instead of malloc.
* lib/gdb.exp (get_hexadecimal_valueof): Add optional 'test'
parameter. Use gdb_test_multiple.
2016-07-01 12:56:39 +02:00
|
|
|
|
|
|
|
|
|
if {$test == ""} {
|
|
|
|
|
set test "get hexadecimal valueof \"${exp}\""
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
set val ${default}
|
|
|
|
|
gdb_test_multiple "print /x ${exp}" $test {
|
2009-02-14 01:27:56 +01:00
|
|
|
|
-re "\\$\[0-9\]* = (0x\[0-9a-zA-Z\]+).*$gdb_prompt $" {
|
|
|
|
|
set val $expect_out(1,string)
|
|
|
|
|
pass "$test"
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return ${val}
|
|
|
|
|
}
|
2009-02-14 00:37:24 +01:00
|
|
|
|
|
2017-03-06 19:24:38 +01:00
|
|
|
|
# Retrieve the size of TYPE in the inferior, as a decimal value. DEFAULT
|
|
|
|
|
# is used as fallback if print fails. TEST is the test message to use.
|
|
|
|
|
# It can be omitted, in which case a test message is 'sizeof (TYPE)'.
|
|
|
|
|
|
|
|
|
|
proc get_sizeof { type default {test ""} } {
|
|
|
|
|
return [get_integer_valueof "sizeof (${type})" $default $test]
|
2009-02-13 17:13:47 +01:00
|
|
|
|
}
|
|
|
|
|
|
Add Guile as an extension language.
* NEWS: Mention Guile scripting.
* Makefile.in (SUBDIR_GUILE_OBS): New variable.
(SUBDIR_GUILE_SRCS, SUBDIR_GUILE_DEPS): New variables
(SUBDIR_GUILE_LDFLAGS, SUBDIR_GUILE_CFLAGS): New variables.
(INTERNAL_CPPFLAGS): Add GUILE_CPPFLAGS.
(CLIBS): Add GUILE_LIBS.
(install-guile): New rule.
(guile.o): New rule.
(scm-arch.o, scm-auto-load.o, scm-block.o): New rules.
(scm-breakpoint.o, scm-disasm.o, scm-exception.o): New rules.
(scm-frame.o, scm-iterator.o, scm-lazy-string.o): New rules.
(scm-math.o, scm-objfile.o, scm-ports.o): New rules.
(scm-pretty-print.o, scm-safe-call.o, scm-gsmob.o): New rules.
(scm-string.o, scm-symbol.o, scm-symtab.o): New rules.
(scm-type.o, scm-utils.o, scm-value.o): New rules.
* configure.ac: New option --with-guile.
* configure: Regenerate.
* config.in: Regenerate.
* auto-load.c: Remove #include "python/python.h". Add #include
"gdb/section-scripts.h".
(source_section_scripts): Handle Guile scripts.
(_initialize_auto_load): Add name of Guile objfile script to
scripts-directory help text.
* breakpoint.c (condition_command): Tweak comment to include Scheme.
* breakpoint.h (gdbscm_breakpoint_object): Add forward decl.
(struct breakpoint): New member scm_bp_object.
* defs.h (enum command_control_type): New value guile_control.
* cli/cli-cmds.c: Remove #include "python/python.h". Add #include
"extension.h".
(show_user): Update comment.
(_initialize_cli_cmds): Update help text for "show user". Update help
text for max-user-call-depth.
* cli/cli-script.c: Remove #include "python/python.h". Add #include
"extension.h".
(multi_line_command_p): Add guile_control.
(print_command_lines): Handle guile_control.
(execute_control_command, recurse_read_control_structure): Ditto.
(process_next_line): Recognize "guile" commands.
* disasm.c (gdb_disassemble_info): Make non-static.
* disasm.h: #include "dis-asm.h".
(struct gdbarch): Add forward decl.
(gdb_disassemble_info): Declare.
* extension.c: #include "guile/guile.h".
(extension_languages): Add guile.
(get_ext_lang_defn): Handle EXT_LANG_GDB.
* extension.h (enum extension_language): New value EXT_LANG_GUILE.
* gdbtypes.c (get_unsigned_type_max): New function.
(get_signed_type_minmax): New function.
* gdbtypes.h (get_unsigned_type_max): Declare.
(get_signed_type_minmax): Declare.
* guile/README: New file.
* guile/guile-internal.h: New file.
* guile/guile.c: New file.
* guile/guile.h: New file.
* guile/scm-arch.c: New file.
* guile/scm-auto-load.c: New file.
* guile/scm-block.c: New file.
* guile/scm-breakpoint.c: New file.
* guile/scm-disasm.c: New file.
* guile/scm-exception.c: New file.
* guile/scm-frame.c: New file.
* guile/scm-gsmob.c: New file.
* guile/scm-iterator.c: New file.
* guile/scm-lazy-string.c: New file.
* guile/scm-math.c: New file.
* guile/scm-objfile.c: New file.
* guile/scm-ports.c: New file.
* guile/scm-pretty-print.c: New file.
* guile/scm-safe-call.c: New file.
* guile/scm-string.c: New file.
* guile/scm-symbol.c: New file.
* guile/scm-symtab.c: New file.
* guile/scm-type.c: New file.
* guile/scm-utils.c: New file.
* guile/scm-value.c: New file.
* guile/lib/gdb.scm: New file.
* guile/lib/gdb/boot.scm: New file.
* guile/lib/gdb/experimental.scm: New file.
* guile/lib/gdb/init.scm: New file.
* guile/lib/gdb/iterator.scm: New file.
* guile/lib/gdb/printing.scm: New file.
* guile/lib/gdb/types.scm: New file.
* data-directory/Makefile.in (GUILE_SRCDIR): New variable.
(VPATH): Add $(GUILE_SRCDIR).
(GUILE_DIR): New variable.
(GUILE_INSTALL_DIR, GUILE_FILES): New variables.
(all): Add stamp-guile dependency.
(stamp-guile): New rule.
(clean-guile, install-guile, uninstall-guile): New rules.
(install-only): Add install-guile dependency.
(uninstall): Add uninstall-guile dependency.
(clean): Add clean-guile dependency.
doc/
* Makefile.in (GDB_DOC_FILES): Add guile.texi.
* gdb.texinfo (Auto-loading): Add set/show auto-load guile-scripts.
(Extending GDB): New menu entries Guile, Multiple Extension Languages.
(Guile docs): Include guile.texi.
(objfile-gdbdotext file): Add objfile-gdb.scm.
(dotdebug_gdb_scripts section): Mention Guile scripts.
(Multiple Extension Languages): New node.
* guile.texi: New file.
testsuite/
* configure.ac (AC_OUTPUT): Add gdb.guile.
* configure: Regenerate.
* lib/gdb-guile.exp: New file.
* lib/gdb.exp (get_target_charset): New function.
* gdb.base/help.exp: Update expected output from "apropos apropos".
* gdb.guile/Makefile.in: New file.
* gdb.guile/guile.exp: New file.
* gdb.guile/scm-arch.c: New file.
* gdb.guile/scm-arch.exp: New file.
* gdb.guile/scm-block.c: New file.
* gdb.guile/scm-block.exp: New file.
* gdb.guile/scm-breakpoint.c: New file.
* gdb.guile/scm-breakpoint.exp: New file.
* gdb.guile/scm-disasm.c: New file.
* gdb.guile/scm-disasm.exp: New file.
* gdb.guile/scm-equal.c: New file.
* gdb.guile/scm-equal.exp: New file.
* gdb.guile/scm-error.exp: New file.
* gdb.guile/scm-error.scm: New file.
* gdb.guile/scm-frame-args.c: New file.
* gdb.guile/scm-frame-args.exp: New file.
* gdb.guile/scm-frame-args.scm: New file.
* gdb.guile/scm-frame-inline.c: New file.
* gdb.guile/scm-frame-inline.exp: New file.
* gdb.guile/scm-frame.c: New file.
* gdb.guile/scm-frame.exp: New file.
* gdb.guile/scm-generics.exp: New file.
* gdb.guile/scm-gsmob.exp: New file.
* gdb.guile/scm-iterator.c: New file.
* gdb.guile/scm-iterator.exp: New file.
* gdb.guile/scm-math.c: New file.
* gdb.guile/scm-math.exp: New file.
* gdb.guile/scm-objfile-script-gdb.in: New file.
* gdb.guile/scm-objfile-script.c: New file.
* gdb.guile/scm-objfile-script.exp: New file.
* gdb.guile/scm-objfile.c: New file.
* gdb.guile/scm-objfile.exp: New file.
* gdb.guile/scm-ports.exp: New file.
* gdb.guile/scm-pretty-print.c: New file.
* gdb.guile/scm-pretty-print.exp: New file.
* gdb.guile/scm-pretty-print.scm: New file.
* gdb.guile/scm-section-script.c: New file.
* gdb.guile/scm-section-script.exp: New file.
* gdb.guile/scm-section-script.scm: New file.
* gdb.guile/scm-symbol.c: New file.
* gdb.guile/scm-symbol.exp: New file.
* gdb.guile/scm-symtab-2.c: New file.
* gdb.guile/scm-symtab.c: New file.
* gdb.guile/scm-symtab.exp: New file.
* gdb.guile/scm-type.c: New file.
* gdb.guile/scm-type.exp: New file.
* gdb.guile/scm-value-cc.cc: New file.
* gdb.guile/scm-value-cc.exp: New file.
* gdb.guile/scm-value.c: New file.
* gdb.guile/scm-value.exp: New file.
* gdb.guile/source2.scm: New file.
* gdb.guile/types-module.cc: New file.
* gdb.guile/types-module.exp: New file.
2014-02-10 04:40:01 +01:00
|
|
|
|
proc get_target_charset { } {
|
|
|
|
|
global gdb_prompt
|
|
|
|
|
|
|
|
|
|
gdb_test_multiple "show target-charset" "" {
|
|
|
|
|
-re "The target character set is \"auto; currently (\[^\"\]*)\".*$gdb_prompt $" {
|
|
|
|
|
return $expect_out(1,string)
|
|
|
|
|
}
|
|
|
|
|
-re "The target character set is \"(\[^\"\]*)\".*$gdb_prompt $" {
|
|
|
|
|
return $expect_out(1,string)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# Pick a reasonable default.
|
|
|
|
|
warning "Unable to read target-charset."
|
|
|
|
|
return "UTF-8"
|
|
|
|
|
}
|
|
|
|
|
|
2016-10-13 17:08:17 +02:00
|
|
|
|
# Get the address of VAR.
|
|
|
|
|
|
|
|
|
|
proc get_var_address { var } {
|
|
|
|
|
global gdb_prompt hex
|
|
|
|
|
|
|
|
|
|
# Match output like:
|
|
|
|
|
# $1 = (int *) 0x0
|
|
|
|
|
# $5 = (int (*)()) 0
|
|
|
|
|
# $6 = (int (*)()) 0x24 <function_bar>
|
|
|
|
|
|
|
|
|
|
gdb_test_multiple "print &${var}" "get address of ${var}" {
|
|
|
|
|
-re "\\\$\[0-9\]+ = \\(.*\\) (0|$hex)( <${var}>)?\[\r\n\]+${gdb_prompt} $"
|
|
|
|
|
{
|
|
|
|
|
pass "get address of ${var}"
|
|
|
|
|
if { $expect_out(1,string) == "0" } {
|
|
|
|
|
return "0x0"
|
|
|
|
|
} else {
|
|
|
|
|
return $expect_out(1,string)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return ""
|
|
|
|
|
}
|
|
|
|
|
|
2018-05-18 18:45:16 +02:00
|
|
|
|
# Return the frame number for the currently selected frame
|
|
|
|
|
proc get_current_frame_number {{test_name ""}} {
|
|
|
|
|
global gdb_prompt
|
|
|
|
|
|
|
|
|
|
if { $test_name == "" } {
|
|
|
|
|
set test_name "get current frame number"
|
|
|
|
|
}
|
|
|
|
|
set frame_num -1
|
|
|
|
|
gdb_test_multiple "frame" $test_name {
|
|
|
|
|
-re "#(\[0-9\]+) .*$gdb_prompt $" {
|
|
|
|
|
set frame_num $expect_out(1,string)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return $frame_num
|
|
|
|
|
}
|
|
|
|
|
|
2011-07-01 02:19:25 +02:00
|
|
|
|
# Get the current value for remotetimeout and return it.
|
|
|
|
|
proc get_remotetimeout { } {
|
|
|
|
|
global gdb_prompt
|
|
|
|
|
global decimal
|
|
|
|
|
|
|
|
|
|
gdb_test_multiple "show remotetimeout" "" {
|
|
|
|
|
-re "Timeout limit to wait for target to respond is ($decimal).*$gdb_prompt $" {
|
gdb/testsuite/
* config/monitor.exp (gdb_target_cmd): Remove semicolon after
'return'.
(gdb_target_monitor, gdb_load): Likewise.
* config/sid.exp (gdb_load): Likewise.
* config/slite.exp (gdb_load): Likewise.
* config/vx.exp (gdb_start, spawn_vxgdb): Likewise.
* gdb.ada/arrayidx.exp, gdb.ada/null_array.exp: Likewise.
* gdb.arch/mips-octeon-bbit.exp (single_step): Likewise.
(single_step_until): Likewise.
* gdb.arch/powerpc-d128-regs.exp: Likewise.
* gdb.arch/system-gcore.exp: Likewise.
* gdb.base/bigcore.exp (extract_heap): Likewise.
* gdb.base/break-on-linker-gcd-function.exp: Likewise.
* gdb.base/call-ar-st.exp: Likewise.
* gdb.base/call-rt-st.exp: Likewise.
* gdb.base/call-sc.exp, gdb.base/call-strs.exp: Likewise.
* gdb.base/callfuncs.exp, gdb.base/completion.exp: Likewise.
* gdb.base/condbreak.exp, gdb.base/constvars.exp: Likewise.
* gdb.base/corefile.exp: Likewise.
* gdb.base/dbx.exp (gdb_file_cmd): Likewise.
* gdb.base/exprs.exp, gdb.base/fileio.exp: Likewise.
* gdb.base/fixsection.exp: Likewise.
* gdb.base/funcargs.exp: Likewise.
* gdb.base/gcore-buffer-overflow.exp: Likewise.
* gdb.base/gcore-relro.exp: Likewise.
* gdb.base/gcore.exp, gdb.base/gdb11530.exp: Likewise.
* gdb.base/gdb11531.exp, gdb.base/gnu-ifunc.exp: Likewise.
* gdb.base/info-os.exp, gdb.base/info-proc.exp: Likewise.
* gdb.base/interp.exp, gdb.base/langs.exp:: Likewise.
* gdb.base/list.exp: Likewise.
(set_listsize): Likewise.
* gdb.base/logical.exp, gdb.base/mips_pro.exp: Likewise.
* gdb.base/miscexprs.exp, gdb.base/nodebug.exp: Likewise.
* gdb.base/opaque.exp, gdb.base/pointers.exp: Likewise.
* gdb.base/psymtab.exp, gdb.base/ptype.exp: Likewise.
* gdb.base/relational.exp, gdb.base/scope.exp: Likewise.
* gdb.base/setvar.exp: Likewise.
(test_set): Likewise.
* gdb.base/signals.exp, gdb.base/sizeof.exp: Likewise.
* gdb.base/solib-overlap.exp: Likewise.
* gdb.base/store.exp, gdb.base/structs.exp: Likewise.
* gdb.base/structs2.exp, gdb.base/volatile.exp: Likewise.
* gdb.base/watchpoint.exp (initialize): Likewise.
(test_simple_watchpoint): Likewise.
(test_disabling_watchpoints): Likewise.
(test_watchpoint_triggered_in_syscall): Likewise.
* gdb.base/whatis.exp, gdb.cp/ambiguous.exp: Likewise.
* gdb.cp/casts.exp, gdb.cp/ctti.exp: Likewise.
* gdb.cp/namespace.exp, gdb.cp/nsdecl.exp: Likewise.
* gdb.cp/psmang.exp, gdb.dwarf2/dw2-ranges.exp: Likewise.
* gdb.hp/gdb.aCC/optimize.exp: Likewise.
* gdb.hp/gdb.aCC/watch-cmd.exp: Likewise.
* gdb.hp/gdb.base-hp/callfwmall.exp: Likewise.
* gdb.hp/gdb.base-hp/pxdb.exp: Likewise.
* gdb.hp/gdb.compat/xdb1.exp: Likewise.
* gdb.hp/gdb.compat/xdb2.exp: Likewise.
* gdb.hp/gdb.compat/xdb3.exp: Likewise.
* gdb.hp/gdb.defects/bs14602.exp: Likewise.
* gdb.hp/gdb.defects/solib-d.exp: Likewise.
* gdb.mi/gdb792.exp: Likewise.
* gdb.mi/mi-inheritance-syntax-error.exp: Likewise.
* gdb.mi/mi-logging.exp, gdb.mi/mi-var-cp.exp : Likewise.
* gdb.mi/mi-var-rtti.exp, gdb.python/py-type.exp: Likewise.
* gdb.threads/gcore-thread.exp: Likewise.
(load_core): Likewise.
* gdb.threads/pthreads.exp (all_threads_running): Likewise.
(test_startup, check_control_c): Likewise.
* gdb.threads/sigstep-threads.exp: Likewise.
* gdb.threads/thread_check.exp: Likewise.
* gdb.trace/backtrace.exp, gdb.trace/change-loc.exp: Likewise.
* gdb.trace/circ.exp (run_trace_experiment): Likewise.
(set_a_tracepoint, trace_buffer_normal): Likewise.
(gdb_trace_circular_tests): Likewise.
* gdb.trace/collection.exp: Likewise.
* gdb.trace/disconnected-tracing.exp: Likewise.
* gdb.trace/infotrace.exp: Likewise.
* gdb.trace/mi-traceframe-changed.exp: Likewise.
* gdb.trace/mi-tracepoint-changed.exp: Likewise.
* gdb.trace/mi-tsv-changed.exp (test_create_delete_modify_tsv): Likewise.
* gdb.trace/packetlen.exp, gdb.trace/passc-dyn.exp: Likewise.
* gdb.trace/pending.exp, gdb.trace/report.exp: Likewise.
* gdb.trace/stap-trace.exp: Likewise.
* gdb.trace/status-stop.exp,gdb.trace/strace.exp: Likewise.
* gdb.trace/tfind.exp, gdb.trace/trace-break.exp: Likewise.
* gdb.trace/trace-buffer-size.exp: Likewise.
* gdb.trace/tspeed.exp, gdb.trace/tsv.exp: Likewise.
* gdb.trace/unavailable.exp: Likewise.
* gdb.trace/while-dyn.exp: Likewise.
* lib/fortran.exp (set_lang_fortran): Likewise.
* lib/gdb.exp (default_gdb_version, gdb_start_cmd): Likewise.
(gdb_breakpoint, gdb_reinitialize_dir): Likewise.
(default_gdb_start, get_compiler_info): Likewise.
(gdb_compile, gdb_compile_objc, gdb_reload, gdb_init): Likewise.
(get_debug_format, setup_xfail_format): Likewise.
(rerun_to_main, gdb_skip_float_test): Likewise.
(build_id_debug_filename_get, get_remotetimeout): Likewise.
* lib/java.exp (set_lang_java): Likewise.
* lib/mi-support.exp (default_mi_gdb_start): Likewise.
(mi_gdb_reinitialize_dir, mi_gdb_target_cmd): Likewise.
(mi_gdb_file_cmd, mi_gdb_test): Likewise.
(mi_run_cmd_full, mi_expect_interrupt): Likewise.
* lib/objc.exp (set_lang_objc): Likewise.
* lib/pascal.exp (set_lang_pascal): Likewise.
* lib/prompt.exp (default_prompt_gdb_start): Likewise.
* lib/trace-support.exp (gdb_trace_setactions, gdb_tfind_test): Likewise.
(gdb_readexpr, gdb_gettpnum, gdb_find_recursion_test_baseline): Likewise.
2013-03-14 14:34:06 +01:00
|
|
|
|
return $expect_out(1,string)
|
2011-07-01 02:19:25 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# Pick the default that gdb uses
|
|
|
|
|
warning "Unable to read remotetimeout"
|
|
|
|
|
return 300
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# Set the remotetimeout to the specified timeout. Nothing is returned.
|
|
|
|
|
proc set_remotetimeout { timeout } {
|
|
|
|
|
global gdb_prompt
|
|
|
|
|
|
|
|
|
|
gdb_test_multiple "set remotetimeout $timeout" "" {
|
|
|
|
|
-re "$gdb_prompt $" {
|
|
|
|
|
verbose "Set remotetimeout to $timeout\n"
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-06-13 15:20:26 +02:00
|
|
|
|
# Get the target's current endianness and return it.
|
|
|
|
|
proc get_endianness { } {
|
|
|
|
|
global gdb_prompt
|
|
|
|
|
|
|
|
|
|
gdb_test_multiple "show endian" "determine endianness" {
|
|
|
|
|
-re ".* (little|big) endian.*\r\n$gdb_prompt $" {
|
|
|
|
|
# Pass silently.
|
|
|
|
|
return $expect_out(1,string)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return "little"
|
|
|
|
|
}
|
|
|
|
|
|
2013-08-23 20:18:57 +02:00
|
|
|
|
# ROOT and FULL are file names. Returns the relative path from ROOT
|
|
|
|
|
# to FULL. Note that FULL must be in a subdirectory of ROOT.
|
|
|
|
|
# For example, given ROOT = /usr/bin and FULL = /usr/bin/ls, this
|
|
|
|
|
# will return "ls".
|
|
|
|
|
|
|
|
|
|
proc relative_filename {root full} {
|
|
|
|
|
set root_split [file split $root]
|
|
|
|
|
set full_split [file split $full]
|
|
|
|
|
|
|
|
|
|
set len [llength $root_split]
|
|
|
|
|
|
|
|
|
|
if {[eval file join $root_split]
|
|
|
|
|
!= [eval file join [lrange $full_split 0 [expr {$len - 1}]]]} {
|
|
|
|
|
error "$full not a subdir of $root"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return [eval file join [lrange $full_split $len end]]
|
|
|
|
|
}
|
|
|
|
|
|
introduce parallel mode
This introduces parallel mode for the test suite.
It doesn't fully work yet in the sense that if you do a fully parallel
run, you will encounter some file-name clashes, but this has to start
somewhere, and it seemed best to add some infrastructure now, so that
you can follow along and test subsequent patches if you care to.
This patch has two parts.
First, it checks for the GDB_PARALLEL variable. If this is set (say,
on the runtest command line), then the test suite assumes "parallel
mode". In this mode, files are put into a subdirectory named after
the test. That is, for DIR/TEST.exp, the outputs are put into
./outputs/DIR/TEST/.
This first part has various follow-on changes coming in subsequent
patches. This is why the code in this patch also makes "temp" and
"cache" directories.
Second, this adds an "inotify" mode. If you have the inotifywait
command (part of inotify-tools), you can set the GDB_INOTIFY variable.
This will tell the test suite to watch for changes outside of the
allowed output directories.
This mode is useful for debugging the test suite, as it issues a
report whenever a possibly parallel-unsafe file open is done.
2013-08-13 Tom Tromey <tromey@redhat.com>
Yao Qi <yao@codesourcery.com>
* lib/cache.exp (gdb_do_cache): Handle GDB_PARALLEL.
* lib/gdb.exp: Handle GDB_PARALLEL.
(default_gdb_version): Kill inotify_pid if it exists.
(default_gdb_exit): Emit warning if the inotify log is not
empty.
(standard_output_file): Respect GDB_PARALLEL.
(standard_temp_file): Likewise.
(gdb_init): Start inotifywait if requested.
* gdbint.texinfo (Testsuite): Use @table, not @itemize.
Document GDB_PARALLEL and GDB_INOTIFY.
2013-08-13 18:12:04 +02:00
|
|
|
|
# If GDB_PARALLEL exists, then set up the parallel-mode directories.
|
|
|
|
|
if {[info exists GDB_PARALLEL]} {
|
|
|
|
|
if {[is_remote host]} {
|
|
|
|
|
unset GDB_PARALLEL
|
|
|
|
|
} else {
|
2015-08-03 18:17:40 +02:00
|
|
|
|
file mkdir \
|
|
|
|
|
[make_gdb_parallel_path outputs] \
|
|
|
|
|
[make_gdb_parallel_path temp] \
|
|
|
|
|
[make_gdb_parallel_path cache]
|
introduce parallel mode
This introduces parallel mode for the test suite.
It doesn't fully work yet in the sense that if you do a fully parallel
run, you will encounter some file-name clashes, but this has to start
somewhere, and it seemed best to add some infrastructure now, so that
you can follow along and test subsequent patches if you care to.
This patch has two parts.
First, it checks for the GDB_PARALLEL variable. If this is set (say,
on the runtest command line), then the test suite assumes "parallel
mode". In this mode, files are put into a subdirectory named after
the test. That is, for DIR/TEST.exp, the outputs are put into
./outputs/DIR/TEST/.
This first part has various follow-on changes coming in subsequent
patches. This is why the code in this patch also makes "temp" and
"cache" directories.
Second, this adds an "inotify" mode. If you have the inotifywait
command (part of inotify-tools), you can set the GDB_INOTIFY variable.
This will tell the test suite to watch for changes outside of the
allowed output directories.
This mode is useful for debugging the test suite, as it issues a
report whenever a possibly parallel-unsafe file open is done.
2013-08-13 Tom Tromey <tromey@redhat.com>
Yao Qi <yao@codesourcery.com>
* lib/cache.exp (gdb_do_cache): Handle GDB_PARALLEL.
* lib/gdb.exp: Handle GDB_PARALLEL.
(default_gdb_version): Kill inotify_pid if it exists.
(default_gdb_exit): Emit warning if the inotify log is not
empty.
(standard_output_file): Respect GDB_PARALLEL.
(standard_temp_file): Likewise.
(gdb_init): Start inotifywait if requested.
* gdbint.texinfo (Testsuite): Use @table, not @itemize.
Document GDB_PARALLEL and GDB_INOTIFY.
2013-08-13 18:12:04 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2010-01-14 22:12:00 +01:00
|
|
|
|
proc core_find {binfile {deletefiles {}} {arg ""}} {
|
2010-01-09 01:14:11 +01:00
|
|
|
|
global objdir subdir
|
|
|
|
|
|
|
|
|
|
set destcore "$binfile.core"
|
|
|
|
|
file delete $destcore
|
|
|
|
|
|
|
|
|
|
# Create a core file named "$destcore" rather than just "core", to
|
|
|
|
|
# avoid problems with sys admin types that like to regularly prune all
|
|
|
|
|
# files named "core" from the system.
|
|
|
|
|
#
|
|
|
|
|
# Arbitrarily try setting the core size limit to "unlimited" since
|
|
|
|
|
# this does not hurt on systems where the command does not work and
|
|
|
|
|
# allows us to generate a core on systems where it does.
|
|
|
|
|
#
|
|
|
|
|
# Some systems append "core" to the name of the program; others append
|
|
|
|
|
# the name of the program to "core"; still others (like Linux, as of
|
|
|
|
|
# May 2003) create cores named "core.PID". In the latter case, we
|
|
|
|
|
# could have many core files lying around, and it may be difficult to
|
|
|
|
|
# tell which one is ours, so let's run the program in a subdirectory.
|
|
|
|
|
set found 0
|
2012-07-12 18:39:42 +02:00
|
|
|
|
set coredir [standard_output_file coredir.[getpid]]
|
2010-01-09 01:14:11 +01:00
|
|
|
|
file mkdir $coredir
|
2010-01-14 22:12:00 +01:00
|
|
|
|
catch "system \"(cd ${coredir}; ulimit -c unlimited; ${binfile} ${arg}; true) >/dev/null 2>&1\""
|
2010-01-09 01:14:11 +01:00
|
|
|
|
# remote_exec host "${binfile}"
|
|
|
|
|
foreach i "${coredir}/core ${coredir}/core.coremaker.c ${binfile}.core" {
|
|
|
|
|
if [remote_file build exists $i] {
|
|
|
|
|
remote_exec build "mv $i $destcore"
|
|
|
|
|
set found 1
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
# Check for "core.PID".
|
|
|
|
|
if { $found == 0 } {
|
|
|
|
|
set names [glob -nocomplain -directory $coredir core.*]
|
|
|
|
|
if {[llength $names] == 1} {
|
|
|
|
|
set corefile [file join $coredir [lindex $names 0]]
|
|
|
|
|
remote_exec build "mv $corefile $destcore"
|
|
|
|
|
set found 1
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if { $found == 0 } {
|
|
|
|
|
# The braindamaged HPUX shell quits after the ulimit -c above
|
|
|
|
|
# without executing ${binfile}. So we try again without the
|
|
|
|
|
# ulimit here if we didn't find a core file above.
|
|
|
|
|
# Oh, I should mention that any "braindamaged" non-Unix system has
|
|
|
|
|
# the same problem. I like the cd bit too, it's really neat'n stuff.
|
|
|
|
|
catch "system \"(cd ${objdir}/${subdir}; ${binfile}; true) >/dev/null 2>&1\""
|
|
|
|
|
foreach i "${objdir}/${subdir}/core ${objdir}/${subdir}/core.coremaker.c ${binfile}.core" {
|
|
|
|
|
if [remote_file build exists $i] {
|
|
|
|
|
remote_exec build "mv $i $destcore"
|
|
|
|
|
set found 1
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# Try to clean up after ourselves.
|
|
|
|
|
foreach deletefile $deletefiles {
|
|
|
|
|
remote_file build delete [file join $coredir $deletefile]
|
|
|
|
|
}
|
|
|
|
|
remote_exec build "rmdir $coredir"
|
|
|
|
|
|
|
|
|
|
if { $found == 0 } {
|
|
|
|
|
warning "can't generate a core file - core tests suppressed - check ulimit -c"
|
|
|
|
|
return ""
|
|
|
|
|
}
|
|
|
|
|
return $destcore
|
|
|
|
|
}
|
2011-05-24 14:01:22 +02:00
|
|
|
|
|
gdb.dwarf2: Define and use gdb_target_symbol for symbol prefixes
Some of the tests in gdb.dwarf2 which use Dwarf::assemble refer to
(minimal/linker) symbols created in the course of building a small
test program. Some targets use a prefix such as underscore ("_") on
these symbols. Many of the tests in gdb.dwarf2 do not take this into
account. As a consequence, these tests fail to build, resulting
either in failures or untested testcases.
Here is an example from gdb.dwarf2/dw2-regno-invalid.exp:
Dwarf::assemble $asm_file {
cu {} {
compile_unit {
{low_pc main DW_FORM_addr}
{high_pc main+0x10000 DW_FORM_addr}
} {
...
}
For targets which require an underscore prefix on linker symbols,
the two occurrences of "main" would have to have a prepended underscore,
i.e. _main instead of main.
For the above case, a call to the new proc gdb_target_symbol is used
prepend the correct prefix to the symbol. I.e. the above code is
rewritten (as shown in the patch) as follows:
Dwarf::assemble $asm_file {
cu {} {
compile_unit {
{low_pc [gdb_target_symbol main] DW_FORM_addr}
{high_pc [gdb_target_symbol main]+0x10000 DW_FORM_addr}
} {
...
}
I also found it necessary to make an adjustment to lib/dwarf.exp so that
expressions of more than just one list element can be used in DW_TAG_...
constructs. Both atomic-type.exp and dw2-bad-mips-linkage-name.exp require
this new functionality.
gdb/testsuite/ChangeLog:
* lib/gdb.exp (gdb_target_symbol_prefix, gdb_target_symbol):
New procs.
* lib/dwarf.exp (_handle_DW_TAG): Handle attribute values,
representing expressions, of more than one list element.
* gdb.dwarf2/atomic-type.exp (Dwarf::assemble): Use gdb_target_symbol
to prepend linker symbol prefix to f.
* gdb.dwarf2/data-loc.exp (Dwarf::assemble): Likewise, for
table_1 and table_2.
* gdb.dwarf2/dw2-bad-mips-linkage-name.exp (Dwarf::assemble):
Likewise, for f and g.
* gdb.dwarf2/dw2-ifort-parameter.exp (Dwarf::assemble): Likewise,
for ptr.
* gdb.dwarf2/dw2-regno-invalid.exp (Dwarf::assemble): Likewise,
for main.
* gdb.dwarf2/dynarr-ptr.exp (Dwarf::assemble): Likewise, for
table_1_ptr and table_2_ptr.
2015-10-28 19:36:06 +01:00
|
|
|
|
# gdb_target_symbol_prefix compiles a test program and then examines
|
|
|
|
|
# the output from objdump to determine the prefix (such as underscore)
|
|
|
|
|
# for linker symbol prefixes.
|
|
|
|
|
|
|
|
|
|
gdb_caching_proc gdb_target_symbol_prefix {
|
2018-09-05 11:11:32 +02:00
|
|
|
|
# Compile a simple test program...
|
|
|
|
|
set src { int main() { return 0; } }
|
|
|
|
|
if {![gdb_simple_compile target_symbol_prefix $src executable]} {
|
|
|
|
|
return 0
|
gdb.dwarf2: Define and use gdb_target_symbol for symbol prefixes
Some of the tests in gdb.dwarf2 which use Dwarf::assemble refer to
(minimal/linker) symbols created in the course of building a small
test program. Some targets use a prefix such as underscore ("_") on
these symbols. Many of the tests in gdb.dwarf2 do not take this into
account. As a consequence, these tests fail to build, resulting
either in failures or untested testcases.
Here is an example from gdb.dwarf2/dw2-regno-invalid.exp:
Dwarf::assemble $asm_file {
cu {} {
compile_unit {
{low_pc main DW_FORM_addr}
{high_pc main+0x10000 DW_FORM_addr}
} {
...
}
For targets which require an underscore prefix on linker symbols,
the two occurrences of "main" would have to have a prepended underscore,
i.e. _main instead of main.
For the above case, a call to the new proc gdb_target_symbol is used
prepend the correct prefix to the symbol. I.e. the above code is
rewritten (as shown in the patch) as follows:
Dwarf::assemble $asm_file {
cu {} {
compile_unit {
{low_pc [gdb_target_symbol main] DW_FORM_addr}
{high_pc [gdb_target_symbol main]+0x10000 DW_FORM_addr}
} {
...
}
I also found it necessary to make an adjustment to lib/dwarf.exp so that
expressions of more than just one list element can be used in DW_TAG_...
constructs. Both atomic-type.exp and dw2-bad-mips-linkage-name.exp require
this new functionality.
gdb/testsuite/ChangeLog:
* lib/gdb.exp (gdb_target_symbol_prefix, gdb_target_symbol):
New procs.
* lib/dwarf.exp (_handle_DW_TAG): Handle attribute values,
representing expressions, of more than one list element.
* gdb.dwarf2/atomic-type.exp (Dwarf::assemble): Use gdb_target_symbol
to prepend linker symbol prefix to f.
* gdb.dwarf2/data-loc.exp (Dwarf::assemble): Likewise, for
table_1 and table_2.
* gdb.dwarf2/dw2-bad-mips-linkage-name.exp (Dwarf::assemble):
Likewise, for f and g.
* gdb.dwarf2/dw2-ifort-parameter.exp (Dwarf::assemble): Likewise,
for ptr.
* gdb.dwarf2/dw2-regno-invalid.exp (Dwarf::assemble): Likewise,
for main.
* gdb.dwarf2/dynarr-ptr.exp (Dwarf::assemble): Likewise, for
table_1_ptr and table_2_ptr.
2015-10-28 19:36:06 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
set prefix ""
|
|
|
|
|
|
2018-09-05 11:11:32 +02:00
|
|
|
|
set objdump_program [gdb_find_objdump]
|
|
|
|
|
set result [catch "exec $objdump_program --syms $obj" output]
|
gdb.dwarf2: Define and use gdb_target_symbol for symbol prefixes
Some of the tests in gdb.dwarf2 which use Dwarf::assemble refer to
(minimal/linker) symbols created in the course of building a small
test program. Some targets use a prefix such as underscore ("_") on
these symbols. Many of the tests in gdb.dwarf2 do not take this into
account. As a consequence, these tests fail to build, resulting
either in failures or untested testcases.
Here is an example from gdb.dwarf2/dw2-regno-invalid.exp:
Dwarf::assemble $asm_file {
cu {} {
compile_unit {
{low_pc main DW_FORM_addr}
{high_pc main+0x10000 DW_FORM_addr}
} {
...
}
For targets which require an underscore prefix on linker symbols,
the two occurrences of "main" would have to have a prepended underscore,
i.e. _main instead of main.
For the above case, a call to the new proc gdb_target_symbol is used
prepend the correct prefix to the symbol. I.e. the above code is
rewritten (as shown in the patch) as follows:
Dwarf::assemble $asm_file {
cu {} {
compile_unit {
{low_pc [gdb_target_symbol main] DW_FORM_addr}
{high_pc [gdb_target_symbol main]+0x10000 DW_FORM_addr}
} {
...
}
I also found it necessary to make an adjustment to lib/dwarf.exp so that
expressions of more than just one list element can be used in DW_TAG_...
constructs. Both atomic-type.exp and dw2-bad-mips-linkage-name.exp require
this new functionality.
gdb/testsuite/ChangeLog:
* lib/gdb.exp (gdb_target_symbol_prefix, gdb_target_symbol):
New procs.
* lib/dwarf.exp (_handle_DW_TAG): Handle attribute values,
representing expressions, of more than one list element.
* gdb.dwarf2/atomic-type.exp (Dwarf::assemble): Use gdb_target_symbol
to prepend linker symbol prefix to f.
* gdb.dwarf2/data-loc.exp (Dwarf::assemble): Likewise, for
table_1 and table_2.
* gdb.dwarf2/dw2-bad-mips-linkage-name.exp (Dwarf::assemble):
Likewise, for f and g.
* gdb.dwarf2/dw2-ifort-parameter.exp (Dwarf::assemble): Likewise,
for ptr.
* gdb.dwarf2/dw2-regno-invalid.exp (Dwarf::assemble): Likewise,
for main.
* gdb.dwarf2/dynarr-ptr.exp (Dwarf::assemble): Likewise, for
table_1_ptr and table_2_ptr.
2015-10-28 19:36:06 +01:00
|
|
|
|
|
2018-09-05 11:11:32 +02:00
|
|
|
|
if { $result == 0 \
|
|
|
|
|
&& ![regexp -lineanchor \
|
|
|
|
|
{ ([^ a-zA-Z0-9]*)main$} $output dummy prefix] } {
|
|
|
|
|
verbose "gdb_target_symbol_prefix: Could not find main in objdump output; returning null prefix" 2
|
gdb.dwarf2: Define and use gdb_target_symbol for symbol prefixes
Some of the tests in gdb.dwarf2 which use Dwarf::assemble refer to
(minimal/linker) symbols created in the course of building a small
test program. Some targets use a prefix such as underscore ("_") on
these symbols. Many of the tests in gdb.dwarf2 do not take this into
account. As a consequence, these tests fail to build, resulting
either in failures or untested testcases.
Here is an example from gdb.dwarf2/dw2-regno-invalid.exp:
Dwarf::assemble $asm_file {
cu {} {
compile_unit {
{low_pc main DW_FORM_addr}
{high_pc main+0x10000 DW_FORM_addr}
} {
...
}
For targets which require an underscore prefix on linker symbols,
the two occurrences of "main" would have to have a prepended underscore,
i.e. _main instead of main.
For the above case, a call to the new proc gdb_target_symbol is used
prepend the correct prefix to the symbol. I.e. the above code is
rewritten (as shown in the patch) as follows:
Dwarf::assemble $asm_file {
cu {} {
compile_unit {
{low_pc [gdb_target_symbol main] DW_FORM_addr}
{high_pc [gdb_target_symbol main]+0x10000 DW_FORM_addr}
} {
...
}
I also found it necessary to make an adjustment to lib/dwarf.exp so that
expressions of more than just one list element can be used in DW_TAG_...
constructs. Both atomic-type.exp and dw2-bad-mips-linkage-name.exp require
this new functionality.
gdb/testsuite/ChangeLog:
* lib/gdb.exp (gdb_target_symbol_prefix, gdb_target_symbol):
New procs.
* lib/dwarf.exp (_handle_DW_TAG): Handle attribute values,
representing expressions, of more than one list element.
* gdb.dwarf2/atomic-type.exp (Dwarf::assemble): Use gdb_target_symbol
to prepend linker symbol prefix to f.
* gdb.dwarf2/data-loc.exp (Dwarf::assemble): Likewise, for
table_1 and table_2.
* gdb.dwarf2/dw2-bad-mips-linkage-name.exp (Dwarf::assemble):
Likewise, for f and g.
* gdb.dwarf2/dw2-ifort-parameter.exp (Dwarf::assemble): Likewise,
for ptr.
* gdb.dwarf2/dw2-regno-invalid.exp (Dwarf::assemble): Likewise,
for main.
* gdb.dwarf2/dynarr-ptr.exp (Dwarf::assemble): Likewise, for
table_1_ptr and table_2_ptr.
2015-10-28 19:36:06 +01:00
|
|
|
|
}
|
|
|
|
|
|
2018-09-05 11:11:32 +02:00
|
|
|
|
file delete $obj
|
gdb.dwarf2: Define and use gdb_target_symbol for symbol prefixes
Some of the tests in gdb.dwarf2 which use Dwarf::assemble refer to
(minimal/linker) symbols created in the course of building a small
test program. Some targets use a prefix such as underscore ("_") on
these symbols. Many of the tests in gdb.dwarf2 do not take this into
account. As a consequence, these tests fail to build, resulting
either in failures or untested testcases.
Here is an example from gdb.dwarf2/dw2-regno-invalid.exp:
Dwarf::assemble $asm_file {
cu {} {
compile_unit {
{low_pc main DW_FORM_addr}
{high_pc main+0x10000 DW_FORM_addr}
} {
...
}
For targets which require an underscore prefix on linker symbols,
the two occurrences of "main" would have to have a prepended underscore,
i.e. _main instead of main.
For the above case, a call to the new proc gdb_target_symbol is used
prepend the correct prefix to the symbol. I.e. the above code is
rewritten (as shown in the patch) as follows:
Dwarf::assemble $asm_file {
cu {} {
compile_unit {
{low_pc [gdb_target_symbol main] DW_FORM_addr}
{high_pc [gdb_target_symbol main]+0x10000 DW_FORM_addr}
} {
...
}
I also found it necessary to make an adjustment to lib/dwarf.exp so that
expressions of more than just one list element can be used in DW_TAG_...
constructs. Both atomic-type.exp and dw2-bad-mips-linkage-name.exp require
this new functionality.
gdb/testsuite/ChangeLog:
* lib/gdb.exp (gdb_target_symbol_prefix, gdb_target_symbol):
New procs.
* lib/dwarf.exp (_handle_DW_TAG): Handle attribute values,
representing expressions, of more than one list element.
* gdb.dwarf2/atomic-type.exp (Dwarf::assemble): Use gdb_target_symbol
to prepend linker symbol prefix to f.
* gdb.dwarf2/data-loc.exp (Dwarf::assemble): Likewise, for
table_1 and table_2.
* gdb.dwarf2/dw2-bad-mips-linkage-name.exp (Dwarf::assemble):
Likewise, for f and g.
* gdb.dwarf2/dw2-ifort-parameter.exp (Dwarf::assemble): Likewise,
for ptr.
* gdb.dwarf2/dw2-regno-invalid.exp (Dwarf::assemble): Likewise,
for main.
* gdb.dwarf2/dynarr-ptr.exp (Dwarf::assemble): Likewise, for
table_1_ptr and table_2_ptr.
2015-10-28 19:36:06 +01:00
|
|
|
|
|
|
|
|
|
return $prefix
|
|
|
|
|
}
|
|
|
|
|
|
2018-07-03 17:44:08 +02:00
|
|
|
|
# Return 1 if target supports scheduler locking, otherwise return 0.
|
|
|
|
|
|
|
|
|
|
gdb_caching_proc target_supports_scheduler_locking {
|
|
|
|
|
global gdb_prompt
|
|
|
|
|
|
|
|
|
|
set me "gdb_target_supports_scheduler_locking"
|
|
|
|
|
|
2018-09-05 11:11:32 +02:00
|
|
|
|
set src { int main() { return 0; } }
|
|
|
|
|
if {![gdb_simple_compile $me $src executable]} {
|
2018-07-03 17:44:08 +02:00
|
|
|
|
return 0
|
|
|
|
|
}
|
|
|
|
|
|
2018-09-05 11:11:32 +02:00
|
|
|
|
clean_restart $obj
|
2018-10-04 14:10:39 +02:00
|
|
|
|
if ![runto_main] {
|
|
|
|
|
return 0
|
|
|
|
|
}
|
2018-07-03 17:44:08 +02:00
|
|
|
|
|
|
|
|
|
set supports_schedule_locking -1
|
|
|
|
|
set current_schedule_locking_mode ""
|
|
|
|
|
|
|
|
|
|
set test "reading current scheduler-locking mode"
|
|
|
|
|
gdb_test_multiple "show scheduler-locking" $test {
|
|
|
|
|
-re "Mode for locking scheduler during execution is \"(\[\^\"\]*)\".*$gdb_prompt" {
|
|
|
|
|
set current_schedule_locking_mode $expect_out(1,string)
|
|
|
|
|
}
|
|
|
|
|
-re "$gdb_prompt $" {
|
|
|
|
|
set supports_schedule_locking 0
|
|
|
|
|
}
|
|
|
|
|
timeout {
|
|
|
|
|
set supports_schedule_locking 0
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if { $supports_schedule_locking == -1 } {
|
|
|
|
|
set test "checking for scheduler-locking support"
|
|
|
|
|
gdb_test_multiple "set scheduler-locking $current_schedule_locking_mode" $test {
|
|
|
|
|
-re "Target '\[^'\]+' cannot support this command\..*$gdb_prompt $" {
|
|
|
|
|
set supports_schedule_locking 0
|
|
|
|
|
}
|
|
|
|
|
-re "$gdb_prompt $" {
|
|
|
|
|
set supports_schedule_locking 1
|
|
|
|
|
}
|
|
|
|
|
timeout {
|
|
|
|
|
set supports_schedule_locking 0
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if { $supports_schedule_locking == -1 } {
|
|
|
|
|
set supports_schedule_locking 0
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
gdb_exit
|
2018-09-05 11:11:32 +02:00
|
|
|
|
remote_file build delete $obj
|
2018-07-03 17:44:08 +02:00
|
|
|
|
verbose "$me: returning $supports_schedule_locking" 2
|
|
|
|
|
return $supports_schedule_locking
|
|
|
|
|
}
|
|
|
|
|
|
2019-11-09 19:09:41 +01:00
|
|
|
|
# Return 1 if compiler supports use of nested functions. Otherwise,
|
|
|
|
|
# return 0.
|
|
|
|
|
|
|
|
|
|
gdb_caching_proc support_nested_function_tests {
|
|
|
|
|
# Compile a test program containing a nested function
|
|
|
|
|
return [gdb_can_simple_compile nested_func {
|
|
|
|
|
int main () {
|
|
|
|
|
int foo () {
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
return foo ();
|
|
|
|
|
}
|
|
|
|
|
} executable]
|
|
|
|
|
}
|
|
|
|
|
|
gdb.dwarf2: Define and use gdb_target_symbol for symbol prefixes
Some of the tests in gdb.dwarf2 which use Dwarf::assemble refer to
(minimal/linker) symbols created in the course of building a small
test program. Some targets use a prefix such as underscore ("_") on
these symbols. Many of the tests in gdb.dwarf2 do not take this into
account. As a consequence, these tests fail to build, resulting
either in failures or untested testcases.
Here is an example from gdb.dwarf2/dw2-regno-invalid.exp:
Dwarf::assemble $asm_file {
cu {} {
compile_unit {
{low_pc main DW_FORM_addr}
{high_pc main+0x10000 DW_FORM_addr}
} {
...
}
For targets which require an underscore prefix on linker symbols,
the two occurrences of "main" would have to have a prepended underscore,
i.e. _main instead of main.
For the above case, a call to the new proc gdb_target_symbol is used
prepend the correct prefix to the symbol. I.e. the above code is
rewritten (as shown in the patch) as follows:
Dwarf::assemble $asm_file {
cu {} {
compile_unit {
{low_pc [gdb_target_symbol main] DW_FORM_addr}
{high_pc [gdb_target_symbol main]+0x10000 DW_FORM_addr}
} {
...
}
I also found it necessary to make an adjustment to lib/dwarf.exp so that
expressions of more than just one list element can be used in DW_TAG_...
constructs. Both atomic-type.exp and dw2-bad-mips-linkage-name.exp require
this new functionality.
gdb/testsuite/ChangeLog:
* lib/gdb.exp (gdb_target_symbol_prefix, gdb_target_symbol):
New procs.
* lib/dwarf.exp (_handle_DW_TAG): Handle attribute values,
representing expressions, of more than one list element.
* gdb.dwarf2/atomic-type.exp (Dwarf::assemble): Use gdb_target_symbol
to prepend linker symbol prefix to f.
* gdb.dwarf2/data-loc.exp (Dwarf::assemble): Likewise, for
table_1 and table_2.
* gdb.dwarf2/dw2-bad-mips-linkage-name.exp (Dwarf::assemble):
Likewise, for f and g.
* gdb.dwarf2/dw2-ifort-parameter.exp (Dwarf::assemble): Likewise,
for ptr.
* gdb.dwarf2/dw2-regno-invalid.exp (Dwarf::assemble): Likewise,
for main.
* gdb.dwarf2/dynarr-ptr.exp (Dwarf::assemble): Likewise, for
table_1_ptr and table_2_ptr.
2015-10-28 19:36:06 +01:00
|
|
|
|
# gdb_target_symbol returns the provided symbol with the correct prefix
|
|
|
|
|
# prepended. (See gdb_target_symbol_prefix, above.)
|
|
|
|
|
|
|
|
|
|
proc gdb_target_symbol { symbol } {
|
|
|
|
|
set prefix [gdb_target_symbol_prefix]
|
|
|
|
|
return "${prefix}${symbol}"
|
|
|
|
|
}
|
|
|
|
|
|
testsuite: Define and use gdb_target_symbol_prefix_flags_asm.
Some of the source code for the test cases in the GDB testsuite
reside in .S files containing assembly code. These files typically
define a symbol - such as main - which may, depending on the target,
require a prefix such as underscore.
For example, gdb.dwarf2/dw-compdir-oldgcc.S defines the symbol main:
main: .globl main
Some targets, such as rx-elf, require main to have an underscore
prefix. (If it doesn't, a linker error results due to not being able
to find _main required by crt0.o.) So, instead, the above should look
like this for rx-elf and other targets with this same requirement:
_main: .globl _main
This patch defines a new tcl proc in lib/gdb named
gdb_target_symbol_prefix_flags_asm. This proc returns a string
which will - assuming everything else is wired up correctly - cause
-DSYMBOL_PREFIX=_ to be passed on the command line to the compiler.
The test cases are augmented with a macro definition for SYMBOL
as follows:
#define CONCAT1(a, b) CONCAT2(a, b)
#define CONCAT2(a, b) a ## b
#ifdef SYMBOL_PREFIX
# define SYMBOL(str) CONCAT1(SYMBOL_PREFIX, str)
#else
# define SYMBOL(str) str
#endif
Symbols, such as main shown in the example earlier are then wrapped
with SYMBOL like this:
SYMBOL(main): .globl SYMBOL(main)
The net effect will be to add a prefix for those targets which need
it and add no prefix for those targets which do not.
It should be noted that there was already a proc in lib/gdb.exp
called gdb_target_symbol_prefix_flags. It still exists, but has
been significantly rewritten. (There is only one small difference
between the two versions.)
That proc used to explicitly list targets which were known to
require an underscore prefix. This is no longer done; the recently
added proc, gdb_target_symbol_prefix, is now invoked to dynamically
discover whether or not a prefix is required for that particular
target.
The difference between gdb_target_symbol_prefix_flags_asm
and gdb_target_symbol_prefix_flags is that the former returns
a bare prefix while the latter returns the prefix enclosed in
double quotes. I.e. assuming that the discovered prefix is
underscore, gdb_target_symbol_prefix_flags_asm returns:
additional_flags=-DSYMBOL_PREFIX=_
while gdb_target_symbol_prefix_flags returns:
additional_flags=-DSYMBOL_PREFIX="_"
The double-quoted version is not suitable for using with .S files
containing assembly code; there is no way to strip the double quotes
using C preprocessor constructs.
It would be possible to use the bare (non double quoted) version in
C source code. However, the supporting macros become more complicated
and therefore more difficult to maintain.
gdb/testsuite/ChangeLog:
* lib/gdb (gdb_target_symbol_prefix_flags_asm): New proc.
(gdb_target_symbol_prefix_flags): Define in terms of _asm
version.
* gdb.arch/i386-float.exp, gdb.arch/i386-permbkpt.exp,
gdb.dwarf2/dw2-canonicalize-type.exp,
gdb.dwarf2/dw2-compdir-oldgcc.exp, gdb.dwarf2/dw2-minsym-in-cu.exp,
gdb.dwarf2/dw2-op-stack-value.exp, gdb.dwarf2/dw2-unresolved.exp,
gdb.dwarf2/fission-reread.exp, gdb.dwarf2/pr13961.exp: Use flags
provided by gdb_target_symbol_prefix_flags_asm.
* gdb.dwarf2/dw2-canonicalize-type.S, gdb.dwarf2/dw2-compdir-oldgcc.S,
testsuite/gdb.dwarf2/dw2-minsym-in-cu.S,
testsuite/gdb.dwarf2/dw2-unresolved-main.c,
testsuite/gdb.dwarf2/dw2-unresolved.S, gdb.dwarf2/fission-reread.S,
gdb.dwarf2/pr13961.S: Define and use SYMBOL macro (and supporting
macros where needed). Use this macro for symbols which require
the prefix provided by SYMBOL_PREFIX.
2015-11-06 05:40:53 +01:00
|
|
|
|
# gdb_target_symbol_prefix_flags_asm returns a string that can be
|
|
|
|
|
# added to gdb_compile options to define the C-preprocessor macro
|
|
|
|
|
# SYMBOL_PREFIX with a value that can be prepended to symbols
|
|
|
|
|
# for targets which require a prefix, such as underscore.
|
|
|
|
|
#
|
|
|
|
|
# This version (_asm) defines the prefix without double quotes
|
|
|
|
|
# surrounding the prefix. It is used to define the macro
|
|
|
|
|
# SYMBOL_PREFIX for assembly language files. Another version, below,
|
|
|
|
|
# is used for symbols in inline assembler in C/C++ files.
|
|
|
|
|
#
|
|
|
|
|
# The lack of quotes in this version (_asm) makes it possible to
|
|
|
|
|
# define supporting macros in the .S file. (The version which
|
|
|
|
|
# uses quotes for the prefix won't work for such files since it's
|
|
|
|
|
# impossible to define a quote-stripping macro in C.)
|
|
|
|
|
#
|
|
|
|
|
# It's possible to use this version (_asm) for C/C++ source files too,
|
|
|
|
|
# but a string is usually required in such files; providing a version
|
|
|
|
|
# (no _asm) which encloses the prefix with double quotes makes it
|
|
|
|
|
# somewhat easier to define the supporting macros in the test case.
|
|
|
|
|
|
|
|
|
|
proc gdb_target_symbol_prefix_flags_asm {} {
|
|
|
|
|
set prefix [gdb_target_symbol_prefix]
|
|
|
|
|
if {$prefix ne ""} {
|
|
|
|
|
return "additional_flags=-DSYMBOL_PREFIX=$prefix"
|
|
|
|
|
} else {
|
|
|
|
|
return "";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# gdb_target_symbol_prefix_flags returns the same string as
|
|
|
|
|
# gdb_target_symbol_prefix_flags_asm, above, but with the prefix
|
|
|
|
|
# enclosed in double quotes if there is a prefix.
|
|
|
|
|
#
|
|
|
|
|
# See the comment for gdb_target_symbol_prefix_flags_asm for an
|
|
|
|
|
# extended discussion.
|
2011-05-24 14:01:22 +02:00
|
|
|
|
|
|
|
|
|
proc gdb_target_symbol_prefix_flags {} {
|
testsuite: Define and use gdb_target_symbol_prefix_flags_asm.
Some of the source code for the test cases in the GDB testsuite
reside in .S files containing assembly code. These files typically
define a symbol - such as main - which may, depending on the target,
require a prefix such as underscore.
For example, gdb.dwarf2/dw-compdir-oldgcc.S defines the symbol main:
main: .globl main
Some targets, such as rx-elf, require main to have an underscore
prefix. (If it doesn't, a linker error results due to not being able
to find _main required by crt0.o.) So, instead, the above should look
like this for rx-elf and other targets with this same requirement:
_main: .globl _main
This patch defines a new tcl proc in lib/gdb named
gdb_target_symbol_prefix_flags_asm. This proc returns a string
which will - assuming everything else is wired up correctly - cause
-DSYMBOL_PREFIX=_ to be passed on the command line to the compiler.
The test cases are augmented with a macro definition for SYMBOL
as follows:
#define CONCAT1(a, b) CONCAT2(a, b)
#define CONCAT2(a, b) a ## b
#ifdef SYMBOL_PREFIX
# define SYMBOL(str) CONCAT1(SYMBOL_PREFIX, str)
#else
# define SYMBOL(str) str
#endif
Symbols, such as main shown in the example earlier are then wrapped
with SYMBOL like this:
SYMBOL(main): .globl SYMBOL(main)
The net effect will be to add a prefix for those targets which need
it and add no prefix for those targets which do not.
It should be noted that there was already a proc in lib/gdb.exp
called gdb_target_symbol_prefix_flags. It still exists, but has
been significantly rewritten. (There is only one small difference
between the two versions.)
That proc used to explicitly list targets which were known to
require an underscore prefix. This is no longer done; the recently
added proc, gdb_target_symbol_prefix, is now invoked to dynamically
discover whether or not a prefix is required for that particular
target.
The difference between gdb_target_symbol_prefix_flags_asm
and gdb_target_symbol_prefix_flags is that the former returns
a bare prefix while the latter returns the prefix enclosed in
double quotes. I.e. assuming that the discovered prefix is
underscore, gdb_target_symbol_prefix_flags_asm returns:
additional_flags=-DSYMBOL_PREFIX=_
while gdb_target_symbol_prefix_flags returns:
additional_flags=-DSYMBOL_PREFIX="_"
The double-quoted version is not suitable for using with .S files
containing assembly code; there is no way to strip the double quotes
using C preprocessor constructs.
It would be possible to use the bare (non double quoted) version in
C source code. However, the supporting macros become more complicated
and therefore more difficult to maintain.
gdb/testsuite/ChangeLog:
* lib/gdb (gdb_target_symbol_prefix_flags_asm): New proc.
(gdb_target_symbol_prefix_flags): Define in terms of _asm
version.
* gdb.arch/i386-float.exp, gdb.arch/i386-permbkpt.exp,
gdb.dwarf2/dw2-canonicalize-type.exp,
gdb.dwarf2/dw2-compdir-oldgcc.exp, gdb.dwarf2/dw2-minsym-in-cu.exp,
gdb.dwarf2/dw2-op-stack-value.exp, gdb.dwarf2/dw2-unresolved.exp,
gdb.dwarf2/fission-reread.exp, gdb.dwarf2/pr13961.exp: Use flags
provided by gdb_target_symbol_prefix_flags_asm.
* gdb.dwarf2/dw2-canonicalize-type.S, gdb.dwarf2/dw2-compdir-oldgcc.S,
testsuite/gdb.dwarf2/dw2-minsym-in-cu.S,
testsuite/gdb.dwarf2/dw2-unresolved-main.c,
testsuite/gdb.dwarf2/dw2-unresolved.S, gdb.dwarf2/fission-reread.S,
gdb.dwarf2/pr13961.S: Define and use SYMBOL macro (and supporting
macros where needed). Use this macro for symbols which require
the prefix provided by SYMBOL_PREFIX.
2015-11-06 05:40:53 +01:00
|
|
|
|
set prefix [gdb_target_symbol_prefix]
|
|
|
|
|
if {$prefix ne ""} {
|
|
|
|
|
return "additional_flags=-DSYMBOL_PREFIX=\"$prefix\""
|
2011-05-24 14:01:22 +02:00
|
|
|
|
} else {
|
testsuite: Define and use gdb_target_symbol_prefix_flags_asm.
Some of the source code for the test cases in the GDB testsuite
reside in .S files containing assembly code. These files typically
define a symbol - such as main - which may, depending on the target,
require a prefix such as underscore.
For example, gdb.dwarf2/dw-compdir-oldgcc.S defines the symbol main:
main: .globl main
Some targets, such as rx-elf, require main to have an underscore
prefix. (If it doesn't, a linker error results due to not being able
to find _main required by crt0.o.) So, instead, the above should look
like this for rx-elf and other targets with this same requirement:
_main: .globl _main
This patch defines a new tcl proc in lib/gdb named
gdb_target_symbol_prefix_flags_asm. This proc returns a string
which will - assuming everything else is wired up correctly - cause
-DSYMBOL_PREFIX=_ to be passed on the command line to the compiler.
The test cases are augmented with a macro definition for SYMBOL
as follows:
#define CONCAT1(a, b) CONCAT2(a, b)
#define CONCAT2(a, b) a ## b
#ifdef SYMBOL_PREFIX
# define SYMBOL(str) CONCAT1(SYMBOL_PREFIX, str)
#else
# define SYMBOL(str) str
#endif
Symbols, such as main shown in the example earlier are then wrapped
with SYMBOL like this:
SYMBOL(main): .globl SYMBOL(main)
The net effect will be to add a prefix for those targets which need
it and add no prefix for those targets which do not.
It should be noted that there was already a proc in lib/gdb.exp
called gdb_target_symbol_prefix_flags. It still exists, but has
been significantly rewritten. (There is only one small difference
between the two versions.)
That proc used to explicitly list targets which were known to
require an underscore prefix. This is no longer done; the recently
added proc, gdb_target_symbol_prefix, is now invoked to dynamically
discover whether or not a prefix is required for that particular
target.
The difference between gdb_target_symbol_prefix_flags_asm
and gdb_target_symbol_prefix_flags is that the former returns
a bare prefix while the latter returns the prefix enclosed in
double quotes. I.e. assuming that the discovered prefix is
underscore, gdb_target_symbol_prefix_flags_asm returns:
additional_flags=-DSYMBOL_PREFIX=_
while gdb_target_symbol_prefix_flags returns:
additional_flags=-DSYMBOL_PREFIX="_"
The double-quoted version is not suitable for using with .S files
containing assembly code; there is no way to strip the double quotes
using C preprocessor constructs.
It would be possible to use the bare (non double quoted) version in
C source code. However, the supporting macros become more complicated
and therefore more difficult to maintain.
gdb/testsuite/ChangeLog:
* lib/gdb (gdb_target_symbol_prefix_flags_asm): New proc.
(gdb_target_symbol_prefix_flags): Define in terms of _asm
version.
* gdb.arch/i386-float.exp, gdb.arch/i386-permbkpt.exp,
gdb.dwarf2/dw2-canonicalize-type.exp,
gdb.dwarf2/dw2-compdir-oldgcc.exp, gdb.dwarf2/dw2-minsym-in-cu.exp,
gdb.dwarf2/dw2-op-stack-value.exp, gdb.dwarf2/dw2-unresolved.exp,
gdb.dwarf2/fission-reread.exp, gdb.dwarf2/pr13961.exp: Use flags
provided by gdb_target_symbol_prefix_flags_asm.
* gdb.dwarf2/dw2-canonicalize-type.S, gdb.dwarf2/dw2-compdir-oldgcc.S,
testsuite/gdb.dwarf2/dw2-minsym-in-cu.S,
testsuite/gdb.dwarf2/dw2-unresolved-main.c,
testsuite/gdb.dwarf2/dw2-unresolved.S, gdb.dwarf2/fission-reread.S,
gdb.dwarf2/pr13961.S: Define and use SYMBOL macro (and supporting
macros where needed). Use this macro for symbols which require
the prefix provided by SYMBOL_PREFIX.
2015-11-06 05:40:53 +01:00
|
|
|
|
return "";
|
2011-05-24 14:01:22 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2013-08-26 20:30:02 +02:00
|
|
|
|
# A wrapper for 'remote_exec host' that passes or fails a test.
|
|
|
|
|
# Returns 0 if all went well, nonzero on failure.
|
|
|
|
|
# TEST is the name of the test, other arguments are as for remote_exec.
|
|
|
|
|
|
|
|
|
|
proc run_on_host { test program args } {
|
|
|
|
|
verbose -log "run_on_host: $program $args"
|
|
|
|
|
# remote_exec doesn't work properly if the output is set but the
|
|
|
|
|
# input is the empty string -- so replace an empty input with
|
|
|
|
|
# /dev/null.
|
|
|
|
|
if {[llength $args] > 1 && [lindex $args 1] == ""} {
|
|
|
|
|
set args [lreplace $args 1 1 "/dev/null"]
|
|
|
|
|
}
|
|
|
|
|
set result [eval remote_exec host [list $program] $args]
|
|
|
|
|
verbose "result is $result"
|
|
|
|
|
set status [lindex $result 0]
|
|
|
|
|
set output [lindex $result 1]
|
|
|
|
|
if {$status == 0} {
|
|
|
|
|
pass $test
|
|
|
|
|
return 0
|
|
|
|
|
} else {
|
2014-02-24 22:39:14 +01:00
|
|
|
|
verbose -log "run_on_host failed: $output"
|
2013-08-26 20:30:02 +02:00
|
|
|
|
fail $test
|
|
|
|
|
return -1
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2013-09-17 01:59:02 +02:00
|
|
|
|
# Return non-zero if "board_info debug_flags" mentions Fission.
|
|
|
|
|
# http://gcc.gnu.org/wiki/DebugFission
|
|
|
|
|
# Fission doesn't support everything yet.
|
|
|
|
|
# This supports working around bug 15954.
|
|
|
|
|
|
|
|
|
|
proc using_fission { } {
|
|
|
|
|
set debug_flags [board_info [target_info name] debug_flags]
|
|
|
|
|
return [regexp -- "-gsplit-dwarf" $debug_flags]
|
|
|
|
|
}
|
|
|
|
|
|
Introduce some new MI test suite cleanups for breakpoint and
breakpoint table handling. This is a patch in five parts (all committed
here in one commit).
----- 1/5: parse_args
parse_args is a very useful utility function which allows you to do
getopt-y kinds of things in Tcl.
Example:
proc myproc {foo args} {
parse_args {{bar} {baz "abc"} {qux}}
# ...
}
myproc ABC -bar -baz DEF peanut butter
will define the following variables in myproc:
foo (=ABC), bar (=1), baz (=DEF), and qux (=0)
args will be the list {peanut butter}
----- 2/5: mi_build_kv_pairs
build_kv_pairs simply does what it says: given the input list
and an option join string, it combines list elements into kv-pairs
for MI handling. It knows how to handle tuples and other special
MI types.
Example:
mi_build_kv_pairs {a b c d e f g \[.*\]}
returns a=\"b\",c=\"d\",e=\"f\",g=\[.*\]
----- 3/5: mi_make_breakpoint
This function builds breakpoint regexps, such as
"bkpt={number=\".*\", [snip]}".
Note that ONLY the options given to mi_make_breakpoint/mi_create_breakpoint
will actually be tested. So if -number is omitted, the regexp will allow
anything [number=\".*\"]
Examples:
mi_make_breakpoint -number 3
mi_create_breakpoint "myfile.c:21" -file myfile.c -line 21
----- 4/5: mi_make_breakpoint_table
This function builds MI breakpoint table regexps.
Example:
set bps {}
lappend bps [mi_make_breakpoint -number 1 -func "main" \
-file ".*/myfile.c" -line 42
lappend bps [mi_make_breakpoint -number 2 -func "marker" \
-file ".*myfile.c" -line 21
gdb_test "-break-info" "\\^done,[mi_make_breakpoint_table $bps]" \
"breakpoint list"
----- 5/5: Update all callers
Self-explanatory
testsuite/ChangeLog
2014-04-23 Keith Seitz <keiths@redhat.com>
* lib/mi-support.exp (mi_list_breakpoints): Delete.
(mi_make_breakpoint_table): New procedure.
(mi_create_breakpoint): Use mi_make_breakpoint
and return the result.
(mi_make_breakpoint): New procedure.
(mi_build_kv_pairs): New procedure.
* gdb.mi/mi-break.exp: Remove unused globals,
update mi_create_breakpoint usage, and use mi_make_breakpoint_table.
All callers updated.
* gdb.mi/mi-dprintf.exp: Use variable to track command
number.
Update all callers of mi_create_breakpoint and use
mi_make_breakpoint_table.
Remove any unused global variables.
* gdb.mi/mi-nonstop.exp: Likewise.
* gdb.mi/mi-nsintrall.exp: Likewise.
* gdb.mi/mi-nsmoribund.exp: Likewise.
* gdb.mi/mi-nsthrexec.exp: Likewise.
* gdb.mi/mi-reverse.exp: Likewise.
* gdb.mi/mi-simplerun.exp: Likewise.
* gdb.mi/mi-stepn.exp: Likewise.
* gdb.mi/mi-syn-frame.exp: Likewise.
* gdb.mi/mi-until.exp: Likewise.
* gdb.mi/mi-var-cp.exp: Likewise.
* gdb.mi/mi-var-display.exp: Likewise.
* gdb.mi/mi2-amd64-entry-value.exp: Likewise.
* gdb.mi/mi2-var-child.exp: Likewise.
* gdb.mi/mi-vla-c99.exp: Likewise.
* lib/mi-support.exp: Likewise.
From Ian Lance Taylor <iant@cygnus.com>:
* lib/gdb.exp (parse_args): New procedure.
2014-04-23 21:17:31 +02:00
|
|
|
|
# Search the caller's ARGS list and set variables according to the list of
|
|
|
|
|
# valid options described by ARGSET.
|
|
|
|
|
#
|
|
|
|
|
# The first member of each one- or two-element list in ARGSET defines the
|
|
|
|
|
# name of a variable that will be added to the caller's scope.
|
|
|
|
|
#
|
|
|
|
|
# If only one element is given to describe an option, it the value is
|
|
|
|
|
# 0 if the option is not present in (the caller's) ARGS or 1 if
|
|
|
|
|
# it is.
|
|
|
|
|
#
|
|
|
|
|
# If two elements are given, the second element is the default value of
|
|
|
|
|
# the variable. This is then overwritten if the option exists in ARGS.
|
|
|
|
|
#
|
|
|
|
|
# Any parse_args elements in (the caller's) ARGS will be removed, leaving
|
|
|
|
|
# any optional components.
|
|
|
|
|
|
|
|
|
|
# Example:
|
|
|
|
|
# proc myproc {foo args} {
|
|
|
|
|
# parse_args {{bar} {baz "abc"} {qux}}
|
|
|
|
|
# # ...
|
|
|
|
|
# }
|
|
|
|
|
# myproc ABC -bar -baz DEF peanut butter
|
|
|
|
|
# will define the following variables in myproc:
|
|
|
|
|
# foo (=ABC), bar (=1), baz (=DEF), and qux (=0)
|
|
|
|
|
# args will be the list {peanut butter}
|
|
|
|
|
|
|
|
|
|
proc parse_args { argset } {
|
|
|
|
|
upvar args args
|
|
|
|
|
|
|
|
|
|
foreach argument $argset {
|
|
|
|
|
if {[llength $argument] == 1} {
|
|
|
|
|
# No default specified, so we assume that we should set
|
|
|
|
|
# the value to 1 if the arg is present and 0 if it's not.
|
|
|
|
|
# It is assumed that no value is given with the argument.
|
|
|
|
|
set result [lsearch -exact $args "-$argument"]
|
|
|
|
|
if {$result != -1} then {
|
|
|
|
|
uplevel 1 [list set $argument 1]
|
|
|
|
|
set args [lreplace $args $result $result]
|
|
|
|
|
} else {
|
|
|
|
|
uplevel 1 [list set $argument 0]
|
|
|
|
|
}
|
|
|
|
|
} elseif {[llength $argument] == 2} {
|
|
|
|
|
# There are two items in the argument. The second is a
|
|
|
|
|
# default value to use if the item is not present.
|
|
|
|
|
# Otherwise, the variable is set to whatever is provided
|
|
|
|
|
# after the item in the args.
|
|
|
|
|
set arg [lindex $argument 0]
|
|
|
|
|
set result [lsearch -exact $args "-[lindex $arg 0]"]
|
|
|
|
|
if {$result != -1} then {
|
|
|
|
|
uplevel 1 [list set $arg [lindex $args [expr $result+1]]]
|
|
|
|
|
set args [lreplace $args $result [expr $result+1]]
|
|
|
|
|
} else {
|
|
|
|
|
uplevel 1 [list set $arg [lindex $argument 1]]
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
error "Badly formatted argument \"$argument\" in argument set"
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# The remaining args should be checked to see that they match the
|
|
|
|
|
# number of items expected to be passed into the procedure...
|
|
|
|
|
}
|
|
|
|
|
|
2015-08-12 02:09:36 +02:00
|
|
|
|
# Capture the output of COMMAND in a string ignoring PREFIX (a regexp);
|
|
|
|
|
# return that string.
|
|
|
|
|
|
2014-05-20 09:48:43 +02:00
|
|
|
|
proc capture_command_output { command prefix } {
|
|
|
|
|
global gdb_prompt
|
|
|
|
|
global expect_out
|
|
|
|
|
|
|
|
|
|
set output_string ""
|
|
|
|
|
gdb_test_multiple "$command" "capture_command_output for $command" {
|
2015-08-12 02:09:36 +02:00
|
|
|
|
-re "[string_to_regexp ${command}]\[\r\n\]+${prefix}(.*)\[\r\n\]+$gdb_prompt $" {
|
2014-05-20 09:48:43 +02:00
|
|
|
|
set output_string $expect_out(1,string)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return $output_string
|
|
|
|
|
}
|
|
|
|
|
|
2015-03-10 09:51:27 +01:00
|
|
|
|
# A convenience function that joins all the arguments together, with a
|
|
|
|
|
# regexp that matches exactly one end of line in between each argument.
|
|
|
|
|
# This function is ideal to write the expected output of a GDB command
|
|
|
|
|
# that generates more than a couple of lines, as this allows us to write
|
|
|
|
|
# each line as a separate string, which is easier to read by a human
|
|
|
|
|
# being.
|
|
|
|
|
|
|
|
|
|
proc multi_line { args } {
|
|
|
|
|
return [join $args "\r\n"]
|
|
|
|
|
}
|
|
|
|
|
|
Further cleanup/modernization of gdb.base/commands.exp
- Use multi_line for matching multi-line GDB output.
- Add a multi_line_input variant of multi_line to build GDB input and
use it throughout.
(The two changes above make the tests much more readable, IMO.)
- Add a new valnum_re global to get rid of the multiple "\\\$\[0-9\]*".
- Remove gdb_stop_suppressing_tests uses.
- tighten a few regexps.
- Replace send_gdb/gdb_expect with gdb_test_multiple and simplify,
making pass/fail messages the same.
gdb/ChangeLog:
2016-11-09 Pedro Alves <palves@redhat.com>
* gdb.base/commands.exp (runto_or_return): New procedure.
(gdbvar_simple_if_test, gdbvar_simple_while_test)
(gdbvar_complex_if_while_test, progvar_simple_if_test)
(progvar_simple_while_test, progvar_complex_if_while_test)
(if_while_breakpoint_command_test)
(infrun_breakpoint_command_test, breakpoint_command_test)
(user_defined_command_test, watchpoint_command_test)
(test_command_prompt_position, redefine_hook_test)
(stray_arg0_test, error_clears_commands_left, redefine_hook_test)
(redefine_backtrace_test): Use runto_or_return, $valnum_re,
multi_line_input and multi_line. Remove gdb_expect and
gdb_stop_suppressing_tests uses.
* lib/gdb.exp (valnum_re): New global.
* lib/gdb.exp (valnum_re): New global.
(multi_line_input): New procedure.
2016-11-09 19:48:25 +01:00
|
|
|
|
# Similar to the above, but while multi_line is meant to be used to
|
|
|
|
|
# match GDB output, this one is meant to be used to build strings to
|
|
|
|
|
# send as GDB input.
|
|
|
|
|
|
|
|
|
|
proc multi_line_input { args } {
|
|
|
|
|
return [join $args "\n"]
|
|
|
|
|
}
|
|
|
|
|
|
2017-03-13 23:02:07 +01:00
|
|
|
|
# Return the version of the DejaGnu framework.
|
|
|
|
|
#
|
|
|
|
|
# The return value is a list containing the major, minor and patch version
|
|
|
|
|
# numbers. If the version does not contain a minor or patch number, they will
|
|
|
|
|
# be set to 0. For example:
|
|
|
|
|
#
|
|
|
|
|
# 1.6 -> {1 6 0}
|
|
|
|
|
# 1.6.1 -> {1 6 1}
|
|
|
|
|
# 2 -> {2 0 0}
|
|
|
|
|
|
|
|
|
|
proc dejagnu_version { } {
|
|
|
|
|
# The frame_version variable is defined by DejaGnu, in runtest.exp.
|
|
|
|
|
global frame_version
|
|
|
|
|
|
|
|
|
|
verbose -log "DejaGnu version: $frame_version"
|
|
|
|
|
verbose -log "Expect version: [exp_version]"
|
|
|
|
|
verbose -log "Tcl version: [info tclversion]"
|
|
|
|
|
|
|
|
|
|
set dg_ver [split $frame_version .]
|
|
|
|
|
|
|
|
|
|
while { [llength $dg_ver] < 3 } {
|
|
|
|
|
lappend dg_ver 0
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return $dg_ver
|
|
|
|
|
}
|
Further cleanup/modernization of gdb.base/commands.exp
- Use multi_line for matching multi-line GDB output.
- Add a multi_line_input variant of multi_line to build GDB input and
use it throughout.
(The two changes above make the tests much more readable, IMO.)
- Add a new valnum_re global to get rid of the multiple "\\\$\[0-9\]*".
- Remove gdb_stop_suppressing_tests uses.
- tighten a few regexps.
- Replace send_gdb/gdb_expect with gdb_test_multiple and simplify,
making pass/fail messages the same.
gdb/ChangeLog:
2016-11-09 Pedro Alves <palves@redhat.com>
* gdb.base/commands.exp (runto_or_return): New procedure.
(gdbvar_simple_if_test, gdbvar_simple_while_test)
(gdbvar_complex_if_while_test, progvar_simple_if_test)
(progvar_simple_while_test, progvar_complex_if_while_test)
(if_while_breakpoint_command_test)
(infrun_breakpoint_command_test, breakpoint_command_test)
(user_defined_command_test, watchpoint_command_test)
(test_command_prompt_position, redefine_hook_test)
(stray_arg0_test, error_clears_commands_left, redefine_hook_test)
(redefine_backtrace_test): Use runto_or_return, $valnum_re,
multi_line_input and multi_line. Remove gdb_expect and
gdb_stop_suppressing_tests uses.
* lib/gdb.exp (valnum_re): New global.
* lib/gdb.exp (valnum_re): New global.
(multi_line_input): New procedure.
2016-11-09 19:48:25 +01:00
|
|
|
|
|
Fix removing inferiors from within "thread apply" commands
This patch fixes an internal error exposed by a test that does
something like:
define kill-and-remove
kill inferiors 2
remove-inferiors 2
end
# Start one inferior.
start
# Start another inferior.
add-inferior 2
inferior 2
start
# Kill and remove inferior 1 while inferior 2 is selected.
thread apply 1.1 kill-and-remove
The internal error looks like this:
Thread 1.1 (Thread 0x7ffff7fc2700 (LWP 20677)):
[Switching to inferior 1 [process 20677] (gdb/testsuite/outputs/gdb.threads/threadapply/threadapply)]
[Switching to thread 1.1 (Thread 0x7ffff7fc2700 (LWP 20677))]
#0 main () at src/gdb/testsuite/gdb.threads/threadapply.c:38
38 for (i = 0; i < NUM; i++)
src/gdb/inferior.c:66: internal-error: void set_current_inferior(inferior*): Assertion `inf != NULL' failed.
A problem internal to GDB has been detected,
further debugging may prove unreliable.
Quit this debugging session? (y or n) FAIL: gdb.threads/threadapply.exp: kill_and_remove_inferior: try kill-and-remove: thread apply 1.1 kill-and-remove (GDB internal error)
There are several problems around this area of the code. One is that
in do_restore_current_thread_cleanup, we do a look up of inferior by
ptid, which can find the wrong inferior if the previously selected
inferior exited and some other inferior was started with a reused pid
(rare, but still...).
The other problem is that the "remove-inferiors" command rejects
attempts to remove the current inferior, but when we get to
"remove-inferiors" in a "thread apply THR remove-inferiors 2" command,
the current inferior is the inferior of thread THR, not the previously
selected inferior, so if the previously selected inferior was inferior
2, that command still manages to wipe it, and then gdb restores the
old selected inferior, which is now a dangling pointer...
So the fix here is:
- Make make_cleanup_restore_current_thread store a pointer to the
previously selected inferior directly, and use it directly instead
of doing ptid look ups.
- Add a refcount to inferiors, very similar to thread_info's refcount,
that is incremented/decremented by
make_cleanup_restore_current_thread, and checked before deleting an
inferior. To avoid duplication, a new refcounted_object type is
added, that both thread_info and inferior inherit from.
gdb/ChangeLog:
2017-04-19 Pedro Alves <palves@redhat.com>
* common/refcounted-object.h: New file.
* gdbthread.h: Include "common/refcounted-object.h".
(thread_info): Inherit from refcounted_object and add comments.
(thread_info::incref, thread_info::decref)
(thread_info::m_refcount): Delete.
(thread_info::deletable): Use the refcounted_object::refcount()
method.
* inferior.c (current_inferior_): Add comment.
(set_current_inferior): Increment/decrement refcounts.
(prune_inferiors, remove_inferior_command): Skip inferiors marked
not-deletable instead of comparing with the current inferior.
(initialize_inferiors): Increment the initial inferior's refcount.
* inferior.h (struct inferior): Forward declare.
Include "common/refcounted-object.h".
(current_inferior, set_current_inferior): Move declaration to
before struct inferior's definition, and fix comment.
(inferior): Inherit from refcounted_object. Add comments.
* thread.c (switch_to_thread_no_regs): Reference the thread's
inferior pointer directly instead of doing a ptid lookup.
(switch_to_no_thread): New function.
(switch_to_thread(thread_info *)): New function, factored out
from ...
(switch_to_thread(ptid_t)): ... this.
(restore_current_thread): Delete.
(current_thread_cleanup): Remove 'inf_id' and 'was_removable'
fields, and add 'inf' field.
(do_restore_current_thread_cleanup): Check whether old->inf is
alive instead of looking up an inferior by ptid. Use
switch_to_thread and switch_to_no_thread.
(restore_current_thread_cleanup_dtor): Use old->inf directly
instead of lookup up an inferior by id. Decref the inferior.
Don't restore 'removable'.
(make_cleanup_restore_current_thread): Same the inferior pointer
in old, instead of the inferior number. Incref the inferior.
Don't save/clear 'removable'.
gdb/testsuite/ChangeLog:
2017-04-19 Pedro Alves <palves@redhat.com>
* gdb.threads/threadapply.exp (kill_and_remove_inferior): New
procedure.
(top level): Call it.
* lib/gdb.exp (gdb_define_cmd): New procedure.
2017-04-19 14:12:23 +02:00
|
|
|
|
# Define user-defined command COMMAND using the COMMAND_LIST as the
|
|
|
|
|
# command's definition. The terminating "end" is added automatically.
|
|
|
|
|
|
|
|
|
|
proc gdb_define_cmd {command command_list} {
|
|
|
|
|
global gdb_prompt
|
|
|
|
|
|
|
|
|
|
set input [multi_line_input {*}$command_list "end"]
|
|
|
|
|
set test "define $command"
|
|
|
|
|
|
|
|
|
|
gdb_test_multiple "define $command" $test {
|
|
|
|
|
-re "End with" {
|
|
|
|
|
gdb_test_multiple $input $test {
|
|
|
|
|
-re "\r\n$gdb_prompt " {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2019-03-06 10:52:08 +01:00
|
|
|
|
# Override the 'cd' builtin with a version that ensures that the
|
|
|
|
|
# log file keeps pointing at the same file. We need this because
|
|
|
|
|
# unfortunately the path to the log file is recorded using an
|
|
|
|
|
# relative path name, and, we sometimes need to close/reopen the log
|
|
|
|
|
# after changing the current directory. See get_compiler_info.
|
|
|
|
|
|
|
|
|
|
rename cd builtin_cd
|
|
|
|
|
|
|
|
|
|
proc cd { dir } {
|
|
|
|
|
|
|
|
|
|
# Get the existing log file flags.
|
|
|
|
|
set log_file_info [log_file -info]
|
|
|
|
|
|
|
|
|
|
# Split the flags into args and file name.
|
|
|
|
|
set log_file_flags ""
|
|
|
|
|
set log_file_file ""
|
|
|
|
|
foreach arg [ split "$log_file_info" " "] {
|
|
|
|
|
if [string match "-*" $arg] {
|
|
|
|
|
lappend log_file_flags $arg
|
|
|
|
|
} else {
|
|
|
|
|
lappend log_file_file $arg
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# If there was an existing file, ensure it is an absolute path, and then
|
|
|
|
|
# reset logging.
|
|
|
|
|
if { $log_file_file != "" } {
|
|
|
|
|
set log_file_file [file normalize $log_file_file]
|
|
|
|
|
log_file
|
|
|
|
|
log_file $log_file_flags "$log_file_file"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# Call the builtin version of cd.
|
|
|
|
|
builtin_cd $dir
|
|
|
|
|
}
|
|
|
|
|
|
2019-02-14 16:49:39 +01:00
|
|
|
|
# Return a list of all languages supported by GDB, suitable for use in
|
|
|
|
|
# 'set language NAME'. This doesn't include either the 'local' or
|
|
|
|
|
# 'auto' keywords.
|
|
|
|
|
proc gdb_supported_languages {} {
|
|
|
|
|
return [list c objective-c c++ d go fortran modula-2 asm pascal \
|
|
|
|
|
opencl rust minimal ada]
|
|
|
|
|
}
|
|
|
|
|
|
2019-05-17 15:35:23 +02:00
|
|
|
|
# Check if debugging is enabled for gdb.
|
|
|
|
|
|
|
|
|
|
proc gdb_debug_enabled { } {
|
|
|
|
|
global gdbdebug
|
|
|
|
|
|
|
|
|
|
# If not already read, get the debug setting from environment or board setting.
|
|
|
|
|
if {![info exists gdbdebug]} {
|
|
|
|
|
global env
|
|
|
|
|
if [info exists env(GDB_DEBUG)] {
|
|
|
|
|
set gdbdebug $env(GDB_DEBUG)
|
|
|
|
|
} elseif [target_info exists gdb,debug] {
|
|
|
|
|
set gdbdebug [target_info gdb,debug]
|
|
|
|
|
} else {
|
|
|
|
|
return 0
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# Ensure it not empty.
|
|
|
|
|
return [expr { $gdbdebug != "" }]
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# Turn on debugging if enabled, or reset if already on.
|
|
|
|
|
|
|
|
|
|
proc gdb_debug_init { } {
|
|
|
|
|
|
|
|
|
|
global gdb_prompt
|
|
|
|
|
|
|
|
|
|
if ![gdb_debug_enabled] {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# First ensure logging is off.
|
|
|
|
|
send_gdb "set logging off\n"
|
|
|
|
|
|
|
|
|
|
set debugfile [standard_output_file gdb.debug]
|
|
|
|
|
send_gdb "set logging file $debugfile\n"
|
|
|
|
|
|
|
|
|
|
send_gdb "set logging debugredirect\n"
|
|
|
|
|
|
|
|
|
|
global gdbdebug
|
|
|
|
|
foreach entry [split $gdbdebug ,] {
|
|
|
|
|
send_gdb "set debug $entry 1\n"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# Now that everything is set, enable logging.
|
|
|
|
|
send_gdb "set logging on\n"
|
|
|
|
|
gdb_expect 10 {
|
|
|
|
|
-re "Copying output to $debugfile.*Redirecting debug output to $debugfile.*$gdb_prompt $" {}
|
|
|
|
|
timeout { warning "Couldn't set logging file" }
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2019-04-12 17:36:51 +02:00
|
|
|
|
# Check if debugging is enabled for gdbserver.
|
|
|
|
|
|
|
|
|
|
proc gdbserver_debug_enabled { } {
|
|
|
|
|
# Always disabled for GDB only setups.
|
|
|
|
|
return 0
|
|
|
|
|
}
|
|
|
|
|
|
2019-05-17 17:30:09 +02:00
|
|
|
|
# Open the file for logging gdb input
|
|
|
|
|
|
|
|
|
|
proc gdb_stdin_log_init { } {
|
|
|
|
|
global in_file
|
|
|
|
|
|
|
|
|
|
if {[info exists in_file]} {
|
|
|
|
|
# Close existing file.
|
|
|
|
|
catch "close $in_file"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
set logfile [standard_output_file_with_gdb_instance gdb.in]
|
|
|
|
|
set in_file [open $logfile w]
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# Write to the file for logging gdb input.
|
|
|
|
|
# TYPE can be one of the following:
|
|
|
|
|
# "standard" : Default. Standard message written to the log
|
|
|
|
|
# "answer" : Answer to a question (eg "Y"). Not written the log.
|
|
|
|
|
# "optional" : Optional message. Not written to the log.
|
|
|
|
|
|
|
|
|
|
proc gdb_stdin_log_write { message {type standard} } {
|
|
|
|
|
|
|
|
|
|
global in_file
|
|
|
|
|
if {![info exists in_file]} {
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# Check message types.
|
|
|
|
|
switch -regexp -- $type {
|
|
|
|
|
"answer" {
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
"optional" {
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#Write to the log
|
|
|
|
|
puts -nonewline $in_file "$message"
|
|
|
|
|
}
|
|
|
|
|
|
2019-05-17 17:38:02 +02:00
|
|
|
|
# Write the command line used to invocate gdb to the cmd file.
|
|
|
|
|
|
|
|
|
|
proc gdb_write_cmd_file { cmdline } {
|
|
|
|
|
set logfile [standard_output_file_with_gdb_instance gdb.cmd]
|
|
|
|
|
set cmd_file [open $logfile w]
|
|
|
|
|
puts $cmd_file $cmdline
|
|
|
|
|
catch "close $cmd_file"
|
|
|
|
|
}
|
|
|
|
|
|
2019-09-05 14:33:10 +02:00
|
|
|
|
# Compare contents of FILE to string STR. Pass with MSG if equal, otherwise
|
|
|
|
|
# fail with MSG.
|
|
|
|
|
|
|
|
|
|
proc cmp_file_string { file str msg } {
|
|
|
|
|
if { ![file exists $file]} {
|
|
|
|
|
fail "$msg"
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
set caught_error [catch {
|
|
|
|
|
set fp [open "$file" r]
|
|
|
|
|
set file_contents [read $fp]
|
|
|
|
|
close $fp
|
|
|
|
|
} error_message]
|
|
|
|
|
if { $caught_error } then {
|
|
|
|
|
error "$error_message"
|
|
|
|
|
fail "$msg"
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if { $file_contents == $str } {
|
|
|
|
|
pass "$msg"
|
|
|
|
|
} else {
|
|
|
|
|
fail "$msg"
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2019-10-08 11:09:31 +02:00
|
|
|
|
# Does the compiler support CTF debug output using '-gt' compiler
|
|
|
|
|
# flag? If not then we should skip these tests.
|
|
|
|
|
|
|
|
|
|
gdb_caching_proc skip_ctf_tests {
|
|
|
|
|
return ![gdb_can_simple_compile ctfdebug {
|
|
|
|
|
int main () {
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
} executable "additional_flags=-gt"]
|
|
|
|
|
}
|
|
|
|
|
|
2011-06-29 16:44:45 +02:00
|
|
|
|
# Always load compatibility stuff.
|
|
|
|
|
load_lib future.exp
|