Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [PATCH] Fix build errors for armhf
@ 2021-01-21 13:41 Luis Machado via Gdb-patches
  2021-01-21 19:07 ` Tom Tromey
  0 siblings, 1 reply; 4+ messages in thread
From: Luis Machado via Gdb-patches @ 2021-01-21 13:41 UTC (permalink / raw)
  To: gdb-patches

When building for 32-bit ARM, I ran into a couple build failures.

The first one seems to be caused by recent changes to warning switches,
leading to the following error:

--
In file included from gdb/coffread.c:35:0:
gdb/coffread.c: In function ‘void enter_linenos(file_ptr, int, int, objfile*)’:
gdb/complaints.h:40:40: error: format ‘%ld’ expects argument of type ‘long int’, but argument 2 has type ‘file_ptr {aka long long int}’ [-Werror=format=]
  complaint_internal (FMT, ##__VA_ARGS__);  \
                                        ^
gdb/coffread.c:1413:7: note: in expansion of macro ‘complaint’
       complaint (_("Line number pointer %ld lower than start of line numbers"),
       ^~~~~~~~~
--

The other one is due to a narrowing conversion in valops.c:

--
gdb/valops.c: In function ‘value* value_assign(value*, value*)’:
gdb/gdbtypes.h:1798:43: error: narrowing conversion of ‘type->type::length’ from ‘ULONGEST {aka long long unsigned int}’ to ‘size_t {aka unsigned int}’ inside { } [-Werror=narrowing]
 #define TYPE_LENGTH(thistype) (thistype)->length
                               ~~~~~~~~~~~~^
gdb/valops.c:1252:9: note: in expansion of macro ‘TYPE_LENGTH’
         TYPE_LENGTH (type)});
--

Fix both with the following patch. Validated with --enable-targets=all on
Ubuntu 18.04/20.04.

gdb/ChangeLog:

YYYY-MM-DD  Luis Machado  <luis.machado@linaro.org>

	* coffread.c (enter_linenos): Passing string to complaint.
	* valops.c (value_assign): Make array view.
---
 gdb/coffread.c | 4 ++--
 gdb/valops.c   | 6 ++++--
 2 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/gdb/coffread.c b/gdb/coffread.c
index 3b59ba9c922..296cc90d902 100644
--- a/gdb/coffread.c
+++ b/gdb/coffread.c
@@ -1410,8 +1410,8 @@ enter_linenos (file_ptr file_offset, int first_line,
     return;
   if (file_offset < linetab_offset)
     {
-      complaint (_("Line number pointer %ld lower than start of line numbers"),
-		 file_offset);
+      complaint (_("Line number pointer %s lower than start of line numbers"),
+		 phex_nz (file_offset, sizeof (file_offset)));
       if (file_offset > linetab_size)	/* Too big to be an offset?  */
 	return;
       file_offset += linetab_offset;	/* Try reading at that linetab
diff --git a/gdb/valops.c b/gdb/valops.c
index 882f6e7f0c2..d0d5628d11b 100644
--- a/gdb/valops.c
+++ b/gdb/valops.c
@@ -1246,10 +1246,12 @@ value_assign (struct value *toval, struct value *fromval)
 	      }
 	    else
 	      {
+		gdb::array_view<const gdb_byte> contents
+		  = gdb::make_array_view (value_contents (fromval),
+					  TYPE_LENGTH (type));
 		put_frame_register_bytes (frame, value_reg,
 					  value_offset (toval),
-					  {value_contents (fromval),
-					   TYPE_LENGTH (type)});
+					  contents);
 	      }
 	  }
 
-- 
2.25.1


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

* Re: [PATCH] Fix build errors for armhf
  2021-01-21 13:41 [PATCH] Fix build errors for armhf Luis Machado via Gdb-patches
@ 2021-01-21 19:07 ` Tom Tromey
  2021-01-21 19:15   ` Luis Machado via Gdb-patches
  0 siblings, 1 reply; 4+ messages in thread
From: Tom Tromey @ 2021-01-21 19:07 UTC (permalink / raw)
  To: Luis Machado via Gdb-patches

>>>>> "Luis" == Luis Machado via Gdb-patches <gdb-patches@sourceware.org> writes:

Luis> -      complaint (_("Line number pointer %ld lower than start of line numbers"),
Luis> -		 file_offset);
Luis> +      complaint (_("Line number pointer %s lower than start of line numbers"),
Luis> +		 phex_nz (file_offset, sizeof (file_offset)));

phex_nz doesn't print the leading "0x", so this output will be a bit
harder to understand.

How about just using plongest instead?

Tom

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

* Re: [PATCH] Fix build errors for armhf
  2021-01-21 19:07 ` Tom Tromey
@ 2021-01-21 19:15   ` Luis Machado via Gdb-patches
  2021-01-21 20:17     ` Luis Machado via Gdb-patches
  0 siblings, 1 reply; 4+ messages in thread
From: Luis Machado via Gdb-patches @ 2021-01-21 19:15 UTC (permalink / raw)
  To: Tom Tromey, Luis Machado via Gdb-patches

On 1/21/21 4:07 PM, Tom Tromey wrote:
>>>>>> "Luis" == Luis Machado via Gdb-patches <gdb-patches@sourceware.org> writes:
> 
> Luis> -      complaint (_("Line number pointer %ld lower than start of line numbers"),
> Luis> -		 file_offset);
> Luis> +      complaint (_("Line number pointer %s lower than start of line numbers"),
> Luis> +		 phex_nz (file_offset, sizeof (file_offset)));
> 
> phex_nz doesn't print the leading "0x", so this output will be a bit
> harder to understand.
> 
> How about just using plongest instead?

That'd be fine by me.

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

* Re: [PATCH] Fix build errors for armhf
  2021-01-21 19:15   ` Luis Machado via Gdb-patches
@ 2021-01-21 20:17     ` Luis Machado via Gdb-patches
  0 siblings, 0 replies; 4+ messages in thread
From: Luis Machado via Gdb-patches @ 2021-01-21 20:17 UTC (permalink / raw)
  To: Tom Tromey, Luis Machado via Gdb-patches

On 1/21/21 4:15 PM, Luis Machado wrote:
> On 1/21/21 4:07 PM, Tom Tromey wrote:
>>>>>>> "Luis" == Luis Machado via Gdb-patches 
>>>>>>> <gdb-patches@sourceware.org> writes:
>>
>> Luis> -      complaint (_("Line number pointer %ld lower than start of 
>> line numbers"),
>> Luis> -         file_offset);
>> Luis> +      complaint (_("Line number pointer %s lower than start of 
>> line numbers"),
>> Luis> +         phex_nz (file_offset, sizeof (file_offset)));
>>
>> phex_nz doesn't print the leading "0x", so this output will be a bit
>> harder to understand.
>>
>> How about just using plongest instead?
> 
> That'd be fine by me.

Pushed with that fix. Thanks!

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

end of thread, other threads:[~2021-01-21 20:17 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-21 13:41 [PATCH] Fix build errors for armhf Luis Machado via Gdb-patches
2021-01-21 19:07 ` Tom Tromey
2021-01-21 19:15   ` Luis Machado via Gdb-patches
2021-01-21 20:17     ` Luis Machado via Gdb-patches

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