Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [RFA] Make cu/tu functions in dwarf.exp take a list of options
@ 2013-05-17 17:28 Doug Evans
  2013-05-17 18:04 ` Tom Tromey
  0 siblings, 1 reply; 6+ messages in thread
From: Doug Evans @ 2013-05-17 17:28 UTC (permalink / raw)
  To: gdb-patches, tromey

Hi.
I needed to add another parameter to the cu/tu functions in dwarf.exp.
And if I need to add one I may need to add another.
This patch changes the existing set of options to be a list.

The testcase that uses this is a separate patch, but it may be awhile
in coming, sigh.
I'd like to get this in now so that any new tests that get written
don't also have to be updated when this goes in.

Note: I made the defaults 64 bit addresses and dwarf version 4.
Seems reasonable these days.  It does change the dwarf version from 2 to 4
for some of the existing tests, but I didn't find an issue with this.

Ok to check in?
Regression tested on amd64-linux.

2013-05-17  Doug Evans  <dje@google.com>

	* lib/dwarf.exp (Dwarf): New variable _abbrev_section.
	(_handle_DW_TAG): Use it.
	(cu): Replace parameters is_64, version, addr_size with options.
	All callers updated.  Add Fission support.

Index: testsuite/gdb.dwarf2/implptrconst.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.dwarf2/implptrconst.exp,v
retrieving revision 1.2
diff -u -p -r1.2 implptrconst.exp
--- testsuite/gdb.dwarf2/implptrconst.exp	13 May 2013 19:32:17 -0000	1.2
+++ testsuite/gdb.dwarf2/implptrconst.exp	17 May 2013 17:03:47 -0000
@@ -29,7 +29,7 @@ set asm_file [standard_output_file $srcf
 Dwarf::assemble $asm_file {
     # Creating a CU with 4-byte addresses lets this test link on both
     # 32- and 64-bit machines.
-    cu 0 2 4 {
+    cu { addr_size 4 } {
  	compile_unit {} {
 	    declare_labels byte_label size_type_label array_label
 	    declare_labels var_label ptr_label
Index: testsuite/gdb.dwarf2/method-ptr.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.dwarf2/method-ptr.exp,v
retrieving revision 1.3
diff -u -p -r1.3 method-ptr.exp
--- testsuite/gdb.dwarf2/method-ptr.exp	1 Feb 2013 19:33:47 -0000	1.3
+++ testsuite/gdb.dwarf2/method-ptr.exp	17 May 2013 17:03:47 -0000
@@ -29,7 +29,7 @@ Dwarf::assemble $asm_file {
     declare_labels int_label float_label struct_label
     declare_labels ptr_label subr_label memptr_label
 
-    cu 0 2 8 {
+    cu {} {
 	compile_unit {{language @DW_LANG_C_plus_plus}} {
 	    int_label: base_type {
 		{name int}
Index: testsuite/gdb.dwarf2/missing-sig-type.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.dwarf2/missing-sig-type.exp,v
retrieving revision 1.1
diff -u -p -r1.1 missing-sig-type.exp
--- testsuite/gdb.dwarf2/missing-sig-type.exp	17 Apr 2013 21:07:09 -0000	1.1
+++ testsuite/gdb.dwarf2/missing-sig-type.exp	17 May 2013 17:03:47 -0000
@@ -26,7 +26,7 @@ standard_testfile main.c missing-sig-typ
 # Make some DWARF for the test.
 set asm_file [standard_output_file $srcfile2]
 Dwarf::assemble $asm_file {
-    cu 0 4 8 {
+    cu {} {
  	compile_unit {} {
 	    declare_labels typedef_label
 
@@ -38,7 +38,7 @@ Dwarf::assemble $asm_file {
 	}
     }
 
-    tu 0 4 8 0x1122334455667788 the_type {
+    tu {} 0x1122334455667788 the_type {
 	type_unit {} {
 	    the_type: base_type {
 		{name int}
Index: testsuite/gdb.dwarf2/nostaticblock.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.dwarf2/nostaticblock.exp,v
retrieving revision 1.1
diff -u -p -r1.1 nostaticblock.exp
--- testsuite/gdb.dwarf2/nostaticblock.exp	25 Apr 2013 16:25:37 -0000	1.1
+++ testsuite/gdb.dwarf2/nostaticblock.exp	17 May 2013 17:03:47 -0000
@@ -26,7 +26,7 @@ standard_testfile main.c .S
 # Make some DWARF for the test.
 set asm_file [standard_output_file $srcfile2]
 Dwarf::assemble $asm_file {
-    cu 0 2 8 {
+    cu {} {
  	compile_unit {
 	    {low_pc 0x104320 DW_FORM_addr}
 	    {high_pc 0x1045ed DW_FORM_addr}
Index: testsuite/gdb.dwarf2/subrange.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.dwarf2/subrange.exp,v
retrieving revision 1.1
diff -u -p -r1.1 subrange.exp
--- testsuite/gdb.dwarf2/subrange.exp	18 Feb 2013 21:04:28 -0000	1.1
+++ testsuite/gdb.dwarf2/subrange.exp	17 May 2013 17:03:47 -0000
@@ -26,7 +26,7 @@ standard_testfile method-ptr.cc subrange
 # Make some DWARF for the test.
 set asm_file [standard_output_file $srcfile2]
 Dwarf::assemble $asm_file {
-    cu 0 2 8 {
+    cu {} {
  	compile_unit {{language @DW_LANG_Pascal83}} {
 	    declare_labels byte_label typedef_label array_label
 
Index: testsuite/lib/dwarf.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/lib/dwarf.exp,v
retrieving revision 1.8
diff -u -p -r1.8 dwarf.exp
--- testsuite/lib/dwarf.exp	6 May 2013 19:44:04 -0000	1.8
+++ testsuite/lib/dwarf.exp	17 May 2013 17:03:47 -0000
@@ -137,6 +137,10 @@ namespace eval Dwarf {
     # Otherwise, this is the name of a section to write to.
     variable _defer
 
+    # The abbrev section.  Typically .debug_abbrev but can be .debug_abbrev.dwo
+    # for Fission.
+    variable _abbrev_section
+
     # The next available abbrev number in the current CU's abbrev
     # table.
     variable _abbrev_num
@@ -401,6 +405,7 @@ namespace eval Dwarf {
     }
 
     proc _handle_DW_TAG {tag_name {attrs {}} {children {}}} {
+	variable _abbrev_section
 	variable _abbrev_num
 	variable _constants
 
@@ -409,7 +414,7 @@ namespace eval Dwarf {
 
 	# We somewhat wastefully emit a new abbrev entry for each tag.
 	# There's no reason for this other than laziness.
-	_defer_output .debug_abbrev {
+	_defer_output $_abbrev_section {
 	    _op .uleb128 $my_abbrev "Abbrev start"
 	    _op .uleb128 $_constants($tag_name) $tag_name
 	    _op .byte $has_children "has_children"
@@ -429,13 +434,13 @@ namespace eval Dwarf {
 
 	    _handle_DW_FORM $attr_form $attr_value
 
-	    _defer_output .debug_abbrev {
+	    _defer_output $_abbrev_section {
 		_op .uleb128 $_constants($attr_name) $attr_name
 		_op .uleb128 $_constants($attr_form) $attr_form
 	    }
 	}
 
-	_defer_output .debug_abbrev {
+	_defer_output $_abbrev_section {
 	    # Terminator.
 	    _op .byte 0x0 Terminator
 	    _op .byte 0x0 Terminator
@@ -667,29 +672,52 @@ namespace eval Dwarf {
     }
 
     # Emit a DWARF CU.
-    # IS_64 is a boolean which is true if you want to emit 64-bit
-    # DWARF, and false for 32-bit DWARF.
-    # VERSION is the DWARF version number to emit.
-    # ADDR_SIZE is the size of addresses in bytes.
+    # OPTIONS is a list with an even number of elements containing
+    # option-name and option-value pairs.
+    # Current options are:
+    # is_64 0|1    - boolean indicating if you want to emit 64-bit DWARF
+    #                default = 0 (32-bit)
+    # version n    - DWARF version number to emit
+    #                default = 4
+    # addr_size n  - the size of addresses, 32 or 64
+    #                default = 64
+    # fission 0|1  - boolean indicating if generating Fission debug info
+    #                default = 0
     # BODY is Tcl code that emits the DIEs which make up the body of
     # the CU.  It is evaluated in the caller's context.
-    proc cu {is_64 version addr_size body} {
+    proc cu {options body} {
 	variable _cu_count
+	variable _abbrev_section
 	variable _abbrev_num
 	variable _cu_label
 	variable _cu_version
 	variable _cu_addr_size
 	variable _cu_offset_size
 
-	set _cu_version $version
-	if {$is_64} {
-	    set _cu_offset_size 8
-	} else {
-	    set _cu_offset_size 4
+	# Establish the defaults.
+	set is_64 0
+	set _cu_version 4
+	set _cu_addr_size 8
+	set fission 0
+	set section ".debug_info"
+	set _abbrev_section ".debug_abbrev"
+
+	foreach { name value } $options {
+	    switch -exact -- $name {
+		is_64 { set is_64 $value }
+		version { set _cu_version $value }
+		addr_size { set _cu_addr_size $value }
+		fission { set fission $value }
+		default { error "unknown option $name" }
+	    }
+	}
+	set _cu_offset_size [expr { $is_64 ? 8 : 4 }]
+	if { $fission } {
+	    set section ".debug_info.dwo"
+	    set _abbrev_section ".debug_abbrev.dwo"
 	}
-	set _cu_addr_size $addr_size
 
-	_section .debug_info
+	_section $section
 
 	set cu_num [incr _cu_count]
 	set my_abbrevs [_compute_label "abbrev${cu_num}_begin"]
@@ -707,17 +735,17 @@ namespace eval Dwarf {
 	    _op .4byte "$end_label - $start_label"
 	}
 	define_label $start_label
-	_op .2byte $version Version
+	_op .2byte $_cu_version Version
 	_op .4byte $my_abbrevs Abbrevs
-	_op .byte $addr_size "Pointer size"
+	_op .byte $_cu_addr_size "Pointer size"
 
-	_defer_output .debug_abbrev {
+	_defer_output $_abbrev_section {
 	    define_label $my_abbrevs
 	}
 
 	uplevel $body
 
-	_defer_output .debug_abbrev {
+	_defer_output $_abbrev_section {
 	    # Emit the terminator.
 	    _op .byte 0x0 Terminator
 	    _op .byte 0x0 Terminator
@@ -727,31 +755,55 @@ namespace eval Dwarf {
     }
 
     # Emit a DWARF TU.
-    # IS_64 is a boolean which is true if you want to emit 64-bit
-    # DWARF, and false for 32-bit DWARF.
-    # VERSION is the DWARF version number to emit.
-    # ADDR_SIZE is the size of addresses in bytes.
+    # OPTIONS is a list with an even number of elements containing
+    # option-name and option-value pairs.
+    # Current options are:
+    # is_64 0|1    - boolean indicating if you want to emit 64-bit DWARF
+    #                default = 0 (32-bit)
+    # version n    - DWARF version number to emit
+    #                default = 4
+    # addr_size n  - the size of addresses, 32 or 64
+    #                default = 64
+    # fission 0|1  - boolean indicating if generating Fission debug info
+    #                default = 0
     # SIGNATURE is the 64-bit signature of the type.
-    # TYPE_LABEL is the label of the type defined by this TU.
+    # TYPE_LABEL is the label of the type defined by this TU,
+    # or "" if there is no type (i.e., type stubs in Fission).
     # BODY is Tcl code that emits the DIEs which make up the body of
-    # the CU.  It is evaluated in the caller's context.
-    proc tu {is_64 version addr_size signature type_label body} {
+    # the TU.  It is evaluated in the caller's context.
+    proc tu {options signature type_label body} {
 	variable _cu_count
+	variable _abbrev_section
 	variable _abbrev_num
 	variable _cu_label
 	variable _cu_version
 	variable _cu_addr_size
 	variable _cu_offset_size
 
-	set _cu_version $version
-	if {$is_64} {
-	    set _cu_offset_size 8
-	} else {
-	    set _cu_offset_size 4
+	# Establish the defaults.
+	set is_64 0
+	set _cu_version 4
+	set _cu_addr_size 8
+	set fission 0
+	set section ".debug_types"
+	set _abbrev_section ".debug_abbrev"
+
+	foreach { name value } $options {
+	    switch -exact -- $name {
+		is_64 { set is_64 $value }
+		version { set _cu_version $value }
+		addr_size { set _cu_addr_size $value }
+		fission { set fission $value }
+		default { error "unknown option $name" }
+	    }
+	}
+	set _cu_offset_size [expr { $is_64 ? 8 : 4 }]
+	if { $fission } {
+	    set section ".debug_types.dwo"
+	    set _abbrev_section ".debug_abbrev.dwo"
 	}
-	set _cu_addr_size $addr_size
 
-	_section .debug_types
+	_section $section
 
 	set cu_num [incr _cu_count]
 	set my_abbrevs [_compute_label "abbrev${cu_num}_begin"]
@@ -769,25 +821,33 @@ namespace eval Dwarf {
 	    _op .4byte "$end_label - $start_label"
 	}
 	define_label $start_label
-	_op .2byte $version Version
+	_op .2byte $_cu_version Version
 	_op .4byte $my_abbrevs Abbrevs
-	_op .byte $addr_size "Pointer size"
+	_op .byte $_cu_addr_size "Pointer size"
 	_op .8byte $signature Signature
-	uplevel declare_labels $type_label
-	upvar $type_label my_type_label
-	if {$is_64} {
-	    _op .8byte "$my_type_label - $_cu_label"
+	if { $type_label != "" } {
+	    uplevel declare_labels $type_label
+	    upvar $type_label my_type_label
+	    if {$is_64} {
+		_op .8byte "$my_type_label - $_cu_label"
+	    } else {
+		_op .4byte "$my_type_label - $_cu_label"
+	    }
 	} else {
-	    _op .4byte "$my_type_label - $_cu_label"
+	    if {$is_64} {
+		_op .8byte 0
+	    } else {
+		_op .4byte 0
+	    }
 	}
 
-	_defer_output .debug_abbrev {
+	_defer_output $_abbrev_section {
 	    define_label $my_abbrevs
 	}
 
 	uplevel $body
 
-	_defer_output .debug_abbrev {
+	_defer_output $_abbrev_section {
 	    # Emit the terminator.
 	    _op .byte 0x0 Terminator
 	    _op .byte 0x0 Terminator


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [RFA] Make cu/tu functions in dwarf.exp take a list of options
  2013-05-17 17:28 [RFA] Make cu/tu functions in dwarf.exp take a list of options Doug Evans
@ 2013-05-17 18:04 ` Tom Tromey
  2013-05-17 18:20   ` Doug Evans
  2013-05-20 22:09   ` Doug Evans
  0 siblings, 2 replies; 6+ messages in thread
