diff mbox

Update ELF auxv entry types and update GDB to use them.

Message ID 20200225121021.30075-1-luis.machado@linaro.org
State New
Headers show

Commit Message

Luis Machado Feb. 25, 2020, 12:10 p.m. UTC
I noticed GDB didn't know a particular AT tag (51) when doing some debugging.
Turns out we're missing a few entries compared to glibc's headers.

This patch adds them to the ELF include file and GDB.

include/ChangeLog:

	* elf/common.h (AT_L1I_CACHESIZE, AT_L1I_CACHEGEOMETRY,
	AT_L1D_CACHESIZE, AT_L1D_CACHEGEOMETRY, AT_L2_CACHESIZE,
	AT_L2_CACHEGEOMETRY, AT_L3_CACHESIZE, AT_L3_CACHEGEOMETRY,
	AT_MINSIGSTKSZ): New defines, imported from glibc.

gdb/ChangeLog:

	* auxv.c (default_print_auxv_entry): Add new auxv entries.
---
 gdb/auxv.c           | 12 ++++++++++++
 include/elf/common.h | 15 +++++++++++++++
 2 files changed, 27 insertions(+)

Comments

Pedro Alves Feb. 27, 2020, 8:30 p.m. UTC | #1
On 2/25/20 12:10 PM, Luis Machado wrote:
> I noticed GDB didn't know a particular AT tag (51) when doing some debugging.
> Turns out we're missing a few entries compared to glibc's headers.
> 
> This patch adds them to the ELF include file and GDB.
> 
> include/ChangeLog:
> 
> 	* elf/common.h (AT_L1I_CACHESIZE, AT_L1I_CACHEGEOMETRY,
> 	AT_L1D_CACHESIZE, AT_L1D_CACHEGEOMETRY, AT_L2_CACHESIZE,
> 	AT_L2_CACHEGEOMETRY, AT_L3_CACHESIZE, AT_L3_CACHEGEOMETRY,
> 	AT_MINSIGSTKSZ): New defines, imported from glibc.
> 

The standard says to split lines by closing and reopening parens,
instead of comma.  Like:

	* elf/common.h (AT_L1I_CACHESIZE, AT_L1I_CACHEGEOMETRY)
	(AT_L1D_CACHESIZE, AT_L1D_CACHEGEOMETRY, AT_L2_CACHESIZE)
	(AT_L2_CACHEGEOMETRY, AT_L3_CACHESIZE, AT_L3_CACHEGEOMETRY)
	(AT_MINSIGSTKSZ): New defines, imported from glibc.


> gdb/ChangeLog:
> 
> 	* auxv.c (default_print_auxv_entry): Add new auxv entries.
> ---
>  gdb/auxv.c           | 12 ++++++++++++
>  include/elf/common.h | 15 +++++++++++++++
>  2 files changed, 27 insertions(+)
> 
> diff --git a/gdb/auxv.c b/gdb/auxv.c
> index eb1233527e..e7432e1852 100644
> --- a/gdb/auxv.c
> +++ b/gdb/auxv.c
> @@ -497,6 +497,18 @@ default_print_auxv_entry (struct gdbarch *gdbarch, struct ui_file *file,
>  	   AUXV_FORMAT_HEX);
>        TAG (AT_SUN_CAP_HW2, _("Machine-dependent CPU capability hints 2"),
>  	   AUXV_FORMAT_HEX);
> +      TAG (AT_L1I_CACHESIZE , _("L1 Instruction cache size"), AUXV_FORMAT_HEX);
> +      TAG (AT_L1I_CACHEGEOMETRY , _("L1 Instruction cache geometry"),
> +	   AUXV_FORMAT_HEX);
> +      TAG (AT_L1D_CACHESIZE , _("L1 Data cache size"), AUXV_FORMAT_HEX);
> +      TAG (AT_L1D_CACHEGEOMETRY , _("L1 Data cache geometry"),
> +	   AUXV_FORMAT_HEX);
> +      TAG (AT_L2_CACHESIZE , _("L2 cache size"), AUXV_FORMAT_HEX);
> +      TAG (AT_L2_CACHEGEOMETRY , _("L2 cache geometry"), AUXV_FORMAT_HEX);
> +      TAG (AT_L3_CACHESIZE , _("L3 cache size"), AUXV_FORMAT_HEX);
> +      TAG (AT_L3_CACHEGEOMETRY , _("L3 cache geometry"), AUXV_FORMAT_HEX);
> +      TAG (AT_MINSIGSTKSZ , _("Minimum stack size for signal delivery"),
> +	   AUXV_FORMAT_HEX);

