diff options
author | Nick Clifton <nickc@redhat.com> | 2007-08-30 13:47:35 +0000 |
---|---|---|
committer | Nick Clifton <nickc@redhat.com> | 2007-08-30 13:47:35 +0000 |
commit | 09c11c861badb766bb5140bac0e7dba017730f8a (patch) | |
tree | 5b7b48e4c200d899cd764acd3034a3dcab2f59a9 /binutils/testsuite | |
parent | 7cd410025fbd4fcb002cebdf40fdcf17f8d70162 (diff) | |
download | gdb-09c11c861badb766bb5140bac0e7dba017730f8a.zip gdb-09c11c861badb766bb5140bac0e7dba017730f8a.tar.gz gdb-09c11c861badb766bb5140bac0e7dba017730f8a.tar.bz2 |
* readelf.c (dump_type): New type used to classify the kinds of dump requested by the user.
(dump_sects, cmdline_dump_sects): Use the new type.
(options): Add --string-dump option.
(request_dump): Rename to request_dump_bynumber. Use dump_type.
(request_dump_byname): Use dump_type.
(parse_args): Parse --string-dump option.
(process_section_headers): Fix calls to request_dump.
(initialise_dumps_byname): Likewise.
(dump_section): Rename to dump_section_as_bytes.
(dump_section_as_strings): New function. Display the contents of a section as printable strings.
(process_section_contents): String dump the section if requested.
(process_object): Use dump_type.
(main): Likewise.
* Makefile.am: Add dependency for readelf.c on safe-ctype.h.
* Makefile.in: Regenerate.
* NEWS: Mention the new feature.
* doc/binutils.texi: Document the new feature.
* testsuite/binutils-all/dumptest.s: New test file.
* testsuite/binutils-all/readelf.exp: Add test of readelf's -p switch.
Diffstat (limited to 'binutils/testsuite')
-rw-r--r-- | binutils/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | binutils/testsuite/binutils-all/dumptest.s | 2 | ||||
-rw-r--r-- | binutils/testsuite/binutils-all/readelf.exp | 66 |
3 files changed, 68 insertions, 5 deletions
diff --git a/binutils/testsuite/ChangeLog b/binutils/testsuite/ChangeLog index c1fcd3c..82292aa 100644 --- a/binutils/testsuite/ChangeLog +++ b/binutils/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2007-08-30 Nick Clifton <nickc@redhat.com> + + * binutils-all/dumptest.s: New test file. + * binutils-all/readelf.exp: Add test of readelf's -p switch. + 2007-08-28 Mark Shinwell <shinwell@codesourcery.com> Joseph Myers <joseph@codesourcery.com> diff --git a/binutils/testsuite/binutils-all/dumptest.s b/binutils/testsuite/binutils-all/dumptest.s new file mode 100644 index 0000000..6335d22 --- /dev/null +++ b/binutils/testsuite/binutils-all/dumptest.s @@ -0,0 +1,2 @@ + .data + .ascii "test_string" diff --git a/binutils/testsuite/binutils-all/readelf.exp b/binutils/testsuite/binutils-all/readelf.exp index d8ba1c0..52be1ee 100644 --- a/binutils/testsuite/binutils-all/readelf.exp +++ b/binutils/testsuite/binutils-all/readelf.exp @@ -21,6 +21,12 @@ # Based on scripts written by Ian Lance Taylor <ian@cygnus.com> # and Ken Raeburn <raeburn@cygnus.com>. +# Exclude non-ELF targets. +if ![is_elf_format] { + verbose "$READELF is only intended for ELF targets" 2 + return +} + # First some helpful procedures, then the tests themselves # Return the contents of the filename given @@ -203,10 +209,58 @@ proc readelf_wi_test {} { } -# Exclude non-ELF targets. -if ![is_elf_format] { - verbose "$READELF is only intended for ELF targets" 2 - return +# Test readelf's dumping abilities. + +proc readelf_dump_test {} { + global READELF + global READELFFLAGS + global srcdir + global subdir + + # Assemble the dump test file. + if {![binutils_assemble $srcdir/$subdir/dumptest.s tmpdir/dumptest.o]} then { + unresolved "readelf -p: failed to assemble dump test file" + return + } + # Download it. + set tempfile [remote_download host tmpdir/dumptest.o] + + # Run "readelf -p.data" on it. + set got [remote_exec host "$READELF $READELFFLAGS -p.data $tempfile" "" "/dev/null" "readelf.out"] + set got [lindex $got 1] + + # Upload the results. + set output [remote_upload host readelf.out] + + # Check for something going wrong. + if ![string match "" $got] then { + fail "readelf -p: unexpected output" + send_log $got + send_log "\n" + return + } + + # Search for strings that should be in the output. + set sought { + ".*test_string.*" + } + + foreach looked_for $sought { + set lines [grep $output $looked_for] + if ![llength $lines] then { + fail "readelf -p: missing: $looked_for" + send_log readelf.out + return + } + } + + file_on_host delete $tempfile + file_on_host delete $output + + # All done. + pass "readelf -p" + + # XXX FIXME: Add test of readelf -x here } if ![is_remote host] { @@ -220,7 +274,7 @@ send_user "Version [binutil_version $READELF]" # Assemble the test file. if {![binutils_assemble $srcdir/$subdir/bintest.s tmpdir/bintest.o]} then { - perror "unresolved 1" + perror "could not assemble test file" unresolved "readelf - failed to assemble" return } @@ -241,3 +295,5 @@ readelf_test -s $tempfile readelf.ss {} readelf_test -r $tempfile readelf.r {} readelf_wi_test + +readelf_dump_test |