From: Tom Tromey @ 2013-05-17 18:04 UTC (permalink / raw)
  To: Doug Evans; +Cc: gdb-patches

>>>>> "Doug" == Doug Evans <dje@google.com> writes:

Doug> Ok to check in?
Doug> Regression tested on amd64-linux.

Looks good to me.

Doug> 2013-05-17  Doug Evans  <dje@google.com>

Doug> 	* lib/dwarf.exp (Dwarf): New variable _abbrev_section.
Doug> 	(_handle_DW_TAG): Use it.
Doug> 	(cu): Replace parameters is_64, version, addr_size with options.
Doug> 	All callers updated.  Add Fission support.

I thought we were supposed to list all the changed files, even in this
case.  If not, it would be nice to know, so I can stop doing that in the
future.

Tom


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [RFA] Make cu/tu functions in dwarf.exp take a list of options
  2013-05-17 18:04 ` Tom Tromey
@ 2013-05-17 18:20   ` Doug Evans
  2013-05-20  5:40     ` Joel Brobecker
  2013-05-20 22:09   ` Doug Evans
  1 sibling, 1 reply; 6+ messages in thread
From: Doug Evans @ 2013-05-17 18:20 UTC (permalink / raw)
  To: Tom Tromey; +Cc: gdb-patches

