* lib/dwarf.exp (build_executable_from_fission_assembler): New proc.
authorDoug Evans <dje@google.com>
Fri, 20 Sep 2013 22:43:28 +0000 (22:43 +0000)
committerDoug Evans <dje@google.com>
Fri, 20 Sep 2013 22:43:28 +0000 (22:43 +0000)
* gdb.dwarf2/fission-base.S: Update.  Split out .dwo into separate
file.
* gdb.dwarf2/fission-loclists.S: Ditto.
* gdb.dwarf2/fission-reread.S: Ditto.
* gdb.dwarf2/fission-base.exp: Skip of remote host.  Compile with
build_executable_from_fission_assembler.
* gdb.dwarf2/fission-loclists.exp: Ditto.
* gdb.dwarf2/fission-reread.exp: Ditto.

gdb/testsuite/ChangeLog
gdb/testsuite/gdb.dwarf2/fission-base.S
gdb/testsuite/gdb.dwarf2/fission-base.exp
gdb/testsuite/gdb.dwarf2/fission-loclists.S
gdb/testsuite/gdb.dwarf2/fission-loclists.exp
gdb/testsuite/gdb.dwarf2/fission-reread.S
gdb/testsuite/gdb.dwarf2/fission-reread.exp
gdb/testsuite/lib/dwarf.exp

index 9dcdaa522464a51145348aa125017e18233601e1..7f91ee81cbd205a1552ea3edce31945866159ae6 100644 (file)
@@ -1,5 +1,15 @@
 2013-09-20  Doug Evans  <dje@google.com>
 
+       * lib/dwarf.exp (build_executable_from_fission_assembler): New proc.
+       * gdb.dwarf2/fission-base.S: Update.  Split out .dwo into separate
+       file.
+       * gdb.dwarf2/fission-loclists.S: Ditto.
+       * gdb.dwarf2/fission-reread.S: Ditto.
+       * gdb.dwarf2/fission-base.exp: Skip of remote host.  Compile with
+       build_executable_from_fission_assembler.
+       * gdb.dwarf2/fission-loclists.exp: Ditto.
+       * gdb.dwarf2/fission-reread.exp: Ditto.
+
        * lib/future.exp (gdb_find_objcopy, gdb_find_readelf): New procs.
        * lib/gdb.exp (build_id_debug_filename_get): Update to use them.
        (gdb_gnu_strip_debug): Ditto.
index 14b2494495cc1e03d18a562984b55844580bfa65..ccd6b236a08a590b085ce5c618db0fa670f8a805 100644 (file)
@@ -76,7 +76,7 @@ main:
 .LFE1:
        .size   main, .-main
 .Letext0:
-       .section        .debug_info.dwo,"",@progbits
+       .section        .debug_info.dwo,"e",@progbits
 .Ldebug_info0:
        .4byte  .Ldebug_info0_end - .Ldebug_info0 - 4 # Length of Compilation Unit Info
        .2byte  0x4     # DWARF version number
@@ -87,30 +87,30 @@ main:
        .byte   0x1     # DW_AT_language
        .ascii "gdb.dwarf2/fission-base.c\0"    # DW_AT_name
        .ascii "/tmp/src/gdb/testsuite\0"       # DW_AT_comp_dir
-       .byte   0       # DW_AT_GNU_dwo_id
-       .byte   0
-       .byte   0
-       .byte   0
-       .byte   0
-       .byte   0
-       .byte   0
-       .byte   0
+       .byte   1       # DW_AT_GNU_dwo_id
+       .byte   2
+       .byte   3
+       .byte   4
+       .byte   5
+       .byte   6
+       .byte   7
+       .byte   8
        .uleb128 0x2    # (DIE (0x89) DW_TAG_subprogram)
                        # DW_AT_external
        .ascii "func\0" # DW_AT_name
        .byte   0x1     # DW_AT_decl_file (fission-base.c)
        .byte   0x13    # DW_AT_decl_line
                        # DW_AT_prototyped
-       .4byte  .Ldebug_info0_int       # DW_AT_type
+       .4byte  .Ldebug_info0_int - .Ldebug_info0 # DW_AT_type
        .4byte  0x0     # DW_AT_ranges
        .uleb128 0x1    # DW_AT_frame_base
        .byte   0x9c    # DW_OP_call_frame_cfa
