This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [patch] save breakpoints does not save signal catchpoints correctly
- From: Yao Qi <yao at codesourcery dot com>
- To: Jan Kratochvil <jan dot kratochvil at redhat dot com>
- Cc: <gdb-patches at sourceware dot org>, Miroslav Franc <mfranc at redhat dot com>
- Date: Fri, 10 Oct 2014 08:59:01 +0800
- Subject: Re: [patch] save breakpoints does not save signal catchpoints correctly
- Authentication-results: sourceware.org; auth=none
- References: <20141003203219 dot GA30562 at host2 dot jankratochvil dot net> <87r3yhs6sr dot fsf at codesourcery dot com> <20141009175452 dot GA26010 at host2 dot jankratochvil dot net>
Jan Kratochvil <jan.kratochvil@redhat.com> writes:
> Sorry but be more specific how you wanted to simplify the code.
> Any idea I have is 10x more complicated.
>
> With the list I have Googled
> What is the right way of comparing two lists in TCL?
> https://stackoverflow.com/questions/5195153/what-is-the-right-way-of-comparing-two-lists-in-tcl
>
> and those solutions seem too complicated to me.
I didn't mean to compare two lists. We only have one list here, and we
can check each element in it, for example,
set fd [open $filename]
- set contents [read -nonewline $fd]
+ set file_data [read $fd]
+ set data [split $file_data "\n"]
+ set contents [lindex $data 0]
+
close $fd
contents is the first line of the file, and the pattern matching code
can be unchanged. After that, we can check the second line of the file,
which should be "break main". The test becomes,
set fd [open $filename]
set file_data [read $fd]
set data [split $file_data "\n"]
close $fd
if {$arg == ""} {
set pattern "catch signal"
} else {
set pattern "catch signal $arg"
}
# Check the first line.
gdb_assert {[string match $pattern [lindex $data 0]]} \
"1st line of save breakpoints for '$arg'"
# Check the second line.
gdb_assert {[string match "break main" [lindex $data 1]]} \
"2nd line of save breakpoints for '$arg'"
This will be more clear and easier to extend when there are more lines in
the file.
--
Yao (éå)