On Fri, May 17, 2013 at 11:04 AM, Tom Tromey <tromey@redhat.com> wrote:
>>>>>> "Doug" == Doug Evans <dje@google.com> writes:
>
> Doug> Ok to check in?
> Doug> Regression tested on amd64-linux.
>
> Looks good to me.
>
> Doug> 2013-05-17  Doug Evans  <dje@google.com>
>
> Doug>   * lib/dwarf.exp (Dwarf): New variable _abbrev_section.
> Doug>   (_handle_DW_TAG): Use it.
> Doug>   (cu): Replace parameters is_64, version, addr_size with options.
> Doug>   All callers updated.  Add Fission support.
>
> I thought we were supposed to list all the changed files, even in this
> case.  If not, it would be nice to know, so I can stop doing that in the
> future.

I've always gone by this in standards.texi.
I don't see any amendment to this in the two wiki pages on coding standards.
[OTOH I haven't been using uppercase for parameter names, but that's typical
in gdb changelogs.]

@node Simple Changes
@subsection Simple Changes

Certain simple kinds of changes don't need much detail in the change
log.

When you change the calling sequence of a function in a simple fashion,
and you change all the callers of the function to use the new calling
sequence, there is no need to make individual entries for all the
callers that you changed.  Just write in the entry for the function
being called, ``All callers changed''---like this:

