This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [PATCH] Fix annota1.exp: run until main breakpoint in some pc
- From: Keith Seitz <keiths at redhat dot com>
- To: Hui Zhu <hui_zhu at mentor dot com>, gdb-patches ml <gdb-patches at sourceware dot org>
- Date: Fri, 04 Apr 2014 09:55:39 -0700
- Subject: Re: [PATCH] Fix annota1.exp: run until main breakpoint in some pc
- Authentication-results: sourceware.org; auth=none
- References: <533E84B7 dot 6050303 at mentor dot com>
On 04/04/2014 03:08 AM, Hui Zhu wrote:
--- a/gdb/testsuite/gdb.base/annota1.exp
+++ b/gdb/testsuite/gdb.base/annota1.exp
@@ -129,7 +129,7 @@ gdb_test_multiple "info break" "breakpoi
#exp_internal 1
set binexp [string_to_regexp $binfile]
gdb_test_multiple "run" "run until main breakpoint" {
- -re "\r\n\032\032post-prompt\r\nStarting program: $binexp
\(\r\nwarning: Skipping \[^\r\n\]+ .gdb_index section in
\[^\r\n\]+\r\nDo \"set use-deprecated-index-sections on\" before the
file is read\r\nto use the section
anyway\\.\)?\(\(\r\n\r\n\032\032frames-invalid\)|\(\r\n\r\n\032\032breakpoints-invalid\)\)*\r\n\r\n\032\032starting\(\(\r\n\r\n\032\032frames-invalid\)|\(\r\n\r\n\032\032breakpoints-invalid\)\)*\r\n\r\n\032\032breakpoint
1\r\n\r\nBreakpoint 1, \r\n\032\032frame-begin 0
$hex\r\n\r\n\032\032frame-function-name\r\nmain\r\n\032\032frame-args\r\n \\(\\)\r\n\032\032frame-source-begin\r\n
at
\r\n\032\032frame-source-file\r\n.*annota1.c\r\n\032\032frame-source-file-end\r\n:\r\n\032\032frame-source-line\r\n$main_line\r\n\032\032frame-source-end\r\n\r\n\r\n\032\032source.*$srcfile:$main_line:.*:beg:$hex\r\n\r\n\032\032frame-end\r\n\r\n\032\032stopped.*$gdb_prompt$"
{
+ -re "\r\n\032\032post-prompt\r\nStarting program: $binexp
\(\r\nwarning: Skipping \[^\r\n\]+ .gdb_index section in
\[^\r\n\]+\r\nDo \"set use-deprecated-index-sections on\" before the
file is read\r\nto use the section anyway\\.\|.*warning: the debug
information found
in.*)?\(\(\r\n\r\n\032\032frames-invalid\)|\(\r\n\r\n\032\032breakpoints-invalid\)\)*\r\n\r\n\032\032starting\(\(\r\n\r\n\032\032frames-invalid\)|\(\r\n\r\n\032\032breakpoints-invalid\)\)*\r\n\r\n\032\032breakpoint
1\r\n\r\nBreakpoint 1, \r\n\032\032frame-begin 0
$hex\r\n\r\n\032\032frame-function-name\r\nmain\r\n\032\032frame-args\r\n \\(\\)\r\n\032\032frame-source-begin\r\n
at
\r\n\032\032frame-source-file\r\n.*annota1.c\r\n\032\032frame-source-file-end\r\n:\r\n\032\032frame-source-line\r\n$main_line\r\n\032\032frame-source-end\r\n\r\n\r\n\032\032source.*$srcfile:$main_line:.*:beg:$hex\r\n\r\n\032\032frame-end\r\n\r\n\032\032stopped.*$gdb_prompt$"
{
pass "run until main breakpoint"
}
}
Since you are touching this, can I make an impassioned plea to replace
this huge, incomprehensible mess with something a little more sane,
using tcl lists, variable substitutions, and the join command? Like so:
set output_list {}
lappend output_list A
lappend output_list B
lappend output_list C
set expected [join $output_list "\r\n"]
gdb_test_multiple "run" run until main breakpoint" {
-re $expected { pass "run until main breakpoint" }
# ...
}
This is /phenomenally/ easier to read, modify, and figure what went
wrong with a FAIL.
It is relatively easy to take this command and break it at line breaks,
e.g., [please excuse me if my mail client wraps this]
{}
\032\032post-prompt
Starting program: $binexp \(\r\nwarning: Skipping \[^\r\n\]+ .gdb_index
section in \[^\r\n\]+
Do \"set use-deprecated-index-sections on\" before the file is read\r\n
to use the section anyway\\.\|.*warning: the debug information found
in.*)?\(\(\r\n\r\n\032\032frames-invalid\)|\(\r\n\r\n\032\032breakpoints-invalid\)\)*
{}
\032\032starting\(\(\r\n\r\n\032\032frames-invalid\)|\(\r\n\r\n\032\032breakpoints-invalid\)\)*
{}
\032\032breakpoint 1
and so on.
I would go so far as to set variables for all those optional warnings
and annotations [to turn them into simpler regexps like
"$skip_section_warning|$debug_info_warning"]. Likewise with the
(repeated) "frames-invalid" and "breakpoints-invalid" annotations.
Of course, this is a bit beyond the original patch (which is okay), and
therefore a maintainer may just advise that you ignore my plea, which
you are welcome to do anyway. :-)
Keith