-       .4byte  .Ldebug_info0_int       # DW_AT_sibling
+       .4byte  .Ldebug_info0_int - .Ldebug_info0 # DW_AT_sibling
        .uleb128 0x3    # (DIE (0xa4) DW_TAG_formal_parameter)
        .ascii "arg\0"  # DW_AT_name
        .byte   0x1     # DW_AT_decl_file (fission-base.c)
        .byte   0x13    # DW_AT_decl_line
-       .4byte  .Ldebug_info0_int       # DW_AT_type
+       .4byte  .Ldebug_info0_int - .Ldebug_info0 # DW_AT_type
        .uleb128 0x2    # DW_AT_location
        .byte   0x91    # DW_OP_fbreg
        .sleb128 -20
@@ -125,7 +125,7 @@ main:
        .ascii "main\0" # DW_AT_name
        .byte   0x1     # DW_AT_decl_file (fission-base.c)
        .byte   0x19    # DW_AT_decl_line
-       .4byte  .Ldebug_info0_int       # DW_AT_type
+       .4byte  .Ldebug_info0_int - .Ldebug_info0 # DW_AT_type
        .uleb128 0x1    # DW_AT_low_pc
        .8byte  .LFE1-.LFB1     # DW_AT_high_pc
        .uleb128 0x1    # DW_AT_frame_base
@@ -143,21 +143,19 @@ main:
        .8byte  .Letext0-.Ltext0        # DW_AT_high_pc
        .4byte  .Ldebug_line0   # DW_AT_stmt_list
        .ascii "/tmp/src/gdb/testsuite\0"       # DW_AT_comp_dir
-       # Normally dwo_name would be "fission-base.dwo".
-       # Simplification: Leave the DWO contents in the executable.
-       .ascii "fission-base\0" # DW_AT_GNU_dwo_name
+       .ascii "gdb.dwarf2/fission-base.dwo\0"  # DW_AT_GNU_dwo_name
        .4byte  .Ldebug_pubnames0       # DW_AT_GNU_pubnames
        .4byte  .Ldebug_pubtypes0       # DW_AT_GNU_pubtypes
        .4byte  .Ldebug_addr0_begin     # DW_AT_GNU_addr_base
        .4byte  .Ldebug_ranges0_begin   # DW_AT_GNU_ranges_base
-       .byte   0       # DW_AT_GNU_dwo_id
-       .byte   0
-       .byte   0
-       .byte   0
-       .byte   0
-       .byte   0
-       .byte   0
-       .byte   0
+       .byte   1       # DW_AT_GNU_dwo_id
+       .byte   2
+       .byte   3
+       .byte   4
+       .byte   5
+       .byte   6
+       .byte   7
+       .byte   8
 .Lskeleton_debug_info0_end:
        .section        .debug_abbrev,"",@progbits
 .Lskeleton_debug_abbrev0:
@@ -187,7 +185,7 @@ main:
        .byte   0
        .byte   0
        .byte   0       # end of skeleton .debug_abbrev
-       .section        .debug_abbrev.dwo,"",@progbits
+       .section        .debug_abbrev.dwo,"e",@progbits
 .Ldebug_abbrev0:
        .uleb128 0x1    # (abbrev code)
        .uleb128 0x11   # (TAG: DW_TAG_compile_unit)
@@ -275,26 +273,29 @@ main:
        .byte   0
        .byte   0
        .byte   0
-       .section        .debug_pubnames,"",@progbits
+       .section        .debug_gnu_pubnames,"",@progbits
 .Ldebug_pubnames0:
-       .4byte  0x20    # Length of Public Names Info
-       .2byte  0x2     # DWARF Version
-       .4byte  .Lskeleton_debug_info0  # Offset of Compilation Unit Info
-       .4byte  0xd2    # Compilation Unit Length
-       .4byte  0x89    # DIE offset
+       .long   0x22    # Pub Info Length
+       .value  0x2     # DWARF Version
+       .long   .Lskeleton_debug_info0  # Offset of Compilation Unit Info
+       .long   0x59    # Compilation Unit Length
+       .long   0x18    # DIE offset
+       .byte   0x30    # GDB-index flags
        .ascii "func\0" # external name