@example
* keyboard.c (Fcommand_execute): New arg SPECIAL.
All callers changed.
@end example


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [RFA] Make cu/tu functions in dwarf.exp take a list of options
  2013-05-17 18:20   ` Doug Evans
@ 2013-05-20  5:40     ` Joel Brobecker
  2013-05-20 16:42       ` Doug Evans
  0 siblings, 1 reply; 6+ messages in thread
From: Joel Brobecker @ 2013-05-20  5:40 UTC (permalink / raw)
  To: Doug Evans; +Cc: Tom Tromey, gdb-patches

> When you change the calling sequence of a function in a simple fashion,
> and you change all the callers of the function to use the new calling
> sequence, there is no need to make individual entries for all the
> callers that you changed.  Just write in the entry for the function
> being called, ``All callers changed''---like this:

FWIW: No real opinion, but I intepreted the above in the context
of the same file only. I find that listing all the files adjusted
was fairly easy, so I thought the added information was worth the
small effort...

-- 
Joel


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [RFA] Make cu/tu functions in dwarf.exp take a list of options
  2013-05-20  5:40     ` Joel Brobecker
@ 2013-05-20 16:42       ` Doug Evans
  0 siblings, 0 replies; 6+ messages in thread
From: Doug Evans @ 2013-05-20 16:42 UTC (permalink / raw)
  To: Joel Brobecker; +Cc: Tom Tromey, gdb-patches

On Sun, May 19, 2013 at 10:40 PM, Joel Brobecker <brobecker@adacore.com> wrote:
>> When you change the calling sequence of a function in a simple fashion,
>> and you change all the callers of the function to use the new calling
>> sequence, there is no need to make individual entries for all the
>> callers that you changed.  Just write in the entry for the function
>> being called, ``All callers changed''---like this:
>
> FWIW: No real opinion, but I intepreted the above in the context
> of the same file only. I find that listing all the files adjusted
> was fairly easy, so I thought the added information was worth the
> small effort...

"small" can be relative, and we shouldn't IMO be adding effort to
writing ChangeLogs that have incommensurate value.

[For example, we go *way* beyond what is required by standards.texi
for doc ChangeLogs.]


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [RFA] Make cu/tu functions in dwarf.exp take a list of options
  2013-05-17 18:04 ` Tom Tromey
  2013-05-17 18:20   ` Doug Evans
@ 2013-05-20 22:09   ` Doug Evans
  1 sibling, 0 replies; 6+ messages in thread
