Hi Tom, Ulrich and community, >> In the CORE_ADDR >> value::address () >> the return value >> is m_location.address + m_offset = -1 and that is 0xffffff in 2’s complement. >I think the question is why is it -1 here. >Like, is it wrong in the DWARF? Or did the DWARF reader do something >wrong? Or was some runtime offset incorrectly applied? Etc. The problem is from the DWARF itself. Our GDB code is picking up things correctly. Specifically when we do not use the global variables or the global variable section it those variables are assigned 0xffffff by the linker. We give -g -gdwarf when we compile.. So here is my explaination. Consider the code bash-5.1$ cat ~/gdb_tests/simple_test.c #include int global_variable1 = 1; int global_variable2 = 2; int main(){ int local_variable = 1; global_variable2++; printf ("Simple print statement \n"); return 0; } So I checked the code. DWARF values are being read correctly and that address is exactly passed into the code. The dwarf dump output in this case is as pasted below. Kindly note we use global variables. <1>< 347> DW_TAG_variable DW_AT_name global_variable1 DW_AT_decl_file 2 DW_AT_decl_line 2 DW_AT_decl_column 5 DW_AT_type <175> DW_AT_external yes DW_AT_location DW_OP_addr 0x20000e80 <1>< 378> DW_TAG_variable DW_AT_name global_variable2 DW_AT_decl_file 2 DW_AT_decl_line 3 DW_AT_decl_column 5 DW_AT_type <175> DW_AT_external yes DW_AT_location DW_OP_addr 0x20000e84 GDB output for this case:- bash-5.1$ ./gdb ~/gdb_tests/simple_test GNU gdb (GDB) 14.0.50.20230221-git Copyright (C) 2023 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later http://gnu.org/licenses/gpl.html This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Type "show copying" and "show warranty" for details. This GDB was configured as "powerpc64-ibm-aix7.2.0.0". Type "show configuration" for configuration details. For bug reporting instructions, please see: https://www.gnu.org/software/gdb/bugs/. Find the GDB manual and other documentation resources online at: http://www.gnu.org/software/gdb/documentation/. For help, type "help". Type "apropos word" to search for commands related to "word"... Reading symbols from /home/aditya/gdb_tests/simple_test... (gdb) b main Breakpoint 1 at 0x1000052c: file /home/aditya/gdb_tests/simple_test.c, line 5. (gdb) r Starting program: /home/aditya/gdb_tests/simple_test Breakpoint 1, main () at /home/aditya/gdb_tests/simple_test.c:5 5 int local_variable = 1; (gdb) p global_variable1 $1 = 1 (gdb) p global_variable2 $2 = 2 (gdb) Now kindly consider the code bash-5.1$ cat ~/gdb_tests/simple_test.c #include int global_variable1 = 1; int global_variable2 = 2; int main(){ int local_variable = 1; printf ("Simple print statement \n"); return 0; } The dwarf dump output for the same.. <1>< 347> DW_TAG_variable DW_AT_name global_variable1 DW_AT_decl_file 2 DW_AT_decl_line 2 DW_AT_decl_column 5 DW_AT_type <175> DW_AT_external yes DW_AT_location DW_OP_addr 0xffffffff <1>< 378> DW_TAG_variable DW_AT_name global_variable2 DW_AT_decl_file 2 DW_AT_decl_line 3 DW_AT_decl_column 5 DW_AT_type <175> DW_AT_external yes DW_AT_location DW_OP_addr 0xffffffff The GDB output for the above dwarf dump.. bash-5.1$ ./gdb ~/gdb_tests/simple_test GNU gdb (GDB) 14.0.50.20230221-git Copyright (C) 2023 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later http://gnu.org/licenses/gpl.html This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Type "show copying" and "show warranty" for details. This GDB was configured as "powerpc64-ibm-aix7.2.0.0". Type "show configuration" for configuration details. For bug reporting instructions, please see: https://www.gnu.org/software/gdb/bugs/. Find the GDB manual and other documentation resources online at: http://www.gnu.org/software/gdb/documentation/. For help, type "help". Type "apropos word" to search for commands related to "word"... Reading symbols from /home/aditya/gdb_tests/simple_test... (gdb) b main Breakpoint 1 at 0x1000052c: file /home/aditya/gdb_tests/simple_test.c, line 5. (gdb) r Starting program: /home/aditya/gdb_tests/simple_test Breakpoint 1, main () at /home/aditya/gdb_tests/simple_test.c:5 5 int local_variable = 1; (gdb) p global_variable1 Cannot access memory at address 0xffffffff (gdb) So in the dwarf dump we see that in case of ‘n’ number of global variables declared and ‘n’ unused global variables then all variables are assigned 0xfffffff. In case of ‘n’ number of global variables declared and ‘m’ used global variables, where m >= 1 and m <= n, all of them have assigned addresses in AIX. Kindly let me know what you think of this and the patch we sent. Have a nice day ahead. Thanks and regards, Aditya. From: Tom Tromey Date: Wednesday, 15 March 2023 at 6:15 PM To: Aditya Kamath1 Cc: Ulrich Weigand , gdb-patches@sourceware.org , tom@tromey.com , Sangamesh Mallayya Subject: [EXTERNAL] Re: [PATCH] Modify align-c/align-c++ test case for AIX >>>>> Aditya Kamath1 writes: > In the CORE_ADDR > value::address () > the return value > is m_location.address + m_offset = -1 and that is 0xffffff in 2’s complement. I think the question is why is it -1 here. Like, is it wrong in the DWARF? Or did the DWARF reader do something wrong? Or was some runtime offset incorrectly applied? Etc. Tom