This is the mail archive of the gdb@sources.redhat.com mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: How do I get regexp from expect at gdb_expect?


> You've left out your pattern, and the context.  I recommend using
> "exp_internal 1" to debug this sort of problem; that will show you what
> expect is doing.

OK, here's an example of the problem, here's the output for 2
consecutive commands given to GDB. 

First, 200-break-delete is sent. The '200-break-delete' is in the
'expect_out(buffer)' output, which leads me to believe the testsuite is 
echoing the input command. This in itself is probably wrong. However, the
'200-break-delete' is not in the matched regular expression
'expect_out(0,string)'. 

The next command, '200-break-list' is in both the 'expect_out(buffer)'
and in the 'expect_out(0,string)'. This leads me to believe that there
is something wrong with the regular expression matching. It can match
things that it shouldn't, which could mask problems.

I don't really understand what you are saying about 'GDB is echoing
commands'. I do understand that when you are at the terminal running
GDB, GDB allows the terminal to 'echo' the char's typed. However, if you
fork/exec GDB, and send it a command, it will not 'echo' the data back
to your process. Isn't this the way Expect works?

The output is below.

Thanks,
Bob Rossi


send: sending "200-break-delete\n" to { exp11 }

expect: does "" (spawn_id exp11) match regular expression "\*\*\* DOSEXIT code.*"? no
"Ending remote debugging.*[(]gdb[)] \r\n[ ]*$"? no
"([\r\n]*((\^done)[\r\n]+[(]gdb[)] \r\n[ ]*$))"? no
"(^FOOBAR$)$"? no
"Undefined.* command:.*[(]gdb[)] \r\n[ ]*$"? no
"Ambiguous command.*[(]gdb[)] \r\n[ ]*$"? no
"Program exited with code [0-9]+.*[(]gdb[)] \r\n[ ]*$"? no
"The program is not being run.*[(]gdb[)] \r\n[ ]*$"? no
".*[(]gdb[)] \r\n[ ]*$"? no
"<return>"? no
"\(y or n\) "? no
full_buffer? no
200-break-delete
200^done
(gdb) 

expect: does "200-break-delete\r\n200^done\r\n(gdb) \r\n" (spawn_id exp11) match regular expression "\*\*\* DOSEXIT code.*"? no
"Ending remote debugging.*[(]gdb[)] \r\n[ ]*$"? no
"([\r\n]*((\^done)[\r\n]+[(]gdb[)] \r\n[ ]*$))"? yes
expect: set expect_out(0,string) "^done\r\n(gdb) \r\n"
expect: set expect_out(1,string) "^done\r\n(gdb) \r\n"
expect: set expect_out(2,string) "^done\r\n(gdb) \r\n"
expect: set expect_out(3,string) "^done"
expect: set expect_out(spawn_id) "exp11"
expect: set expect_out(buffer) "200-break-delete\r\n200^done\r\n(gdb) \r\n"
PASS: gdb.mi/mi2-basics.exp: break-delete (all) operation
send: sending "201-break-list\n" to { exp11 }

expect: does "" (spawn_id exp11) match regular expression "\*\*\* DOSEXIT code.*"? no
"Ending remote debugging.*[(]gdb[)] \r\n[ ]*$"? no
"([\r\n]*((.*\^done,BreakpointTable=\{.*,body=\[\]\})[\r\n]+[(]gdb[)] \r\n[ ]*$))"? no
"(^FOOBAR$)$"? no
"Undefined.* command:.*[(]gdb[)] \r\n[ ]*$"? no
"Ambiguous command.*[(]gdb[)] \r\n[ ]*$"? no
"Program exited with code [0-9]+.*[(]gdb[)] \r\n[ ]*$"? no
"The program is not being run.*[(]gdb[)] \r\n[ ]*$"? no
".*[(]gdb[)] \r\n[ ]*$"? no
"<return>"? no
"\(y or n\) "? no
full_buffer? no
201-break-list
201^done,BreakpointTable={nr_rows="0",nr_cols="6",hdr=[{width="3",alignment="-1",col_name="number",colhdr="Num"},{width="14",alignment="-1",col_name="type",colhdr="Type"},{width="4",alignment="-1",col_name="disp",colhdr="Disp"},{width="3",alignment="-1",col_name="enabled",colhdr="Enb"},{width="10",alignment="-1",col_name="addr",colhdr="Address"},{width="40",alignment="2",col_name="what",colhdr="What"}],body=[]}
(gdb) 

