[PATCH 2/2] Documentation and testcase
Pedro Alves
palves@redhat.com
Mon Mar 23 20:27:00 GMT 2015
On 03/22/2015 08:45 PM, Sergio Durigan Junior wrote:
> +# We do not do file-backed mappings in the test program, but it is
> +# important to test this anyway. One way of performing the test is to
> +# load GDB with a corefile but without a binary, and then ask for the
> +# disassemble of a function (i.e., the binary's .text section). GDB
> +# should fail in this case. However, it must succeed if the binary is
> +# provided along with the corefile. This is what we test here.
It seems like we now just miss the case of corefilter that _does_ request
that the file backed regions are dumped. In that case, disassembly
should work without the binary. Could you add that too, please? We
can e.g., pass a boolean parameter to test_disasm to specify whether
to expect that disassembly works without a program file.
> +
> +proc test_disasm { core address } {
> + global testfile
> +
> + # Restarting GDB without loading the binary
> + gdb_exit
> + gdb_start
> +
> + set core_loaded [gdb_core_cmd "$core" "load core"]
> + if { $core_loaded == -1 } {
> + fail "loading $core"
> + return
> + }
> +
> + gdb_test "disassemble $address" "No function contains specified address." \
> + "disassemble function with corefile and without a binary"
> +
> + clean_restart $testfile
> +
> + set core_loaded [gdb_core_cmd "$core" "load core"]
> + if { $core_loaded == -1 } {
> + fail "loading $core"
> + return
> + }
> +
> + gdb_test "disassemble $address" "Dump of assembler code for function.*" \
> + "disassemble function with corefile and with a binary"
Looks like there are duplicate test messages here, in the
cases clean_restart, gdb_core_cmd, etc. fail. You can fix that
with e.g.:
with_test_prefix "no binary" {
# Restart GDB without loading the binary.
gdb_exit
gdb_start
set core_loaded [gdb_core_cmd "$core" "load core"]
if { $core_loaded == -1 } {
fail "load $core"
return
}
gdb_test "disassemble $address" "No function contains specified address." \
"disassemble function"
}
with_test_prefix "with binary" {
clean_restart $testfile
set core_loaded [gdb_core_cmd "$core" "load core"]
if { $core_loaded == -1 } {
fail "load $core"
return
}
gdb_test "disassemble $address" "No function contains specified address." \
"disassemble function"
}
> +# Getting the inferior's PID
"Get". Period at end.
> +set infpid ""
> +gdb_test_multiple "info inferiors" "getting inferior pid" {
> + -re "process \($decimal\).*\r\n$gdb_prompt $" {
> + set infpid $expect_out(1,string)
> + }
> +}
> +
> +# Get the main function's address
Period.
(I saw a few other similar gerund uses in the file which
read a bit odd to me, but I didn't point them all out.)
This is OK with the missing test added.
Thanks for the patience and for working on this.
Thanks,
Pedro Alves
More information about the Gdb-patches
mailing list