Odd space before comma in all the new lines above.
How about putting these right after AT_L3_CACHESHAPE / 
before the SUN ones?

LGTM with those changes.  But ...

>      }
>  
>    fprint_auxv_entry (file, name, description, format, type, val);
> diff --git a/include/elf/common.h b/include/elf/common.h
> index 53b72445ca..18c898cf6b 100644
> --- a/include/elf/common.h
> +++ b/include/elf/common.h

... "This file is part of BFD, the Binary File Descriptor library."

You should send this part to binutils@.

Thanks,
Pedro Alves
Luis Machado March 3, 2020, 1:33 p.m. UTC | #2
On 2/27/20 5:30 PM, Pedro Alves wrote:
> On 2/25/20 12:10 PM, Luis Machado wrote:
>> I noticed GDB didn't know a particular AT tag (51) when doing some debugging.
>> Turns out we're missing a few entries compared to glibc's headers.
>>
>> This patch adds them to the ELF include file and GDB.
>>
>> include/ChangeLog:
>>
>> 	* elf/common.h (AT_L1I_CACHESIZE, AT_L1I_CACHEGEOMETRY,
>> 	AT_L1D_CACHESIZE, AT_L1D_CACHEGEOMETRY, AT_L2_CACHESIZE,
>> 	AT_L2_CACHEGEOMETRY, AT_L3_CACHESIZE, AT_L3_CACHEGEOMETRY,
>> 	AT_MINSIGSTKSZ): New defines, imported from glibc.
>>
> 
> The standard says to split lines by closing and reopening parens,
> instead of comma.  Like:
> 
> 	* elf/common.h (AT_L1I_CACHESIZE, AT_L1I_CACHEGEOMETRY)
> 	(AT_L1D_CACHESIZE, AT_L1D_CACHEGEOMETRY, AT_L2_CACHESIZE)
> 	(AT_L2_CACHEGEOMETRY, AT_L3_CACHESIZE, AT_L3_CACHEGEOMETRY)
> 	(AT_MINSIGSTKSZ): New defines, imported from glibc.
> 
> 
>> gdb/ChangeLog:
>>
>> 	* auxv.c (default_print_auxv_entry): Add new auxv entries.
>> ---
>>   gdb/auxv.c           | 12 ++++++++++++
>>   include/elf/common.h | 15 +++++++++++++++
>>   2 files changed, 27 insertions(+)
>>
>> diff --git a/gdb/auxv.c b/gdb/auxv.c
>> index eb1233527e..e7432e1852 100644
>> --- a/gdb/auxv.c
>> +++ b/gdb/auxv.c
>> @@ -497,6 +497,18 @@ default_print_auxv_entry (struct gdbarch *gdbarch, struct ui_file *file,
>>   	   AUXV_FORMAT_HEX);
>>         TAG (AT_SUN_CAP_HW2, _("Machine-dependent CPU capability hints 2"),
>>   	   AUXV_FORMAT_HEX);
>> +      TAG (AT_L1I_CACHESIZE , _("L1 Instruction cache size"), AUXV_FORMAT_HEX);
>> +      TAG (AT_L1I_CACHEGEOMETRY , _("L1 Instruction cache geometry"),
>> +	   AUXV_FORMAT_HEX);
>> +      TAG (AT_L1D_CACHESIZE , _("L1 Data cache size"), AUXV_FORMAT_HEX);
>> +      TAG (AT_L1D_CACHEGEOMETRY , _("L1 Data cache geometry"),
>> +	   AUXV_FORMAT_HEX);
>> +      TAG (AT_L2_CACHESIZE , _("L2 cache size"), AUXV_FORMAT_HEX);
>> +      TAG (AT_L2_CACHEGEOMETRY , _("L2 cache geometry"), AUXV_FORMAT_HEX);
>> +      TAG (AT_L3_CACHESIZE , _("L3 cache size"), AUXV_FORMAT_HEX);
>> +      TAG (AT_L3_CACHEGEOMETRY , _("L3 cache geometry"), AUXV_FORMAT_HEX);
>> +      TAG (AT_MINSIGSTKSZ , _("Minimum stack size for signal delivery"),
>> +	   AUXV_FORMAT_HEX);
> 
> Odd space before comma in all the new lines above.
> How about putting these right after AT_L3_CACHESHAPE /
> before the SUN ones?