expect: does "201-break-list\r\n201^done,BreakpointTable={nr_rows="0",nr_cols="6",hdr=[{width="3",alignment="-1",col_name="number",colhdr="Num"},{width="14",alignment="-1",col_name="type",colhdr="Type"},{width="4",alignment="-1",col_name="disp",colhdr="Disp"},{width="3",alignment="-1",col_name="enabled",colhdr="Enb"},{width="10",alignment="-1",col_name="addr",colhdr="Address"},{width="40",alignment="2",col_name="what",colhdr="What"}],body=[]}\r\n(gdb) \r\n" (spawn_id exp11) match regular expression "\*\*\* DOSEXIT code.*"? no
"Ending remote debugging.*[(]gdb[)] \r\n[ ]*$"? no
"([\r\n]*((.*\^done,BreakpointTable=\{.*,body=\[\]\})[\r\n]+[(]gdb[)] \r\n[ ]*$))"? yes
expect: set expect_out(0,string) "201-break-list\r\n201^done,BreakpointTable={nr_rows="0",nr_cols="6",hdr=[{width="3",alignment="-1",col_name="number",colhdr="Num"},{width="14",alignment="-1",col_name="type",colhdr="Type"},{width="4",alignment="-1",col_name="disp",colhdr="Disp"},{width="3",alignment="-1",col_name="enabled",colhdr="Enb"},{width="10",alignment="-1",col_name="addr",colhdr="Address"},{width="40",alignment="2",col_name="what",colhdr="What"}],body=[]}\r\n(gdb) \r\n"
expect: set expect_out(1,string) "201-break-list\r\n201^done,BreakpointTable={nr_rows="0",nr_cols="6",hdr=[{width="3",alignment="-1",col_name="number",colhdr="Num"},{width="14",alignment="-1",col_name="type",colhdr="Type"},{width="4",alignment="-1",col_name="disp",colhdr="Disp"},{width="3",alignment="-1",col_name="enabled",colhdr="Enb"},{width="10",alignment="-1",col_name="addr",colhdr="Address"},{width="40",alignment="2",col_name="what",colhdr="What"}],body=[]}\r\n(gdb) \r\n"
expect: set expect_out(2,string) "201-break-list\r\n201^done,BreakpointTable={nr_rows="0",nr_cols="6",hdr=[{width="3",alignment="-1",col_name="number",colhdr="Num"},{width="14",alignment="-1",col_name="type",colhdr="Type"},{width="4",alignment="-1",col_name="disp",colhdr="Disp"},{width="3",alignment="-1",col_name="enabled",colhdr="Enb"},{width="10",alignment="-1",col_name="addr",colhdr="Address"},{width="40",alignment="2",col_name="what",colhdr="What"}],body=[]}\r\n(gdb) \r\n"
expect: set expect_out(3,string) "201-break-list\r\n201^done,BreakpointTable={nr_rows="0",nr_cols="6",hdr=[{width="3",alignment="-1",col_name="number",colhdr="Num"},{width="14",alignment="-1",col_name="type",colhdr="Type"},{width="4",alignment="-1",col_name="disp",colhdr="Disp"},{width="3",alignment="-1",col_name="enabled",colhdr="Enb"},{width="10",alignment="-1",col_name="addr",colhdr="Address"},{width="40",alignment="2",col_name="what",colhdr="What"}],body=[]}"
expect: set expect_out(spawn_id) "exp11"
expect: set expect_out(buffer) "201-break-list\r\n201^done,BreakpointTable={nr_rows="0",nr_cols="6",hdr=[{width="3",alignment="-1",col_name="number",colhdr="Num"},{width="14",alignment="-1",col_name="type",colhdr="Type"},{width="4",alignment="-1",col_name="disp",colhdr="Disp"},{width="3",alignment="-1",col_name="enabled",colhdr="Enb"},{width="10",alignment="-1",col_name="addr",colhdr="Address"},{width="40",alignment="2",col_name="what",colhdr="What"}],body=[]}\r\n(gdb) \r\n"



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]