diff options
author | Craig Silverstein <csilvers@google.com> | 2008-07-10 01:32:23 +0000 |
---|---|---|
committer | Craig Silverstein <csilvers@google.com> | 2008-07-10 01:32:23 +0000 |
commit | 1b315056928c75e989b6a0fa858577141da5cc4f (patch) | |
tree | 614e9ce91f305d95088448cd17509082373d0b1d /binutils/testsuite | |
parent | 67f9f80fe82daf2c0b287fa8ccb8b96ae9e68e7f (diff) | |
download | gdb-1b315056928c75e989b6a0fa858577141da5cc4f.zip gdb-1b315056928c75e989b6a0fa858577141da5cc4f.tar.gz gdb-1b315056928c75e989b6a0fa858577141da5cc4f.tar.bz2 |
bfd/
* Makefile.am (BFD32_LIBS): Add compress.lo.
(BFD32_LIBS_CFILES): Add compress.c.
(BFD_H_FILES): Likewise.
* Makefile.in: Regenerate.
* bfd-in2.h: Regenerate.
* config.in: Add HAVE_ZLIB_H
* configure.in: Add test for libz and zlib.h
* configure: Regenerate.
* dwarf2.c (read_section): New function.
(read_indirect_string): Call new function read_section.
(read_abbrevs): Likewise.
(decode_line_info): Likewise.
(read_debug_ranges): Likewise.
(find_line): Call new function read_section when just one
.zdebug_info section is found, otherwise read and compress
multiple sections.
(_bfd_dwarf2_cleanup_debug_info): Free sec_info_ptr.
* elf.c (_bfd_elf_make_section_from_shdr): Add zdebug prefix.
(special_sections_z): New struct.
(special_sections): Refer to special_sections_z.
* elfxx-mips.c (_bfd_mips_elf_section_from_shdr): Recognize
sections named .zdebug_*.
(_bfd_mips_elf_fake_sections): Likewise.
* compress.c: New file.
(bfd_uncompress_section_contents): New function.
bfd/doc/
* Makefile.am (BFD_H_DEP): Add ../compress.c.
* Makefile.in: Regenerate.
binutils/
* config.in: Add HAVE_ZLIB_H
* configure.in: Add test for libz and zlib.h
* configure: Regenerate.
* dwarf.c (debug_displays): Add .zdebug_* strings.
* dwarf.h (struct dwarf_section): Add fields uncompressed_namd
and compressed_name.
* objdump.c (load_debug_section): Call
bfd_uncompress_section_contents when loading a compressed
section.
(dump_dwarf_section): Recognize compressed section name.
(mach_o_dwarf_sections): Rename as
mach_o_uncompressed_dwarf_sections.
(mach_o_compressed_dwarf_sections): New variable.
(generic_dwarf_section): Rename as
generic_uncompressed_dwarf_sections.
(generic_compressed_dwarf_sections): New variable.
(check_mach_o_dwarf): Save and restore
mach_o_compressed_dwarf_sections.
* readelf.c: Add #include for config.h and zlib.h
(process_section_headers): Recognize compressed section name.
(uncompress_section_contents): New function.
(load_debug_section): Call uncompress_section_contents when
loading a compressed section.
(display_debug_section): Recognize compressed section name.
binutils/testsuite:
* binutils-all/objdump.exp: Add test for objdump -s on a file
with a compressed debug section. Add test for objdump -W on a
file that contains a compressed debug section.
* binutils-all/readelf.exp: Call readelf_compressed_wa_test.
(readelf_compressed_wa_test): New function.
* binutils-all/dw2-compressed.S: New file.
* binutils-all/objdump.W: New file.
* binutils-all/objdump.s: New file.
* binutils-all/readelf.wa: New file.
Diffstat (limited to 'binutils/testsuite')
-rw-r--r-- | binutils/testsuite/ChangeLog | 12 | ||||
-rw-r--r-- | binutils/testsuite/binutils-all/dw2-compressed.S | 218 | ||||
-rw-r--r-- | binutils/testsuite/binutils-all/objdump.W | 129 | ||||
-rw-r--r-- | binutils/testsuite/binutils-all/objdump.exp | 43 | ||||
-rw-r--r-- | binutils/testsuite/binutils-all/objdump.s | 9 | ||||
-rw-r--r-- | binutils/testsuite/binutils-all/readelf.exp | 37 | ||||
-rw-r--r-- | binutils/testsuite/binutils-all/readelf.wa | 24 |
7 files changed, 472 insertions, 0 deletions
diff --git a/binutils/testsuite/ChangeLog b/binutils/testsuite/ChangeLog index 83d79d5..3fb1c55 100644 --- a/binutils/testsuite/ChangeLog +++ b/binutils/testsuite/ChangeLog @@ -1,3 +1,15 @@ +2008-07-09 Craig Silverstein <csilvers@google.com> + + * binutils-all/objdump.exp: Add test for objdump -s on a file + with a compressed debug section. Add test for objdump -W on a + file that contains a compressed debug section. + * binutils-all/readelf.exp: Call readelf_compressed_wa_test. + (readelf_compressed_wa_test): New function. + * binutils-all/dw2-compressed.S: New file. + * binutils-all/objdump.W: New file. + * binutils-all/objdump.s: New file. + * binutils-all/readelf.wa: New file. + 2008-07-08 Kai Tietz <kai.tietz@onevision.com> * binutils-all/objcopy.exp (copy_setup): Check if host-triplet diff --git a/binutils/testsuite/binutils-all/dw2-compressed.S b/binutils/testsuite/binutils-all/dw2-compressed.S new file mode 100644 index 0000000..f11d68f --- /dev/null +++ b/binutils/testsuite/binutils-all/dw2-compressed.S @@ -0,0 +1,218 @@ +/* This testcase is derived from a similar test in GDB. + + Copyright 2008 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. */ + +/* This tests that gdb can read compressed sections. The contents + are a basic assembly file, but the .debug_abbrev section has been + comrpessed using zlib. */ + +/* Dummy function to provide debug information for. */ + + .text + .globl _start +_start: + .int 0 +.Lbegin_text1: + .globl func_cu1 + .type func_cu1, %function +func_cu1: +.Lbegin_func_cu1: + .int 0 +.Lend_func_cu1: + .size func_cu1, .-func_cu1 +.Lend_text1: + +/* Debug information */ + + .section .debug_info +.Lcu1_begin: + /* CU header */ + .4byte .Lcu1_end - .Lcu1_start /* Length of Compilation Unit */ +.Lcu1_start: + .2byte 2 /* DWARF Version */ + .4byte .Labbrev1_begin /* Offset into abbrev section */ + .byte 4 /* Pointer size */ + + /* CU die */ + .uleb128 1 /* Abbrev: DW_TAG_compile_unit */ + .4byte .Lline1_begin /* DW_AT_stmt_list */ + .4byte .Lend_text1 /* DW_AT_high_pc */ + .4byte .Lbegin_text1 /* DW_AT_low_pc */ + .ascii "file1.txt\0" /* DW_AT_name */ + .ascii "GNU C 3.3.3\0" /* DW_AT_producer */ + .byte 1 /* DW_AT_language (C) */ + + /* func_cu1 */ + .uleb128 2 /* Abbrev: DW_TAG_subprogram */ + .byte 1 /* DW_AT_external */ + .byte 1 /* DW_AT_decl_file */ + .byte 2 /* DW_AT_decl_line */ + .ascii "func_cu1\0" /* DW_AT_name */ + .4byte .Ltype_int-.Lcu1_begin /* DW_AT_type */ + .4byte .Lbegin_func_cu1 /* DW_AT_low_pc */ + .4byte .Lend_func_cu1 /* DW_AT_high_pc */ + .byte 1 /* DW_AT_frame_base: length */ + .byte 0x55 /* DW_AT_frame_base: DW_OP_reg5 */ + +.Ltype_int: + .uleb128 3 /* Abbrev: DW_TAG_base_type */ + .ascii "int\0" /* DW_AT_name */ + .byte 4 /* DW_AT_byte_size */ + .byte 5 /* DW_AT_encoding */ + + .byte 0 /* End of children of CU */ + +.Lcu1_end: + +/* Line table */ + .section .debug_line +.Lline1_begin: + .4byte .Lline1_end - .Lline1_start /* Initial length */ +.Lline1_start: + .2byte 2 /* Version */ + .4byte .Lline1_lines - .Lline1_hdr /* header_length */ +.Lline1_hdr: + .byte 1 /* Minimum insn length */ + .byte 1 /* default_is_stmt */ + .byte 1 /* line_base */ + .byte 1 /* line_range */ + .byte 0x10 /* opcode_base */ + + /* Standard lengths */ + .byte 0 + .byte 1 + .byte 1 + .byte 1 + .byte 1 + .byte 0 + .byte 0 + .byte 0 + .byte 1 + .byte 0 + .byte 0 + .byte 1 + .byte 0 + .byte 0 + .byte 0 + + /* Include directories */ + .byte 0 + + /* File names */ + .ascii "file1.txt\0" + .uleb128 0 + .uleb128 0 + .uleb128 0 + + .byte 0 + +.Lline1_lines: + .byte 0 /* DW_LNE_set_address */ + .uleb128 5 + .byte 2 + .4byte .Lbegin_func_cu1 + + .byte 3 /* DW_LNS_advance_line */ + .sleb128 3 /* ... to 4 */ + + .byte 1 /* DW_LNS_copy */ + + .byte 1 /* DW_LNS_copy (second time as an end-of-prologue marker) */ + + .byte 0 /* DW_LNE_set_address */ + .uleb128 5 + .byte 2 + .4byte .Lend_func_cu1 + + .byte 0 /* DW_LNE_end_of_sequence */ + .uleb128 1 + .byte 1 + +.Lline1_end: + +/* Abbrev table -- compressed */ + .section .zdebug_abbrev +.Labbrev1_begin: + .ascii "ZLIB" + .4byte 0 + .2byte 0 + .byte 0 + .byte 51 + .byte 0x78 + .byte 0x5e + .byte 0x63 + .byte 0x14 + .byte 0x64 + .byte 0x14 + .byte 0x60 + .byte 0x13 + .byte 0x62 + .byte 0x14 + .byte 0x64 + .byte 0x64 + .byte 0xe6 + .byte 0x50 + .byte 0xe5 + .byte 0x10 + .byte 0xe6 + .byte 0x66 + .byte 0x60 + .byte 0x60 + .byte 0xd2 + .byte 0x63 + .byte 0xb0 + .byte 0xe7 + .byte 0xb1 + .byte 0xe2 + .byte 0xb6 + .byte 0xe6 + .byte 0x66 + .byte 0xe6 + .byte 0xf0 + .byte 0x14 + .byte 0x16 + .byte 0x64 + .byte 0x14 + .byte 0x62 + .byte 0x74 + .byte 0xe0 + .byte 0x02 + .byte 0x00 + .byte 0x25 + .byte 0x78 + .byte 0x02 + .byte 0x81 + .byte 0x78 + .byte 0x9c + .byte 0x63 + .byte 0x60 + .byte 0x60 + .byte 0x56 + .byte 0x61 + .byte 0x60 + .byte 0xe6 + .byte 0xe0 + .byte 0xe6 + .byte 0xb6 + .byte 0xe3 + .byte 0x66 + .byte 0x00 + .byte 0x02 + .byte 0x00 + .byte 0x04 + .byte 0x9c + .byte 0x00 + .byte 0x92 diff --git a/binutils/testsuite/binutils-all/objdump.W b/binutils/testsuite/binutils-all/objdump.W new file mode 100644 index 0000000..18dad34 --- /dev/null +++ b/binutils/testsuite/binutils-all/objdump.W @@ -0,0 +1,129 @@ + +tmpdir/dw2-compressed.o: file format .* + +The section .debug_info contains: + + Compilation Unit @ offset 0x0: + Length: 0x4e \(32-bit\) + Version: 2 + Abbrev Offset: 0 + Pointer Size: 4 + <0><b>: Abbrev Number: 1 \(DW_TAG_compile_unit\) + < c> DW_AT_stmt_list : 0x0 + <10> DW_AT_high_pc : 0x8 + <14> DW_AT_low_pc : 0x4 + <18> DW_AT_name : file1.txt + <22> DW_AT_producer : GNU C 3.3.3 + <2e> DW_AT_language : 1 \(ANSI C\) + <1><2f>: Abbrev Number: 2 \(DW_TAG_subprogram\) + <30> DW_AT_external : 1 + <31> DW_AT_decl_file : 1 + <32> DW_AT_decl_line : 2 + <33> DW_AT_name : func_cu1 + <3c> DW_AT_type : <0x4a> + <40> DW_AT_low_pc : 0x4 + <44> DW_AT_high_pc : 0x8 + <48> DW_AT_frame_base : 1 byte block: 55 \(DW_OP_reg5\) + <1><4a>: Abbrev Number: 3 \(DW_TAG_base_type\) + <4b> DW_AT_name : int + <4f> DW_AT_byte_size : 4 + <50> DW_AT_encoding : 5 \(signed\) + +Raw dump of debug contents of section .debug_line: + + Offset: 0x0 + Length: 62 + DWARF Version: 2 + Prologue Length: 35 + Minimum Instruction Length: 1 + Initial value of 'is_stmt': 1 + Line Base: 1 + Line Range: 1 + Opcode Base: 16 + + Opcodes: + Opcode 1 has 0 args + Opcode 2 has 1 args + Opcode 3 has 1 args + Opcode 4 has 1 args + Opcode 5 has 1 args + Opcode 6 has 0 args + Opcode 7 has 0 args + Opcode 8 has 0 args + Opcode 9 has 1 args + Opcode 10 has 0 args + Opcode 11 has 0 args + Opcode 12 has 1 args + Opcode 13 has 0 args + Opcode 14 has 0 args + Opcode 15 has 0 args + + The Directory Table is empty. + + The File Name Table: + Entry Dir Time Size Name + 1 0 0 0 file1.txt + + Line Number Statements: + Extended opcode 2: set Address to .* + Advance Line by 3 to 4 + Copy + Copy + Extended opcode 2: set Address to .* + Extended opcode 1: End of Sequence + + + Offset: 0x42 + Length: 25 + DWARF Version: 2 + Prologue Length: 19 + Minimum Instruction Length: 1 + Initial value of 'is_stmt': 1 + Line Base: -5 + Line Range: 14 + Opcode Base: 13 + + Opcodes: + Opcode 1 has 0 args + Opcode 2 has 1 args + Opcode 3 has 1 args + Opcode 4 has 1 args + Opcode 5 has 1 args + Opcode 6 has 0 args + Opcode 7 has 0 args + Opcode 8 has 0 args + Opcode 9 has 1 args + Opcode 10 has 0 args + Opcode 11 has 0 args + Opcode 12 has 1 args + + The Directory Table is empty. + + The File Name Table is empty. + + Line Number Statements: + +Contents of the .zdebug_abbrev section: + + Number TAG + 1 DW_TAG_compile_unit \[has children\] + DW_AT_stmt_list DW_FORM_data4 + DW_AT_high_pc DW_FORM_addr + DW_AT_low_pc DW_FORM_addr + DW_AT_name DW_FORM_string + DW_AT_producer DW_FORM_string + DW_AT_language DW_FORM_data1 + 2 DW_TAG_subprogram \[no children\] + DW_AT_external DW_FORM_flag + DW_AT_decl_file DW_FORM_data1 + DW_AT_decl_line DW_FORM_data1 + DW_AT_name DW_FORM_string + DW_AT_type DW_FORM_ref4 + DW_AT_low_pc DW_FORM_addr + DW_AT_high_pc DW_FORM_addr + DW_AT_frame_base DW_FORM_block1 + 3 DW_TAG_base_type \[no children\] + DW_AT_name DW_FORM_string + DW_AT_byte_size DW_FORM_data1 + DW_AT_encoding DW_FORM_data1 + diff --git a/binutils/testsuite/binutils-all/objdump.exp b/binutils/testsuite/binutils-all/objdump.exp index 335b8bd..b9416a4 100644 --- a/binutils/testsuite/binutils-all/objdump.exp +++ b/binutils/testsuite/binutils-all/objdump.exp @@ -158,6 +158,49 @@ if [regexp $want $got] then { fail "objdump -s" } +# Test objdump -s on a file that contains a compressed .debug section + +if {![binutils_assemble $srcdir/$subdir/dw2-compressed.S tmpdir/dw2-compressed.o]} then { + return +} +if [is_remote host] { + set compressed_testfile [remote_download host tmpdir/dw2-compressed.o] +} else { + set compressed_testfile tmpdir/dw2-compressed.o +} + +set got [remote_exec host "$OBJDUMP $OBJDUMPFLAGS -s -j .zdebug_abbrev $compressed_testfile" "" "/dev/null" "objdump.out"] + +if { [lindex $got 0] != 0 || ![string match "" [lindex $got 1]] } then { + fail "objdump -s -j .zdebug_abbrev (reason: unexpected output)" + send_log $got + send_log "\n" +} + +if { [regexp_diff objdump.out $srcdir/$subdir/objdump.s] } then { + fail "objdump -s -j .zdebug_abbrev" +} else { + pass "objdump -s -j .zdebug_abbrev" +} + +# Test objdump -W on a file that contains some compressed .debug sections + +set got [remote_exec host "$OBJDUMP $OBJDUMPFLAGS -W $compressed_testfile" "" "/dev/null" "objdump.out"] + +if { [lindex $got 0] != 0 || ![string match "" [lindex $got 1]] } then { + fail "objdump -W (reason: unexpected output)" + send_log $got + send_log "\n" +} + +if { [regexp_diff objdump.out $srcdir/$subdir/objdump.W] } then { + fail "objdump -W" +} else { + pass "objdump -W" +} + + + # Options which are not tested: -a -d -D -R -T -x -l --stabs # I don't see any generic way to test any of these other than -a. # Tests could be written for specific targets, and that should be done diff --git a/binutils/testsuite/binutils-all/objdump.s b/binutils/testsuite/binutils-all/objdump.s new file mode 100644 index 0000000..72c59d2 --- /dev/null +++ b/binutils/testsuite/binutils-all/objdump.s @@ -0,0 +1,9 @@ + +tmpdir/dw2-compressed.o: file format .* + +Contents of section .zdebug_abbrev: + 0000 5a4c4942 00000000 00000033 785e6314 ZLIB.......3x\^c. + 0010 64146013 62146464 e650e510 e6666060 d.`.b.dd.P...f`` + 0020 d263b0e7 b1e2b6e6 66e6f014 16641462 .c......f....d.b + 0030 74e00200 25780281 789c6360 60566160 t...%x..x.c``Va` + 0040 e6e0e6b6 e3660002 00049c00 92 .....f....... diff --git a/binutils/testsuite/binutils-all/readelf.exp b/binutils/testsuite/binutils-all/readelf.exp index 52be1ee..c879af7 100644 --- a/binutils/testsuite/binutils-all/readelf.exp +++ b/binutils/testsuite/binutils-all/readelf.exp @@ -208,6 +208,42 @@ proc readelf_wi_test {} { pass "readelf -wi" } +# This tests "readelf -wa", but on a file with a compressed +# .debug_abbrev section. + +proc readelf_compressed_wa_test {} { + global READELF + global READELFFLAGS + global srcdir + global subdir + + # Compile the compressed-debug-section test file. + if { [target_compile $srcdir/$subdir/dw2-compressed.S tmpdir/dw2-compressed.o object debug] != "" } { + verbose "Unable to compile test file." + untested "readelf -wa (compressed)" + return + } + + # Download it. + set tempfile [remote_download host tmpdir/dw2-compressed.o] + + # Run "readelf -wa" on it. + set got [remote_exec host "$READELF $READELFFLAGS -wa $tempfile" "" "/dev/null" "readelf.out"] + + # Upload the results. + set output [remote_upload host readelf.out] + + file_on_host delete $tempfile + + if { [string compare [file_contents readelf.out] [file_contents $srcdir/$subdir/readelf.wa]] != 0 } then { + fail "readelf -wa (compressed)" + verbose "output is \n[file_contents readelf.out]" 2 + verbose "expected is \n[file_contents $srcdir/$subdir/readelf.wa]" 2 + return + } + + pass "readelf -wa (compressed)" +} # Test readelf's dumping abilities. @@ -295,5 +331,6 @@ readelf_test -s $tempfile readelf.ss {} readelf_test -r $tempfile readelf.r {} readelf_wi_test +readelf_compressed_wa_test readelf_dump_test diff --git a/binutils/testsuite/binutils-all/readelf.wa b/binutils/testsuite/binutils-all/readelf.wa new file mode 100644 index 0000000..63892a4 --- /dev/null +++ b/binutils/testsuite/binutils-all/readelf.wa @@ -0,0 +1,24 @@ +Contents of the .zdebug_abbrev section: + + Number TAG + 1 DW_TAG_compile_unit [has children] + DW_AT_stmt_list DW_FORM_data4 + DW_AT_high_pc DW_FORM_addr + DW_AT_low_pc DW_FORM_addr + DW_AT_name DW_FORM_string + DW_AT_producer DW_FORM_string + DW_AT_language DW_FORM_data1 + 2 DW_TAG_subprogram [no children] + DW_AT_external DW_FORM_flag + DW_AT_decl_file DW_FORM_data1 + DW_AT_decl_line DW_FORM_data1 + DW_AT_name DW_FORM_string + DW_AT_type DW_FORM_ref4 + DW_AT_low_pc DW_FORM_addr + DW_AT_high_pc DW_FORM_addr + DW_AT_frame_base DW_FORM_block1 + 3 DW_TAG_base_type [no children] + DW_AT_name DW_FORM_string + DW_AT_byte_size DW_FORM_data1 + DW_AT_encoding DW_FORM_data1 + |