-       .4byte  0xba    # DIE offset
+       .long   0x45    # DIE offset
+       .byte   0x30    # GDB-index flags
        .ascii "main\0" # external name
-       .4byte  0
-       .section        .debug_pubtypes,"",@progbits
+       .long   0
+       .section        .debug_gnu_pubtypes,"",@progbits
 .Ldebug_pubtypes0:
-       .4byte  0x16    # Length of Public Type Names Info
-       .2byte  0x2     # DWARF Version
-       .4byte  .Lskeleton_debug_info0  # Offset of Compilation Unit Info
-       .4byte  0xd2    # Compilation Unit Length
-       .4byte  .Ldebug_info0_int       # DIE offset
+       .long   0x17    # Pub Info Length
+       .value  0x2     # DWARF Version
+       .long   .Lskeleton_debug_info0  # Offset of Compilation Unit Info
+       .long   0x59    # Compilation Unit Length
+       .long   0x3e    # DIE offset
+       .byte   0x90    # GDB-index flags
        .ascii "int\0"  # external name
-       .4byte  0
+       .long   0
        .section        .debug_aranges,"",@progbits
        .4byte  0x2c    # Length of Address Ranges Info
        .2byte  0x2     # DWARF Version
@@ -309,7 +310,7 @@ main:
        .8byte  0
        .section        .debug_line,"",@progbits
 .Ldebug_line0:
-       .section        .debug_line.dwo,"",@progbits
+       .section        .debug_line.dwo,"e",@progbits
 .Lskeleton_debug_line0:
        .4byte  .LELT0-.LSLT0   # Length of Source Line Info
 .LSLT0:
index 58448f8b5189f2e815139193fd550bcb2ac01943..bb4eb7716d76d8456521d952847e8bb83d32a71f 100644 (file)
 
 load_lib dwarf.exp
 