From: Doug Evans @ 2013-05-20 22:09 UTC (permalink / raw)
  To: Tom Tromey; +Cc: gdb-patches

Tom Tromey writes:
 > >>>>> "Doug" == Doug Evans <dje@google.com> writes:
 > 
 > Doug> Ok to check in?
 > Doug> Regression tested on amd64-linux.
 > 
 > Looks good to me.
 > 
 > Doug> 2013-05-17  Doug Evans  <dje@google.com>
 > 
 > Doug> 	* lib/dwarf.exp (Dwarf): New variable _abbrev_section.
 > Doug> 	(_handle_DW_TAG): Use it.
 > Doug> 	(cu): Replace parameters is_64, version, addr_size with options.
 > Doug> 	All callers updated.  Add Fission support.
 > 
 > I thought we were supposed to list all the changed files, even in this
 > case.  If not, it would be nice to know, so I can stop doing that in the
 > future.

Here is what I checked in so that the discussion can continue at its own pace.
[I forget to mention "tu", so the changelog entry is fixed to include that.]

2013-05-20  Doug Evans  <dje@google.com>

	* lib/dwarf.exp (Dwarf): New variable _abbrev_section.
	(_handle_DW_TAG): Use it.
	(cu, tu): Replace parameters is_64, version, addr_size with options.
	All callers updated.  Add Fission support.
	* gdb.dwarf2/implptrconst.exp: Update callers of "cu".
	* gdb.dwarf2/method-ptr.exp: Ditto.
	* gdb.dwarf2/nostaticblock.exp: Ditto.
	* gdb.dwarf2/subrange.exp: Ditto.
	* gdb.dwarf2/missing-sig-type.exp: Update callers of "cu", "tu".