Thanks for the review. Fixed now and pushed.

Binutils side approved and pushed by Nick here 
https://sourceware.org/ml/binutils/2020-03/msg00043.html.
diff mbox

Patch

diff --git a/gdb/auxv.c b/gdb/auxv.c
index eb1233527e..e7432e1852 100644
--- a/gdb/auxv.c
+++ b/gdb/auxv.c
@@ -497,6 +497,18 @@  default_print_auxv_entry (struct gdbarch *gdbarch, struct ui_file *file,
 	   AUXV_FORMAT_HEX);
       TAG (AT_SUN_CAP_HW2, _("Machine-dependent CPU capability hints 2"),
 	   AUXV_FORMAT_HEX);
+      TAG (AT_L1I_CACHESIZE , _("L1 Instruction cache size"), AUXV_FORMAT_HEX);
+      TAG (AT_L1I_CACHEGEOMETRY , _("L1 Instruction cache geometry"),
+	   AUXV_FORMAT_HEX);
+      TAG (AT_L1D_CACHESIZE , _("L1 Data cache size"), AUXV_FORMAT_HEX);
+      TAG (AT_L1D_CACHEGEOMETRY , _("L1 Data cache geometry"),
+	   AUXV_FORMAT_HEX);
+      TAG (AT_L2_CACHESIZE , _("L2 cache size"), AUXV_FORMAT_HEX);
+      TAG (AT_L2_CACHEGEOMETRY , _("L2 cache geometry"), AUXV_FORMAT_HEX);
+      TAG (AT_L3_CACHESIZE , _("L3 cache size"), AUXV_FORMAT_HEX);
+      TAG (AT_L3_CACHEGEOMETRY , _("L3 cache geometry"), AUXV_FORMAT_HEX);
+      TAG (AT_MINSIGSTKSZ , _("Minimum stack size for signal delivery"),
+	   AUXV_FORMAT_HEX);
     }
 
   fprint_auxv_entry (file, name, description, format, type, val);
diff --git a/include/elf/common.h b/include/elf/common.h
index 53b72445ca..18c898cf6b 100644
--- a/include/elf/common.h
+++ b/include/elf/common.h
@@ -1222,6 +1222,21 @@ 
 #define AT_L2_CACHESHAPE  36
 #define AT_L3_CACHESHAPE  37
 
+/* Shapes of the caches, with more room to describe them.
+   *GEOMETRY are comprised of cache line size in bytes in the bottom 16 bits
+   and the cache associativity in the next 16 bits.  */
+#define AT_L1I_CACHESIZE	40
+#define AT_L1I_CACHEGEOMETRY	41
+#define AT_L1D_CACHESIZE	42
+#define AT_L1D_CACHEGEOMETRY	43
+#define AT_L2_CACHESIZE		44
+#define AT_L2_CACHEGEOMETRY	45
+#define AT_L3_CACHESIZE		46
+#define AT_L3_CACHEGEOMETRY	47
+
+#define AT_MINSIGSTKSZ		51 /* Stack needed for signal delivery
+				      (AArch64).  */
+
 #define AT_FREEBSD_EXECPATH     15      /* Path to the executable. */
 #define AT_FREEBSD_CANARY       16      /* Canary for SSP. */
 #define AT_FREEBSD_CANARYLEN    17      /* Length of the canary. */