+# We run objcopy locally to split out the .dwo file.
+if [is_remote host] {
+    return 0
+}
+
 # This test can only be run on targets which support DWARF-2 and use gas.
 if ![dwarf2_support] {
     return 0  
@@ -25,22 +30,14 @@ if {![istarget x86_64-*] || ![is_lp64_target]} {
     return 0
 }
 
-set basename "fission-base"
-
 standard_testfile .S
 
-if { [build_executable "$testfile.exp" "$testfile" "$srcfile" {nodebug}] } {
+if [build_executable_from_fission_assembler \
+       "$testfile.exp" "$binfile" "$srcfile" {nodebug}] {
     return -1
 }
 
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
-
-gdb_test_no_output "set debug-file-directory [file dirname $binfile]" \
-    "set debug-file-directory"
-
-gdb_load ${binfile}
+clean_restart ${binfile}
 
 if ![runto_main] {
     return -1
index 33fd8fabb167244b4e1cbd35b9c6970d5afcb6fe..876c6105f44289ae2cea5e689023df2d217d31fc 100644 (file)
@@ -239,13 +239,8 @@ main:
        .byte   0xd6
        .byte   0x5
        .4byte  .Ldebug_ranges0 # DW_AT_GNU_ranges_base
-       .ascii "/tmp\0" # DW_AT_comp_dir
-       # Normally dwo_name would be "fission-loclists.dwo".
-       # Simplification: Leave the DWO contents in the executable.
-       # "gdb.dwarf2/" is included so that gdb can load the file without
-       # having to set "debug-file-directory".  This is useful when
-       # testing with cc-with-tweaks.sh -i.
-       .ascii "gdb.dwarf2/fission-loclists\0"  # DW_AT_GNU_dwo_name
+       .ascii "/tmp/src/gdb/testsuite\0"       # DW_AT_comp_dir
+       .ascii "gdb.dwarf2/fission-loclists.dwo\0"      # DW_AT_GNU_dwo_name
        .4byte  .Ldebug_pubnames0       # DW_AT_GNU_pubnames
        .4byte  .Ldebug_pubtypes0       # DW_AT_GNU_pubtypes
        .4byte  .Ldebug_addr0   # DW_AT_GNU_addr_base
@@ -487,10 +482,47 @@ main:
        .byte   0       # Location list terminator (*.LLST1)
        .section        .debug_gnu_pubnames,"",@progbits
 .Ldebug_pubnames0:
-       .4byte  0
+       .long   0x28    # Pub Info Length
+       .value  0x2     # DWARF Version
+       .long   .Lskeleton_debug_info0  # Offset of Compilation Unit Info
+       .long   0xa6    # Compilation Unit Length
+       .long   0x18    # DIE offset
+       .byte   0x30    # GDB-index flags
+       .ascii "foo\0"  # external name
+       .long   0x47    # DIE offset
+       .byte   0x30    # GDB-index flags
+       .ascii "main\0" # external name
+       .long   0x94    # DIE offset
+       .byte   0x20    # GDB-index flags
+       .ascii "v\0"    # external name
+       .long   0
        .section        .debug_gnu_pubtypes,"",@progbits
 .Ldebug_pubtypes0:
-       .4byte  0
+       .long   0x21    # Pub Info Length
+       .value  0x2     # DWARF Version
+       .long   .Lskeleton_debug_info0  # Offset of Compilation Unit Info
+       .long   0xa6    # Compilation Unit Length
+       .long   0x40    # DIE offset
+       .byte   0x90    # GDB-index flags
+       .ascii "int\0"  # external name
+       .long   0x90    # DIE offset
+       .byte   0x90    # GDB-index flags
+       .ascii "char\0" # external name
+       .long   0
+       .section        .debug_aranges,"",@progbits
+       .long   0x3c    # Length of Address Ranges Info
+       .value  0x2     # DWARF Version
+       .long   .Lskeleton_debug_info0  # Offset of Compilation Unit Info
+       .byte   0x8     # Size of Address
+       .byte   0       # Size of Segment Descriptor
+       .value  0       # Pad to 16 byte boundary
+       .value  0
+       .quad   .Ltext0 # Address
+       .quad   .Letext0-.Ltext0        # Length
+       .quad   .LFB1   # Address
+       .quad   .LFE1-.LFB1     # Length
+       .quad   0
+       .quad   0
        .section        .debug_aranges,"",@progbits
        .4byte  0x3c    # Length of Address Ranges Info
        .value  0x2     # DWARF Version
index 1151fad586f6ea5df07c7f52e7689a32acc1ed69..29ccd1bb9befc1343a3f7d663ddd888d8f5bbaf6 100644 (file)
 
 load_lib dwarf.exp
 
+# We run objcopy locally to split out the .dwo file.
+if [is_remote host] {
+    return 0
+}
+
 # This test can only be run on targets which support DWARF-2 and use gas.
 if ![dwarf2_support] {
     return 0  
@@ -25,14 +30,15 @@ if {![istarget x86_64-*] || ![is_lp64_target]} {
     return 0
 }
 
-set basename "fission-loclists"
-
 standard_testfile .S
 
-if { [prepare_for_testing "$testfile.exp" "$testfile" "$srcfile" {nodebug}] } {
+if [build_executable_from_fission_assembler \
+       "$testfile.exp" "$binfile" "$srcfile" {nodebug}] {
     return -1
 }
 
+clean_restart ${binfile}
+
 if ![runto_main] {
     return -1
 }
index e566cc6a45a758c1bd76374fa929ad97c7bf4f18..808260755c0b4c125a4c0c91111eec8b5f47235a 100644 (file)
@@ -100,12 +100,12 @@ main:
        .byte   0x4     /* DW_AT_byte_size */
        .byte   0x1     /* DW_AT_decl_file (fission-reread.cc) */
        .byte   0x1     /* DW_AT_decl_line */
-       .4byte  .Ltu_int        /* DW_AT_sibling */
+       .4byte  .Ltu_int - .Ltu_start_dwo /* DW_AT_sibling */
        .uleb128 0x3    /* (DIE (0x31) DW_TAG_member) */
        .ascii "bar\0"  /* DW_AT_name */
        .byte   0x1     /* DW_AT_decl_file (fission-reread.cc) */
        .byte   0x4     /* DW_AT_decl_line */
-       .4byte  .Ltu_int        /* DW_AT_type */
+       .4byte  .Ltu_int - .Ltu_start_dwo /* DW_AT_type */
        .byte   0       /* DW_AT_data_member_location */
        .byte   0x1     /* DW_AT_accessibility */
        .byte   0       /* end of children of DIE 0x25 */
@@ -134,9 +134,7 @@ main:
        .4byte  0       /* Offset to Type DIE */
        .uleb128 0x2    /* (DIE (0) DW_TAG_type_unit) */
        .ascii "/tmp/src/gdb/testsuite\0"       /* DW_AT_comp_dir */
-       /* Normally dwo_name would be "fission-reread.dwo".
-          Simplification: Leave the DWO contents in the executable.  */
-       .ascii "fission-reread\0"       /* DW_AT_GNU_dwo_name */
+       .ascii "gdb.dwarf2/fission-reread.dwo\0" /* DW_AT_GNU_dwo_name */
        .4byte  .Ldebug_pubnames0       /* DW_AT_GNU_pubnames */
        .4byte  .Ldebug_pubtypes0       /* DW_AT_GNU_pubtypes */
        .4byte  .Ldebug_addr0   /* DW_AT_GNU_addr_base */
@@ -153,14 +151,14 @@ main:
        .byte   0x4     /* DW_AT_language */
        .ascii "gdb.dwarf2/fission-reread.cc\0" /* DW_AT_name */
        .ascii "/tmp/src/gdb/testsuite\0"       /* DW_AT_comp_dir */
-       .byte   0       /* DW_AT_GNU_dwo_id */
-       .byte   0
-       .byte   0
-       .byte   0
-       .byte   0
-       .byte   0
-       .byte   0
-       .byte   0
+       .byte   1       /* DW_AT_GNU_dwo_id */
+       .byte   2
+       .byte   3
+       .byte   4
+       .byte   5
+       .byte   6
+       .byte   7
+       .byte   8
 .Lcu_int:
        .uleb128 0x4    /* (DIE (0x7f) DW_TAG_base_type) */
        .byte   0x4     /* DW_AT_byte_size */
@@ -171,7 +169,7 @@ main:
        .ascii "main\0" /* DW_AT_name */
        .byte   0x1     /* DW_AT_decl_file (fission-reread.cc) */
        .byte   0xa     /* DW_AT_decl_line */
-       .4byte  .Lcu_int        /* DW_AT_type */
+       .4byte  .Lcu_int - .Lcu_start_dwo /* DW_AT_type */
        .uleb128 0      /* DW_AT_low_pc */
        .4byte  .LFE0-.LFB0     /* DW_AT_high_pc */
        .uleb128 0x1    /* DW_AT_frame_base */
@@ -207,23 +205,18 @@ main:
        .4byte  .Letext0-.Ltext0        /* DW_AT_high_pc */
        .4byte  .Ldebug_line0   /* DW_AT_stmt_list */
        .ascii "/tmp/src/gdb/testsuite\0"       /* DW_AT_comp_dir */
-       /* Normally dwo_name would be "fission-reread.dwo".
-          Simplification: Leave the DWO contents in the executable.
-          "gdb.dwarf2/" is included so that gdb can load the file without
-          having to set "debug-file-directory".  This is useful when
-          testing with cc-with-tweaks.sh -i.  */
-       .ascii "gdb.dwarf2/fission-reread\0"    /* DW_AT_GNU_dwo_name */
+       .ascii "gdb.dwarf2/fission-reread.dwo\0" /* DW_AT_GNU_dwo_name */
        .4byte  .Ldebug_pubnames0       /* DW_AT_GNU_pubnames */
        .4byte  .Ldebug_pubtypes0       /* DW_AT_GNU_pubtypes */
        .4byte  .Ldebug_addr0   /* DW_AT_GNU_addr_base */
-       .byte   0       /* DW_AT_GNU_dwo_id */
-       .byte   0
-       .byte   0
-       .byte   0
-       .byte   0
-       .byte   0
-       .byte   0
-       .byte   0
+       .byte   1       /* DW_AT_GNU_dwo_id */
+       .byte   2
+       .byte   3
+       .byte   4
+       .byte   5
+       .byte   6
+       .byte   7
+       .byte   8
 .Lcu_end:
 
        .section        .debug_abbrev
@@ -411,10 +404,10 @@ main:
        .ascii "foo\0"  /* external name */
        .4byte  0
        .section        .debug_aranges
-       .4byte  0x2c    /* Length of Address Ranges Info */
+       .4byte  0x1c    /* Length of Address Ranges Info */
        .2byte  0x2     /* DWARF Version */
        .4byte  .Lskeleton_debug_info0  /* Offset of Compilation Unit Info */
-       .byte   0x8     /* Size of Address */
+       .byte   0x4     /* Size of Address */
        .byte   0       /* Size of Segment Descriptor */
        .2byte  0       /* Pad to 16 byte boundary */
        .2byte  0
index f275308d47334e7b051754534b2dee937300839e..d2d0d4e8691e086ac1061a60a78f11b9156d2d5d 100644 (file)
 
 load_lib dwarf.exp
 
+# We run objcopy locally to split out the .dwo file.
+if [is_remote host] {
+    return 0
+}
+
 # This test can only be run on targets which support DWARF-2 and use gas.
 if ![dwarf2_support] {
     return 0  
 }
 
-set basename "fission-reread"
-
 standard_testfile .S
 
-if { [build_executable "$testfile.exp" "$testfile" "$srcfile" {nodebug}] } {
+if [build_executable_from_fission_assembler \
+       "$testfile.exp" "$binfile" "$srcfile" {nodebug}] {
     return -1
 }
 
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
-
-gdb_test_no_output "set debug-file-directory [file dirname $binfile]" \
-    "set debug-file-directory"
-
-gdb_load ${binfile}
+clean_restart ${binfile}
 
 gdb_test "break main" "Breakpoint.*at.*"
 
index 39773843748004db19f4548f09bf14d3bcc84b9b..5264def812a838e98d8edff3847e97a94e1f9177 100644 (file)
@@ -29,6 +29,63 @@ proc dwarf2_support {} {
     return 0
 }
 
+# Build an executable from a fission-based .S file.
+# This handles the extra work of splitting the .o into non-dwo and dwo
+# pieces, making sure the .dwo is available if we're using cc-with-tweaks.sh
+# to build a .dwp file.
+# The arguments and results are the same as for build_executable.
+#
+# Current restrictions:
+# - only supports one source file
+# - cannot be run on remote hosts
+
+proc build_executable_from_fission_assembler { testname executable sources options } {
+    verbose -log "build_executable_from_fission_assembler $testname $executable $sources $options"
+    if { [llength $sources] != 1 } {
+       error "Only one source file supported."
+    }
+    if [is_remote host] {
+       error "Remote hosts are not supported."
+    }
+
+    global srcdir subdir
+    set source_file ${srcdir}/${subdir}/${sources}
+    set root_name [file rootname [file tail $source_file]]
+    set output_base [standard_output_file $root_name]
+    set object_file ${output_base}.o
+    set dwo_file ${output_base}.dwo
+    set object_options "object $options"
+    set objcopy [gdb_find_objcopy]
+
+    set result [gdb_compile $source_file $object_file object $options]
+    if { "$result" != "" } {
+       return -1
+    }
+
+    set command "$objcopy --extract-dwo $object_file $dwo_file"
+    verbose -log "Executing $command"
+    set result [catch "exec $command" output]
+    verbose -log "objcopy --extract-dwo output: $output"
+    if { $result == 1 } {
+       return -1
+    }
+
+    set command "$objcopy --strip-dwo $object_file"
+    verbose -log "Executing $command"
+    set result [catch "exec $command" output]
+    verbose -log "objcopy --strip-dwo output: $output"
+    if { $result == 1 } {
+       return -1
+    }
+
+    set result [gdb_compile $object_file $executable executable {nodebug}]
+    if { "$result" != "" } {
+       return -1
+    }
+
+    return 0
+}
+
 # A DWARF assembler.
 #
 # All the variables in this namespace are private to the
This page took 0.063096 seconds and 4 git commands to generate.