)]}'
{
  "commit": "d81b2679c8a9b60c8daf7166b039e529b91f82ff",
  "tree": "f36005a79d2075f17a54f1a3506b8699ffd9c787",
  "parents": [
    "47049598bd189cd504cb12eaec3b3736f452490a"
  ],
  "author": {
    "name": "Aditya Vidyadhar Kamath",
    "email": "aditya.kamath1@ibm.com",
    "time": "Wed Jan 07 03:29:35 2026 -0600"
  },
  "committer": {
    "name": "Aditya Vidyadhar Kamath",
    "email": "aditya.kamath1@ibm.com",
    "time": "Wed Jan 07 03:29:35 2026 -0600"
  },
  "message": "Add TOC calculation for XCOFF binary in AIX and remove legacy line number information.\n\nCo-authored-by: Simon Marchi \u003csimon.marchi@polymtl.ca\u003e\n\nCloses https://sourceware.org/bugzilla/show_bug.cgi?id\u003d33606\n\nThis is a patch to bring back certain XCOFF reading sections back to the GDB code which was removed during the STABS removal.\nThis patch also removes the legacy line table calculation for STABS since we no longer will support it.\n\nThe issue we removed code that will get us the TOC offset in AIX.\nThis will now cause regressions.\n\nFor example,Consider a code where we create a simple library x as below.\n\nint g_in_lib \u003d 777;\n\nint lib_func() {\n\n        return g_in_lib + 1;\n\n}\n\nint lib_func();\n\nThen we use this library X  in main().\n\nint main() {\n\n        printf (\"lib_func() \u003d %d \\n\", lib_func());\n\n        return 0;\n\n}\n\nIf we as of today compile master branch in AIX and try to call lib_func() from GDB we get,\n\nGNU gdb (GDB) 18.0.50.20251112-git\nBreakpoint 1, main () at //gdb_tests/main.c:5\n5           printf (\"lib_func() \u003d %d \\n\", lib_func());\n\n(gdb) call lib_func()\n\n$1 \u003d 536875277\n\n(gdb) q\n\nwhich is a garbage value instead of 778.\n\nDWARF will not have any information about TOC to maintain uniformity with other operating system.\n\nTOC (Table Of Contents) is a part of XCOFF/AIX ABI and is required for:\n1: Loading shared libraries as we need TOC that contain pointers to access global variables and functions entry points.\n2: Function calls like the above call where AIX expects register r2 \u003d pointer to TOC which gives fast access to global data plus an ofset\n3: Large code model \u003d TOC solves the fact that PPC64 can\u0027t embed large 64 bit addresses.\n\nSo we need to get GDB to fetch this even though we only read DWARF debug sections in the XCOFF binary. (AIX uses GCC-13 now which produces only DWARF now.).\n\nIn the above case since the toc_offset is not there now we cannot access lib_func() causing the regression.\n\nThe patch right now brings back the code required to fetch the same. Once this patch is applied we get,\n\nGNU gdb (GDB) 18.0.50.20251204-git\nCopyright (C) 2025 Free Software Foundation, Inc.\nLicense GPLv3+: GNU GPL version 3 or later \u003chttp://gnu.org/licenses/gpl.html\u003e\nThis is free software: you are free to change and redistribute it.\nThere is NO WARRANTY, to the extent permitted by law.\nType \"show copying\" and \"show warranty\" for details.\nThis GDB was configured as \"powerpc64-ibm-aix7.2.0.0\".\nType \"show configuration\" for configuration details.\nFor bug reporting instructions, please see:\n\u003chttps://www.gnu.org/software/gdb/bugs/\u003e.\n\n+------------------------------------------------------------------------------+\n| Find the GDB manual online at:                                               |\n| http://www.gnu.org/software/gdb/documentation/.                              |\n| For help, type \"help\".                                                       |\n| Type \"apropos \u003cword\u003e\" to search for commands related to \u003cword\u003e               |\n+------------------------------------------------------------------------------+\n..\nReading symbols from //gdb_tests/main...\n(gdb) b main\nBreakpoint 1 at 0x10000530: file //gdb_tests/main.c, line 5.\n(gdb) r\nStarting program: /gdb_tests/main\n\nBreakpoint 1, main () at //gdb_tests/main.c:5\n5           printf (\"lib_func() \u003d %d \\n\", lib_func());\n(gdb) call lib_func()\n$1 \u003d 778\n(gdb) q\nA debugging session is active.\n\n        Inferior 1 [process 7340312] will be killed.\n\nQuit anyway? (y or n) y\n\nAlso some clean ups of code and additions, they are:\n1: Replaced old APIs like bfd_map_over_sections with gdb_bfd_sections() and range-based loops.\n2: Used helpers like obstack_strndup instead of manual allocation like changing p \u003d (char *) obstack_alloc (\u0026objfile-\u003eobjfile_obstack, and strncpy (p, symbol-\u003en_name, E_SYMNMLEN);\nto *name \u003d obstack_strndup(\u0026objfile-\u003eobjfile_obstack, symbol-\u003en_name, E_SYMNMLEN);\n3: Removed unused macros as unnecessary global variables as you mentioned\n4: Replaced perror_with_name with error() and bfd_errmsg. See: error(_(\"reading symbol table: %s\"), bfd_errmsg(bfd_get_error()));\n5: Also used bfd_get_section_alloc_size().\n6: Eliminated the xcoff_find_targ_sec_arg struct used in GDB 17 or earlier because it is no longer necessary for context handling.\n7: Eliminated the find_targ_sec () used in GDB 17 or earlier since we find the bfd_sect in xcoff_secnum_to_sections().\n\nApproved-By: Tom Tromey \u003ctom@tromey.com\u003e\n",
  "tree_diff": [
    {
      "type": "modify",
      "old_id": "7caa3644b06ebf5641412bc6bffbcb8c8b55c998",
      "old_mode": 33188,
      "old_path": "gdb/xcoffread.c",
      "new_id": "66775356960e6b11212e7246f94c45c4fb4a722b",
      "new_mode": 33188,
      "new_path": "gdb/xcoffread.c"
    }
  ]
}
