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]

Re: Stabs or Dwarf Was: [PATCH]: testsuite/gdb.base/constvars.exp


Well, Jim Blandy pointed out that there is already a get_debug_format
(it is used in ptype.exp, list.exp and in half a dozen of the C++ test
files).

It uses the "info source" command that Michael mentioned (so it is as
reliable
as "info source" is).


For convenience, there is also a setup_xfail_format that causes the
following
test to fail if the debug format is the one specified.  As Michael
Snyder
pointed out in another list, we actually have concluded that we should
do the
opposite: xfail if _not_ the specified format ;-)  Anyway, it is simple
to
test for DWARF2 or any other that we know we can detect more reliably
and that
can accommodate the tests and xfail for all the others.


Thanks to all for the suggestions.


Here is the code for the function:

global debug_format
set debug_format "unknown"

# 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 {
        -re "Compiled with (.*) debugging format.\r\n$gdb_prompt $" {
            set debug_format $expect_out(1,string)
            verbose "debug format is $debug_format"
            return 1;
        }
        -re "No current source file.\r\n$gdb_prompt $" {
            perror "get_debug_format used when no current source file"
            return 0;
        }
        -re "$gdb_prompt $" {
            warning "couldn't check debug format (no valid response)."
            return 1;
        }
        timeout {
            warning "couldn't check debug format (timed out)."
            return 1;
        }
    }
}

-- 
Fernando Nasser
Red Hat Canada Ltd.                     E-Mail:  fnasser@redhat.com
2323 Yonge Street, Suite #300
Toronto, Ontario   M4P 2C9


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