+2019-02-19 Simon Marchi <simon.marchi@polymtl.ca>
+
+ * top.h (source_file_name): Change to std::string.
+ * top.c (source_file_name): Likewise.
+ (command_line_input): Adjust.
+ * cli/cli-script.c (script_from_file): Adjust.
+
2019-02-19 Tom Tromey <tromey@adacore.com>
* ravenscar-thread.c
scoped_restore restore_line_number
= make_scoped_restore (&source_line_number, 0);
- scoped_restore resotre_file
- = make_scoped_restore (&source_file_name, file);
+ scoped_restore restore_file
+ = make_scoped_restore<std::string, const std::string &> (&source_file_name,
+ file);
scoped_restore save_async = make_scoped_restore (¤t_ui->async, 0);
prepended. */
throw_error (e.error,
_("%s:%d: Error in sourced command file:\n%s"),
- source_file_name, source_line_number, e.message);
+ source_file_name.c_str (), source_line_number, e.message);
}
END_CATCH
}
+2019-02-19 Simon Marchi <simon.marchi@polymtl.ca>
+
+ * gdb.base/source.exp: Move "error in sourced script" code to
+ the end.
+ * gdb.base/source-error.gdb: Move contents to
+ source-error-1.gdb. Add new code to source source-error-1.gdb.
+ * gdb.base/source-error-1.gdb: New file, from previous
+ source-error.gdb.
+
2019-02-17 Tom Tromey <tom@tromey.com>
* gdb.base/style.exp: Use -g3 to compile when possible. Add test
--- /dev/null
+# This testcase is part of GDB, the GNU debugger.
+
+# Copyright 2005-2019 Free Software Foundation, Inc.
+
+# 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
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# 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.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+# Test GDB's "source" command - reads in a GDB script.
+
+echo working line\n
+x 0
+echo should not reach this line\n
# This testcase is part of GDB, the GNU debugger.
-# Copyright 2005-2019 Free Software Foundation, Inc.
+# Copyright 2019 Free Software Foundation, Inc.
# 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
# Test GDB's "source" command - reads in a GDB script.
-echo working line\n
-x 0
-echo should not reach this line\n
+source source-error-1.gdb
gdb_start
-gdb_test "source ${srcdir}/${subdir}/source-error.gdb" \
- "source-error.gdb:21: Error in sourced command file:\[\r\n\]*Cannot access memory at address 0x0.*" \
- "script contains error"
-
gdb_test "source -v ${srcdir}/${subdir}/source-test.gdb" \
"echo test source options.*" \
"source -v"
gdb_test "source source-nofile.gdb" \
"warning: for-sure-nonexistant-file: No such file or directory\.\[\r\n\]*source error not fatal"
-gdb_exit
+
+# Test commands that error out in sourced files, including in nested sourced
+# files.
+#
+# This needs to come after the "dir" command tested above for source-error.gdb
+# to find source-error-1.gdb.
+gdb_test "source ${srcdir}/${subdir}/source-error.gdb" \
+ [multi_line ".*source-error.gdb:20: Error in sourced command file:" \
+ "source-error-1.gdb:21: Error in sourced command file:" \
+ "Cannot access memory at address 0x0" ] \
+ "script contains error"
/* NOTE 1999-04-29: This variable will be static again, once we modify
gdb to use the event loop as the default command loop and we merge
event-top.c into this file, top.c. */
-/* static */ const char *source_file_name;
+/* static */ std::string source_file_name;
/* Read commands from STREAM. */
void
gdb_flush (gdb_stdout);
gdb_flush (gdb_stderr);
- if (source_file_name != NULL)
+ if (!source_file_name.empty ())
++source_line_number;
if (from_tty && annotation_level > 1)
/* For use by event-top.c. */
/* Variables from top.c. */
extern int source_line_number;
-extern const char *source_file_name;
+extern std::string source_file_name;
extern int history_expansion_p;
extern int server_command;
extern char *lim_at_start;