public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] [gdb/testsuite] Generate DW_MACRO_define_strp in dwarf assembly
@ 2024-05-15  7:27 Tom de Vries
  2024-05-15 16:07 ` Tom Tromey
  0 siblings, 1 reply; 2+ messages in thread
From: Tom de Vries @ 2024-05-15  7:27 UTC (permalink / raw)
  To: gdb-patches

Add support for DW_MACRO_define_strp in dwarf assembly, and use it in
test-case gdb.dwarf2/macro-source-path.exp.

Tested on x86_64-linux.
---
 .../gdb.dwarf2/macro-source-path.exp          |  2 ++
 gdb/testsuite/lib/dwarf.exp                   | 28 ++++++++++++++++++-
 2 files changed, 29 insertions(+), 1 deletion(-)

diff --git a/gdb/testsuite/gdb.dwarf2/macro-source-path.exp b/gdb/testsuite/gdb.dwarf2/macro-source-path.exp
index bcfd2f2f92c..b6b7b0bd2fd 100644
--- a/gdb/testsuite/gdb.dwarf2/macro-source-path.exp
+++ b/gdb/testsuite/gdb.dwarf2/macro-source-path.exp
@@ -125,6 +125,7 @@ proc do_test { test_name lines_version DW_AT_name main_file_idx directories
 			# PR 29034).  We're not trying to replicate that here,
 			# this is not in the scope of this test.
 			define 0 "ONE 1"
+			define_strp 0 "THREE 3"
 			start_file 0 $::main_file_idx
 			    # A macro defined at line 1 of the main file.
 			    define 1 "TWO 2"
@@ -144,6 +145,7 @@ proc do_test { test_name lines_version DW_AT_name main_file_idx directories
 
 	    gdb_test "print ONE" " = 1"
 	    gdb_test "print TWO" " = 2"
+	    gdb_test "print THREE" " = 3"
 	}
     }
 }
diff --git a/gdb/testsuite/lib/dwarf.exp b/gdb/testsuite/lib/dwarf.exp
index 44862dbb339..5b23a60af8e 100644
--- a/gdb/testsuite/lib/dwarf.exp
+++ b/gdb/testsuite/lib/dwarf.exp
@@ -549,6 +549,9 @@ namespace eval Dwarf {
     # The current CU's offset size.
     variable _cu_offset_size
 
+    # The current macro unit's offset size.
+    variable _mu_offset_size
+
     # Label generation number.
     variable _label_num
 
@@ -2229,6 +2232,8 @@ namespace eval Dwarf {
 	if { ${is-64} } {
 	    set flags [expr $flags | 0x1]
 	}
+	variable _mu_offset_size
+	set _mu_offset_size [expr ${is-64} ? 8 : 4]
 
 	if { ${debug-line-offset-label} != "" } {
 	    set flags [expr $flags | 0x2]
@@ -2241,11 +2246,12 @@ namespace eval Dwarf {
 		"debug_line offset"
 	}
 
+	with_override Dwarf::define_strp Dwarf::_macro_unit_define_strp {
 	with_override Dwarf::define Dwarf::_macro_unit_define {
 	with_override Dwarf::start_file Dwarf::_macro_unit_start_file {
 	with_override Dwarf::end_file Dwarf::_macro_unit_end_file {
 	    uplevel $body
-	}}}
+	}}}}
     }
 
     # Emit a DW_MACRO_define entry.
@@ -2256,6 +2262,26 @@ namespace eval Dwarf {
 	_op .asciz "\"$text\"" "Macro definition"
     }
 
+    # Emit a DW_MACRO_define_strp entry.
+
+    proc _macro_unit_define_strp { lineno text } {
+	_op .byte 0x5 "DW_MACRO_define_strp"
+	_op .uleb128 $lineno "Line number"
+
+	variable _strings
+	variable _mu_offset_size
+
+	if {![info exists _strings($text)]} {
+	    set _strings($text) [new_label strp]
+	    _defer_output .debug_str {
+		define_label $_strings($text)
+		_op .ascii [_quote $text]
+	    }
+	}
+
+	_op_offset $_mu_offset_size "$_strings($text)" "strp: $text"
+    }
+
     # Emit a DW_MACRO_start_file entry.
 
     proc _macro_unit_start_file { lineno file_idx } {

base-commit: f1fe1d35c855b9abaf1fb0a347e5de2e12994b1a
-- 
2.35.3


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

* Re: [PATCH] [gdb/testsuite] Generate DW_MACRO_define_strp in dwarf assembly
  2024-05-15  7:27 [PATCH] [gdb/testsuite] Generate DW_MACRO_define_strp in dwarf assembly Tom de Vries
@ 2024-05-15 16:07 ` Tom Tromey
  0 siblings, 0 replies; 2+ messages in thread
From: Tom Tromey @ 2024-05-15 16:07 UTC (permalink / raw)
  To: Tom de Vries; +Cc: gdb-patches

>>>>> "Tom" == Tom de Vries <tdevries@suse.de> writes:

Tom> Add support for DW_MACRO_define_strp in dwarf assembly, and use it in
Tom> test-case gdb.dwarf2/macro-source-path.exp.

Looks good to me.
Approved-By: Tom Tromey <tom@tromey.com>

Tom

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

end of thread, other threads:[~2024-05-15 16:07 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-05-15  7:27 [PATCH] [gdb/testsuite] Generate DW_MACRO_define_strp in dwarf assembly Tom de Vries
2024-05-15 16:07 ` Tom Tromey

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).