Index: testsuite/gdb.dwarf2/implptrconst.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.dwarf2/implptrconst.exp,v
retrieving revision 1.2
diff -u -p -r1.2 implptrconst.exp
--- testsuite/gdb.dwarf2/implptrconst.exp	13 May 2013 19:32:17 -0000	1.2
+++ testsuite/gdb.dwarf2/implptrconst.exp	20 May 2013 22:01:05 -0000
@@ -29,7 +29,7 @@ set asm_file [standard_output_file $srcf
 Dwarf::assemble $asm_file {
     # Creating a CU with 4-byte addresses lets this test link on both
     # 32- and 64-bit machines.
-    cu 0 2 4 {
+    cu { addr_size 4 } {
  	compile_unit {} {
 	    declare_labels byte_label size_type_label array_label
 	    declare_labels var_label ptr_label
Index: testsuite/gdb.dwarf2/method-ptr.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.dwarf2/method-ptr.exp,v
retrieving revision 1.3
diff -u -p -r1.3 method-ptr.exp
--- testsuite/gdb.dwarf2/method-ptr.exp	1 Feb 2013 19:33:47 -0000	1.3
+++ testsuite/gdb.dwarf2/method-ptr.exp	20 May 2013 22:01:05 -0000
@@ -29,7 +29,7 @@ Dwarf::assemble $asm_file {
     declare_labels int_label float_label struct_label
     declare_labels ptr_label subr_label memptr_label
 
-    cu 0 2 8 {
+    cu {} {
 	compile_unit {{language @DW_LANG_C_plus_plus}} {
 	    int_label: base_type {
 		{name int}
Index: testsuite/gdb.dwarf2/missing-sig-type.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.dwarf2/missing-sig-type.exp,v
retrieving revision 1.1
diff -u -p -r1.1 missing-sig-type.exp
--- testsuite/gdb.dwarf2/missing-sig-type.exp	17 Apr 2013 21:07:09 -0000	1.1
+++ testsuite/gdb.dwarf2/missing-sig-type.exp	20 May 2013 22:01:05 -0000
@@ -26,7 +26,7 @@ standard_testfile main.c missing-sig-typ
 # Make some DWARF for the test.
 set asm_file [standard_output_file $srcfile2]
 Dwarf::assemble $asm_file {
-    cu 0 4 8 {
+    cu {} {
  	compile_unit {} {
 	    declare_labels typedef_label
 
@@ -38,7 +38,7 @@ Dwarf::assemble $asm_file {
 	}
     }
 
-    tu 0 4 8 0x1122334455667788 the_type {
+    tu {} 0x1122334455667788 the_type {
 	type_unit {} {
 	    the_type: base_type {
 		{name int}
Index: testsuite/gdb.dwarf2/nostaticblock.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.dwarf2/nostaticblock.exp,v
retrieving revision 1.1
diff -u -p -r1.1 nostaticblock.exp
--- testsuite/gdb.dwarf2/nostaticblock.exp	25 Apr 2013 16:25:37 -0000	1.1
+++ testsuite/gdb.dwarf2/nostaticblock.exp	20 May 2013 22:01:05 -0000
@@ -26,7 +26,7 @@ standard_testfile main.c .S
 # Make some DWARF for the test.
 set asm_file [standard_output_file $srcfile2]
 Dwarf::assemble $asm_file {
-    cu 0 2 8 {
+    cu {} {
  	compile_unit {
 	    {low_pc 0x104320 DW_FORM_addr}
 	    {high_pc 0x1045ed DW_FORM_addr}
Index: testsuite/gdb.dwarf2/subrange.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.dwarf2/subrange.exp,v
retrieving revision 1.1
diff -u -p -r1.1 subrange.exp
--- testsuite/gdb.dwarf2/subrange.exp	18 Feb 2013 21:04:28 -0000	1.1
+++ testsuite/gdb.dwarf2/subrange.exp	20 May 2013 22:01:05 -0000
@@ -26,7 +26,7 @@ standard_testfile method-ptr.cc subrange
 # Make some DWARF for the test.
 set asm_file [standard_output_file $srcfile2]
 Dwarf::assemble $asm_file {
-    cu 0 2 8 {
+    cu {} {
  	compile_unit {{language @DW_LANG_Pascal83}} {
 	    declare_labels byte_label typedef_label array_label
 
Index: testsuite/lib/dwarf.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/lib/dwarf.exp,v
retrieving revision 1.8
diff -u -p -r1.8 dwarf.exp
--- testsuite/lib/dwarf.exp	6 May 2013 19:44:04 -0000	1.8
+++ testsuite/lib/dwarf.exp	20 May 2013 22:01:05 -0000
@@ -137,6 +137,10 @@ namespace eval Dwarf {
     # Otherwise, this is the name of a section to write to.
     variable _defer
 
+    # The abbrev section.  Typically .debug_abbrev but can be .debug_abbrev.dwo
+    # for Fission.
+    variable _abbrev_section
+
     # The next available abbrev number in the current CU's abbrev
     # table.
     variable _abbrev_num
@@ -401,6 +405,7 @@ namespace eval Dwarf {
     }
 
     proc _handle_DW_TAG {tag_name {attrs {}} {children {}}} {
+	variable _abbrev_section
 	variable _abbrev_num
 	variable _constants
 
@@ -409,7 +414,7 @@ namespace eval Dwarf {
 
 	# We somewhat wastefully emit a new abbrev entry for each tag.
 	# There's no reason for this other than laziness.
-	_defer_output .debug_abbrev {
+	_defer_output $_abbrev_section {
 	    _op .uleb128 $my_abbrev "Abbrev start"
 	    _op .uleb128 $_constants($tag_name) $tag_name
 	    _op .byte $has_children "has_children"
@@ -429,13 +434,13 @@ namespace eval Dwarf {
 
 	    _handle_DW_FORM $attr_form $attr_value
 
-	    _defer_output .debug_abbrev {
+	    _defer_output $_abbrev_section {
 		_op .uleb128 $_constants($attr_name) $attr_name
 		_op .uleb128 $_constants($attr_form) $attr_form
 	    }
 	}
 
-	_defer_output .debug_abbrev {
+	_defer_output $_abbrev_section {
 	    # Terminator.
 	    _op .byte 0x0 Terminator
 	    _op .byte 0x0 Terminator
@@ -667,29 +672,52 @@ namespace eval Dwarf {
     }
 
     # Emit a DWARF CU.
-    # IS_64 is a boolean which is true if you want to emit 64-bit
-    # DWARF, and false for 32-bit DWARF.
-    # VERSION is the DWARF version number to emit.
-    # ADDR_SIZE is the size of addresses in bytes.
+    # OPTIONS is a list with an even number of elements containing
+    # option-name and option-value pairs.
+    # Current options are:
+    # is_64 0|1    - boolean indicating if you want to emit 64-bit DWARF
+    #                default = 0 (32-bit)
+    # version n    - DWARF version number to emit
+    #                default = 4
+    # addr_size n  - the size of addresses, 32 or 64
+    #                default = 64
+    # fission 0|1  - boolean indicating if generating Fission debug info
+    #                default = 0
     # BODY is Tcl code that emits the DIEs which make up the body of
     # the CU.  It is evaluated in the caller's context.
-    proc cu {is_64 version addr_size body} {
+    proc cu {options body} {
 	variable _cu_count
+	variable _abbrev_section
 	variable _abbrev_num
 	variable _cu_label
 	variable _cu_version
 	variable _cu_addr_size
 	variable _cu_offset_size
 
-	set _cu_version $version
-	if {$is_64} {
-	    set _cu_offset_size 8
-	} else {
-	    set _cu_offset_size 4
+	# Establish the defaults.
+	set is_64 0
+	set _cu_version 4
+	set _cu_addr_size 8
+	set fission 0
+	set section ".debug_info"
+	set _abbrev_section ".debug_abbrev"
+
+	foreach { name value } $options {
+	    switch -exact -- $name {
+		is_64 { set is_64 $value }
+		version { set _cu_version $value }
+		addr_size { set _cu_addr_size $value }
+		fission { set fission $value }
+		default { error "unknown option $name" }
+	    }
+	}
+	set _cu_offset_size [expr { $is_64 ? 8 : 4 }]
+	if { $fission } {
+	    set section ".debug_info.dwo"
+	    set _abbrev_section ".debug_abbrev.dwo"
 	}
-	set _cu_addr_size $addr_size
 
-	_section .debug_info
+	_section $section
 
 	set cu_num [incr _cu_count]
 	set my_abbrevs [_compute_label "abbrev${cu_num}_begin"]
@@ -707,17 +735,17 @@ namespace eval Dwarf {
 	    _op .4byte "$end_label - $start_label"
 	}
 	define_label $start_label
-	_op .2byte $version Version
+	_op .2byte $_cu_version Version
 	_op .4byte $my_abbrevs Abbrevs
-	_op .byte $addr_size "Pointer size"
+	_op .byte $_cu_addr_size "Pointer size"
 
-	_defer_output .debug_abbrev {
+	_defer_output $_abbrev_section {
 	    define_label $my_abbrevs
 	}
 
 	uplevel $body
 
-	_defer_output .debug_abbrev {
+	_defer_output $_abbrev_section {
 	    # Emit the terminator.
 	    _op .byte 0x0 Terminator
 	    _op .byte 0x0 Terminator
@@ -727,31 +755,55 @@ namespace eval Dwarf {
     }
 
     # Emit a DWARF TU.
-    # IS_64 is a boolean which is true if you want to emit 64-bit
-    # DWARF, and false for 32-bit DWARF.
-    # VERSION is the DWARF version number to emit.
-    # ADDR_SIZE is the size of addresses in bytes.
+    # OPTIONS is a list with an even number of elements containing
+    # option-name and option-value pairs.
+    # Current options are:
+    # is_64 0|1    - boolean indicating if you want to emit 64-bit DWARF
+    #                default = 0 (32-bit)
+    # version n    - DWARF version number to emit
+    #                default = 4
+    # addr_size n  - the size of addresses, 32 or 64
+    #                default = 64
+    # fission 0|1  - boolean indicating if generating Fission debug info
+    #                default = 0
     # SIGNATURE is the 64-bit signature of the type.
-    # TYPE_LABEL is the label of the type defined by this TU.
+    # TYPE_LABEL is the label of the type defined by this TU,
+    # or "" if there is no type (i.e., type stubs in Fission).
     # BODY is Tcl code that emits the DIEs which make up the body of
-    # the CU.  It is evaluated in the caller's context.
-    proc tu {is_64 version addr_size signature type_label body} {
+    # the TU.  It is evaluated in the caller's context.
+    proc tu {options signature type_label body} {
 	variable _cu_count
+	variable _abbrev_section
 	variable _abbrev_num
 	variable _cu_label
 	variable _cu_version
 	variable _cu_addr_size
 	variable _cu_offset_size
 
-	set _cu_version $version
-	if {$is_64} {
-	    set _cu_offset_size 8
-	} else {
-	    set _cu_offset_size 4
+	# Establish the defaults.
+	set is_64 0
+	set _cu_version 4
+	set _cu_addr_size 8
+	set fission 0
+	set section ".debug_types"
+	set _abbrev_section ".debug_abbrev"
+
+	foreach { name value } $options {
+	    switch -exact -- $name {
+		is_64 { set is_64 $value }
+		version { set _cu_version $value }
+		addr_size { set _cu_addr_size $value }
+		fission { set fission $value }
+		default { error "unknown option $name" }
+	    }
+	}
+	set _cu_offset_size [expr { $is_64 ? 8 : 4 }]
+	if { $fission } {
+	    set section ".debug_types.dwo"
+	    set _abbrev_section ".debug_abbrev.dwo"
 	}
-	set _cu_addr_size $addr_size
 
-	_section .debug_types
+	_section $section
 
 	set cu_num [incr _cu_count]
 	set my_abbrevs [_compute_label "abbrev${cu_num}_begin"]
@@ -769,25 +821,33 @@ namespace eval Dwarf {
 	    _op .4byte "$end_label - $start_label"
 	}
 	define_label $start_label
-	_op .2byte $version Version
+	_op .2byte $_cu_version Version
 	_op .4byte $my_abbrevs Abbrevs
-	_op .byte $addr_size "Pointer size"
+	_op .byte $_cu_addr_size "Pointer size"
 	_op .8byte $signature Signature
-	uplevel declare_labels $type_label
-	upvar $type_label my_type_label
-	if {$is_64} {
-	    _op .8byte "$my_type_label - $_cu_label"
+	if { $type_label != "" } {
+	    uplevel declare_labels $type_label
+	    upvar $type_label my_type_label
+	    if {$is_64} {
+		_op .8byte "$my_type_label - $_cu_label"
+	    } else {
+		_op .4byte "$my_type_label - $_cu_label"
+	    }
 	} else {
-	    _op .4byte "$my_type_label - $_cu_label"
+	    if {$is_64} {
+		_op .8byte 0
+	    } else {
+		_op .4byte 0
+	    }
 	}
 
-	_defer_output .debug_abbrev {
+	_defer_output $_abbrev_section {
 	    define_label $my_abbrevs
 	}
 
 	uplevel $body
 
-	_defer_output .debug_abbrev {
+	_defer_output $_abbrev_section {
 	    # Emit the terminator.
 	    _op .byte 0x0 Terminator
 	    _op .byte 0x0 Terminator


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2013-05-20 22:09 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-05-17 17:28 [RFA] Make cu/tu functions in dwarf.exp take a list of options Doug Evans
2013-05-17 18:04 ` Tom Tromey
2013-05-17 18:20   ` Doug Evans
2013-05-20  5:40     ` Joel Brobecker
2013-05-20 16:42       ` Doug Evans
2013-05-20 22:09   ` Doug Evans

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox