Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Tom Tromey <tromey@redhat.com>
To: Yao Qi <yao@codesourcery.com>
Cc: <gdb-patches@sourceware.org>
Subject: Re: [PATCH 1/2] Test case for entry values.
Date: Wed, 21 Aug 2013 15:02:00 -0000	[thread overview]
Message-ID: <871u5nf5o3.fsf@fleche.redhat.com> (raw)
In-Reply-To: <5214561B.4050202@codesourcery.com> (Yao Qi's message of "Wed, 21	Aug 2013 13:54:35 +0800")

>>>>> "Yao" == Yao Qi <yao@codesourcery.com> writes:

Tom> Will it still work on x86-64?

Yao> Yes, it works.

Yao> I didn't use "addr_size 4" at the beginning, but get the following
Yao> error.

Yao> gdb/testsuite/gdb.trace/entry-values-dw.S:19: Error: cannot represent relocation type BFD_RELOC_64
Yao> gdb/testsuite/gdb.trace/entry-values-dw.S:20: Error: cannot represent relocation type BFD_RELOC_64

Jan pointed out that the new "dwz.exp" has this failure.

It seems to me that using 32 bit addresses in the DWARF can yield the
wrong results for the test.  What if the high bits matter?

Yao> I also tried the following stuff, but it seems I can't pass
Yao> $cu_addr_size correctly to cu.
Yao> if [is_lp64_target] {
Yao>     set cu_addr_size 8
Yao> } else {
Yao>     set cu_addr_size 4
Yao> }
Yao> ...
Yao> cu {addr_size $cu_addr_size} {

You need to use [list ...] instead.

However, what do you think of the appended?
It adds a "default" setting for addr_size.  This seems to be what we
usually want.

Tom

diff --git a/gdb/testsuite/lib/dwarf.exp b/gdb/testsuite/lib/dwarf.exp
index 5b19bb8..1d3eb03 100644
--- a/gdb/testsuite/lib/dwarf.exp
+++ b/gdb/testsuite/lib/dwarf.exp
@@ -684,8 +684,8 @@ namespace eval 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
+    # addr_size n  - the size of addresses, 32, 64, or default
+    #                default = default
     # 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
@@ -702,7 +702,7 @@ namespace eval Dwarf {
 	# Establish the defaults.
 	set is_64 0
 	set _cu_version 4
-	set _cu_addr_size 8
+	set _cu_addr_size default
 	set fission 0
 	set section ".debug_info"
 	set _abbrev_section ".debug_abbrev"
@@ -716,6 +716,13 @@ namespace eval Dwarf {
 		default { error "unknown option $name" }
 	    }
 	}
+	if {$_cu_addr_size == "default"} {
+	    if {[is_64_target]} {
+		set _cu_addr_size 8
+	    } else {
+		set _cu_addr_size 4
+	    }
+	}
 	set _cu_offset_size [expr { $is_64 ? 8 : 4 }]
 	if { $fission } {
 	    set section ".debug_info.dwo"
@@ -767,8 +774,8 @@ namespace eval 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
+    # addr_size n  - the size of addresses, 32, 64, or default
+    #                default = default
     # fission 0|1  - boolean indicating if generating Fission debug info
     #                default = 0
     # SIGNATURE is the 64-bit signature of the type.
@@ -788,7 +795,7 @@ namespace eval Dwarf {
 	# Establish the defaults.
 	set is_64 0
 	set _cu_version 4
-	set _cu_addr_size 8
+	set _cu_addr_size default
 	set fission 0
 	set section ".debug_types"
 	set _abbrev_section ".debug_abbrev"
@@ -802,6 +809,13 @@ namespace eval Dwarf {
 		default { error "unknown option $name" }
 	    }
 	}
+	if {$_cu_addr_size == "default"} {
+	    if {[is_64_target]} {
+		set _cu_addr_size 8
+	    } else {
+		set _cu_addr_size 4
+	    }
+	}
 	set _cu_offset_size [expr { $is_64 ? 8 : 4 }]
 	if { $fission } {
 	    set section ".debug_types.dwo"
diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
index 1a1fac2..ab41da0 100644
--- a/gdb/testsuite/lib/gdb.exp
+++ b/gdb/testsuite/lib/gdb.exp
@@ -1854,6 +1854,34 @@ gdb_caching_proc is_lp64_target {
     return 1
 }
 
+# Return 1 if target has 64 bit addresses.
+# This cannot be decided simply from looking at the target string,
+# as it might depend on externally passed compiler options like -m64.
+gdb_caching_proc is_64_target {
+    set me "is_64_target"
+
+    set src [standard_temp_file is64[pid].c]
+    set obj [standard_temp_file is64[pid].o]
+
+    set f [open $src "w"]
+    puts $f "int function(void) { return 3; }"
+    puts $f "int dummy\[sizeof (&function) == 8 ? 1 : -1\];"
+    close $f
+
+    verbose "$me:  compiling testfile $src" 2
+    set lines [gdb_compile $src $obj object {quiet}]
+    file delete $src
+    file delete $obj
+
+    if ![string match "" $lines] then {
+        verbose "$me:  testfile compilation failed, returning 0" 2
+        return 0
+    }
+
+    verbose "$me:  returning 1" 2
+    return 1
+}
+
 # Return 1 if target has x86_64 registers - either amd64 or x32.
 # x32 target identifies as x86_64-*-linux*, therefore it cannot be determined
 # just from the target string.


  reply	other threads:[~2013-08-21 15:02 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-08-13  7:41 [PATCH 0/2] Test case on " Yao Qi
2013-08-13  7:41 ` [PATCH 1/2] Test case for " Yao Qi
2013-08-20 17:39   ` Tom Tromey
2013-08-21  5:55     ` Yao Qi
2013-08-21 15:02       ` Tom Tromey [this message]
2013-08-22  0:12         ` Yao Qi
2013-08-22 14:05           ` Tom Tromey
2013-08-23  0:27             ` Yao Qi
2013-08-23 19:23               ` Tom Tromey
2013-08-24  1:56                 ` Yao Qi
2013-08-30 14:52   ` Vidya Praveen
2013-08-30 15:29     ` Vidya Praveen
2013-08-31  0:22       ` Yao Qi
2013-09-10 15:30         ` Vidya Praveen
2013-09-10 23:44           ` Yao Qi
2013-09-11 13:27             ` Vidya Praveen
2013-08-13  7:41 ` [RFC 2/2] Test entry values in trace frame Yao Qi
2013-08-20 17:48   ` Tom Tromey
2013-08-21  6:06     ` Yao Qi
2013-08-21 14:35       ` [PATCH] PR gdb/15871: Unavailable entry value is not shown correctly Pedro Alves
2013-08-21 14:47         ` Mark Kettenis
2013-08-21 15:32           ` Pedro Alves
2013-08-21 15:43             ` Mark Kettenis
2013-08-22  1:25             ` Yao Qi
2013-08-22 10:04               ` [COMMIT] " Pedro Alves
2013-08-23  1:08                 ` Yao Qi
2013-08-23 16:50                   ` Pedro Alves
2013-08-23  0:32       ` [RFC 2/2] Test entry values in trace frame Yao Qi
2013-08-23 17:04         ` Pedro Alves
2013-08-23 19:16           ` Tom Tromey
2013-08-24  1:56             ` Yao Qi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=871u5nf5o3.fsf@fleche.redhat.com \
    --to=tromey@redhat.com \
    --cc=gdb-patches@sourceware.org \
    --cc=yao@codesourcery.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox