From 6827fe201627357b12176385d26c8fb4ab35d83358555cf3bc7379e4596d391b Mon Sep 17 00:00:00 2001 From: Tom de Vries Date: Sun, 29 Oct 2023 08:12:22 +0000 Subject: [PATCH] - Maintenance script qa.sh: * Add comment to kfail for PR30528. * Add UNRESOLVED kfail for gdb.base/gcore-excessive-memory.exp. * Add UNRESOLVED kfail for PR31001. * Remove PR27238 kfail. * Add powerpc64le hw watchpoint kfails. * Add PR31004 kfail. * Add PR30531 kfail. - Patches added (backport from master): * xcoffread.c-fix-werror-dangling-pointer-issue-with-m.patch * avoid-manual-memory-management-in-go-lang.c.patch * gdb-go-handle-v3-go_0-mangled-prefix.patch OBS-URL: https://build.opensuse.org/package/show/devel:gcc/gdb?expand=0&rev=367 --- ...anual-memory-management-in-go-lang.c.patch | 202 ++++++++++++++++++ gdb-go-handle-v3-go_0-mangled-prefix.patch | 138 ++++++++++++ gdb.changes | 16 ++ gdb.spec | 6 + qa.sh | 58 ++++- ...werror-dangling-pointer-issue-with-m.patch | 139 ++++++++++++ 6 files changed, 554 insertions(+), 5 deletions(-) create mode 100644 avoid-manual-memory-management-in-go-lang.c.patch create mode 100644 gdb-go-handle-v3-go_0-mangled-prefix.patch create mode 100644 xcoffread.c-fix-werror-dangling-pointer-issue-with-m.patch diff --git a/avoid-manual-memory-management-in-go-lang.c.patch b/avoid-manual-memory-management-in-go-lang.c.patch new file mode 100644 index 0000000..093f577 --- /dev/null +++ b/avoid-manual-memory-management-in-go-lang.c.patch @@ -0,0 +1,202 @@ +From 4e0e7ff14ba271576232160bf337639662a2ea23 Mon Sep 17 00:00:00 2001 +From: Tom Tromey +Date: Thu, 16 Feb 2023 17:36:29 -0700 +Subject: [PATCH 2/3] Avoid manual memory management in go-lang.c + +I noticed a couple of spots in go-lang.c that could be improved by +using unique_ptr. + +Reviewed-By: Andrew Burgess +--- + gdb/dwarf2/read.c | 2 +- + gdb/go-exp.c | 287 +++++++++++++++++++++++----------------------- + gdb/go-exp.y | 8 +- + gdb/go-lang.c | 40 +++---- + gdb/go-lang.h | 11 +- + 5 files changed, 173 insertions(+), 175 deletions(-) + +diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c +index 8aa7f8c31e5..61f4bd75013 100644 +--- a/gdb/dwarf2/read.c ++++ b/gdb/dwarf2/read.c +@@ -7890,7 +7890,7 @@ fixup_go_packaging (struct dwarf2_cu *cu) + && sym->aclass () == LOC_BLOCK) + { + gdb::unique_xmalloc_ptr this_package_name +- (go_symbol_package_name (sym)); ++ = go_symbol_package_name (sym); + + if (this_package_name == NULL) + continue; +diff --git a/gdb/go-exp.y b/gdb/go-exp.y +index cbaa79ee18c..542a06d06d6 100644 +--- a/gdb/go-exp.y ++++ b/gdb/go-exp.y +@@ -1393,16 +1393,16 @@ classify_name (struct parser_state *par_state, const struct block *block) + current package. */ + + { +- char *current_package_name = go_block_package_name (block); ++ gdb::unique_xmalloc_ptr current_package_name ++ = go_block_package_name (block); + + if (current_package_name != NULL) + { + struct stoken sval = +- build_packaged_name (current_package_name, +- strlen (current_package_name), ++ build_packaged_name (current_package_name.get (), ++ strlen (current_package_name.get ()), + copy.c_str (), copy.size ()); + +- xfree (current_package_name); + sym = lookup_symbol (sval.ptr, block, VAR_DOMAIN, + &is_a_field_of_this); + if (sym.symbol) +diff --git a/gdb/go-lang.c b/gdb/go-lang.c +index 7549f14dc63..f9176ace71d 100644 +--- a/gdb/go-lang.c ++++ b/gdb/go-lang.c +@@ -163,11 +163,8 @@ unpack_package_and_object (char *buf, + + Space for the resulting strings is malloc'd in one buffer. + PACKAGEP,OBJECTP,METHOD_TYPE* will (typically) point into this buffer. +- [There are a few exceptions, but the caller is still responsible for +- freeing the resulting pointer.] + A pointer to this buffer is returned, or NULL if symbol isn't a + mangled Go symbol. +- The caller is responsible for freeing the result. + + *METHOD_TYPE_IS_POINTERP is set to a boolean indicating if + the method type is a pointer. +@@ -180,7 +177,7 @@ unpack_package_and_object (char *buf, + If we ever need to unpack the method type, this routine should work + for that too. */ + +-static char * ++static gdb::unique_xmalloc_ptr + unpack_mangled_go_symbol (const char *mangled_name, + const char **packagep, + const char **objectp, +@@ -209,9 +206,10 @@ unpack_mangled_go_symbol (const char *mangled_name, + /* main.init is mangled specially. */ + if (strcmp (mangled_name, "__go_init_main") == 0) + { +- char *package = xstrdup ("main"); ++ gdb::unique_xmalloc_ptr package ++ = make_unique_xstrdup ("main"); + +- *packagep = package; ++ *packagep = package.get (); + *objectp = "init"; + return package; + } +@@ -219,9 +217,10 @@ unpack_mangled_go_symbol (const char *mangled_name, + /* main.main is mangled specially (missing prefix). */ + if (strcmp (mangled_name, "main.main") == 0) + { +- char *package = xstrdup ("main"); ++ gdb::unique_xmalloc_ptr package ++ = make_unique_xstrdup ("main"); + +- *packagep = package; ++ *packagep = package.get (); + *objectp = "main"; + return package; + } +@@ -261,7 +260,8 @@ unpack_mangled_go_symbol (const char *mangled_name, + + /* At this point we've decided we have a mangled Go symbol. */ + +- buf = xstrdup (mangled_name); ++ gdb::unique_xmalloc_ptr result = make_unique_xstrdup (mangled_name); ++ buf = result.get (); + + /* Search backwards looking for "N". */ + p = buf + len; +@@ -317,7 +317,7 @@ unpack_mangled_go_symbol (const char *mangled_name, + } + + unpack_package_and_object (buf, packagep, objectp); +- return buf; ++ return result; + } + + /* Implements the la_demangle language_defn routine for language Go. +@@ -381,10 +381,9 @@ go_language::demangle_symbol (const char *mangled_name, int options) const + return make_unique_xstrdup ((const char *) obstack_finish (&tempbuf)); + } + +-/* Given a Go symbol, return its package or NULL if unknown. +- Space for the result is malloc'd, caller must free. */ ++/* See go-lang.h. */ + +-char * ++gdb::unique_xmalloc_ptr + go_symbol_package_name (const struct symbol *sym) + { + const char *mangled_name = sym->linkage_name (); +@@ -393,8 +392,7 @@ go_symbol_package_name (const struct symbol *sym) + const char *method_type_package_name; + const char *method_type_object_name; + int method_type_is_pointer; +- char *name_buf; +- char *result; ++ gdb::unique_xmalloc_ptr name_buf; + + gdb_assert (sym->language () == language_go); + name_buf = unpack_mangled_go_symbol (mangled_name, +@@ -405,15 +403,12 @@ go_symbol_package_name (const struct symbol *sym) + /* Some Go symbols don't have mangled form we interpret (yet). */ + if (name_buf == NULL) + return NULL; +- result = xstrdup (package_name); +- xfree (name_buf); +- return result; ++ return make_unique_xstrdup (package_name); + } + +-/* Return the package that BLOCK is in, or NULL if there isn't one. +- Space for the result is malloc'd, caller must free. */ ++/* See go-lang.h. */ + +-char * ++gdb::unique_xmalloc_ptr + go_block_package_name (const struct block *block) + { + while (block != NULL) +@@ -422,7 +417,8 @@ go_block_package_name (const struct block *block) + + if (function != NULL) + { +- char *package_name = go_symbol_package_name (function); ++ gdb::unique_xmalloc_ptr package_name ++ = go_symbol_package_name (function); + + if (package_name != NULL) + return package_name; +diff --git a/gdb/go-lang.h b/gdb/go-lang.h +index f0929cc3ac5..8edfe6ed53a 100644 +--- a/gdb/go-lang.h ++++ b/gdb/go-lang.h +@@ -62,9 +62,14 @@ extern const char *go_main_name (void); + + extern enum go_type go_classify_struct_type (struct type *type); + +-extern char *go_symbol_package_name (const struct symbol *sym); +- +-extern char *go_block_package_name (const struct block *block); ++/* Given a Go symbol, return its package or nullptr if unknown. */ ++extern gdb::unique_xmalloc_ptr go_symbol_package_name ++ (const struct symbol *sym); ++ ++/* Return the package that BLOCK is in, or nullptr if there isn't ++ one. */ ++extern gdb::unique_xmalloc_ptr go_block_package_name ++ (const struct block *block); + + extern const struct builtin_go_type *builtin_go_type (struct gdbarch *); + +-- +2.35.3 + diff --git a/gdb-go-handle-v3-go_0-mangled-prefix.patch b/gdb-go-handle-v3-go_0-mangled-prefix.patch new file mode 100644 index 0000000..58676f1 --- /dev/null +++ b/gdb-go-handle-v3-go_0-mangled-prefix.patch @@ -0,0 +1,138 @@ +From 6c9e159dbd1a35aafa134fcd52982174236a8dd9 Mon Sep 17 00:00:00 2001 +From: Tom de Vries +Date: Thu, 5 Oct 2023 23:22:11 +0200 +Subject: [PATCH 3/3] [gdb/go] Handle v3 go_0 mangled prefix + +With gcc-10 we have: +... +(gdb) break package2.Foo^M +Breakpoint 2 at 0x402563: file package2.go, line 5.^M +(gdb) PASS: gdb.go/package.exp: setting breakpoint 1 +... +but with gcc-11: +... +gdb) break package2.Foo^M +Function "package2.Foo" not defined.^M +Make breakpoint pending on future shared library load? (y or [n]) n^M +(gdb) FAIL: gdb.go/package.exp: gdb_breakpoint: set breakpoint at package2.Foo +... + +In the gcc-10 case, though the exec contains dwarf, it's not used to set the +breakpoint (which is an independent problem, filed as PR go/30941), instead +the minimal symbol information is used. + +The minimal symbol information changed between gcc-10 and gcc-11: +... +$ nm a.out.10 | grep Foo +000000000040370d T go.package2.Foo +0000000000404e50 R go.package2.Foo..f +$ nm a.out.11 | grep Foo +0000000000403857 T go_0package2.Foo +0000000000405030 R go_0package2.Foo..f +... + +A new v3 mangling scheme was used. The mangling schemes define a separator +character and mangling character: +- for v2, dot is used both as separator character and mangling character, and +- for v3, dot is used as separator character and underscore as mangling + character. + +For more details, see [1] and [2]. + +In v3, "_0" demangles to ".". [ See gcc commit a01dda3c23b ("compiler, libgo: +change mangling scheme"), function Special_char_code::Special_char_code. ] + +Handle the new go_0 prefix in unpack_mangled_go_symbol, which fixes the +test-case. + +Note that this doesn't fix this regression: +... +$ gccgo-10 package2.go -c -g0 +$ gccgo-10 package1.go package2.o -g0 +$ gdb -q -batch a.out -ex "break go.package2.Foo" +Breakpoint 1 at 0x40370d +$ gccgo-11 package2.go -c -g0 +$ gccgo-11 package1.go package2.o -g0 +$ gdb -q -batch a.out -ex "break go.package2.Foo" +Function "go.package2.Foo" not defined. +... + +With gcc-10, we set a breakpoint on the mangled minimal symbol. That +one has simply changed for gcc-11, so it's equivalent to using: +... +$ gdb -q -batch a.out -ex "break go_0package2.Foo" +Breakpoint 1 at 0x403857 +... +which does work. + +Tested on x86_64-linux: +- openSUSE Leap 15.4, using gccgo-7, +- openSUSE Tumbleweed, using gccgo-13. + +PR go/27238 +Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=27238 + +[1] https://go-review.googlesource.com/c/gofrontend/+/271726 +[2] https://github.com/golang/go/issues/41862#issuecomment-707244103 +--- + gdb/go-lang.c | 30 +++++++++++++++++++++++++++--- + 1 file changed, 27 insertions(+), 3 deletions(-) + +diff --git a/gdb/go-lang.c b/gdb/go-lang.c +index f9176ace71d..8a5568f56e0 100644 +--- a/gdb/go-lang.c ++++ b/gdb/go-lang.c +@@ -233,16 +233,28 @@ unpack_mangled_go_symbol (const char *mangled_name, + libgo_.*: used by gccgo's runtime + + Thus we don't support -fgo-prefix (except as used by the runtime). */ +- if (!startswith (mangled_name, "go.") +- && !startswith (mangled_name, "libgo_")) ++ bool v3; ++ if (startswith (mangled_name, "go_0")) ++ /* V3 mangling detected, see ++ https://go-review.googlesource.com/c/gofrontend/+/271726 . */ ++ v3 = true; ++ else if (startswith (mangled_name, "go.") ++ || startswith (mangled_name, "libgo_")) ++ v3 = false; ++ else + return NULL; + + /* Quick check for whether a search may be fruitful. */ + /* Ignore anything with @plt, etc. in it. */ + if (strchr (mangled_name, '@') != NULL) + return NULL; ++ + /* It must have at least two dots. */ +- first_dot = strchr (mangled_name, '.'); ++ if (v3) ++ first_dot = strchr (mangled_name, '0'); ++ else ++ first_dot = strchr (mangled_name, '.'); ++ + if (first_dot == NULL) + return NULL; + /* Treat "foo.bar" as unmangled. It can collide with lots of other +@@ -263,6 +275,18 @@ unpack_mangled_go_symbol (const char *mangled_name, + gdb::unique_xmalloc_ptr result = make_unique_xstrdup (mangled_name); + buf = result.get (); + ++ if (v3) ++ { ++ /* Replace "go_0" with "\0go.". */ ++ buf[0] = '\0'; ++ buf[1] = 'g'; ++ buf[2] = 'o'; ++ buf[3] = '.'; ++ ++ /* Skip the '\0'. */ ++ buf++; ++ } ++ + /* Search backwards looking for "N". */ + p = buf + len; + saw_digit = method_type = NULL; +-- +2.35.3 + diff --git a/gdb.changes b/gdb.changes index 571fc7b..49476c9 100644 --- a/gdb.changes +++ b/gdb.changes @@ -1,3 +1,19 @@ +------------------------------------------------------------------- +Thu Oct 26 12:51:55 UTC 2023 - Tom de Vries + +- Maintenance script qa.sh: + * Add comment to kfail for PR30528. + * Add UNRESOLVED kfail for gdb.base/gcore-excessive-memory.exp. + * Add UNRESOLVED kfail for PR31001. + * Remove PR27238 kfail. + * Add powerpc64le hw watchpoint kfails. + * Add PR31004 kfail. + * Add PR30531 kfail. +- Patches added (backport from master): + * xcoffread.c-fix-werror-dangling-pointer-issue-with-m.patch + * avoid-manual-memory-management-in-go-lang.c.patch + * gdb-go-handle-v3-go_0-mangled-prefix.patch + ------------------------------------------------------------------- Thu Oct 26 09:24:04 UTC 2023 - Tom de Vries diff --git a/gdb.spec b/gdb.spec index 0a78447..b14993f 100644 --- a/gdb.spec +++ b/gdb.spec @@ -331,6 +331,9 @@ Patch2037: gdb-cli-handle-pending-c-after-rl_callback_read_char.patch Patch2038: gdb-testsuite-add-have_host_locale.patch Patch2039: gdb-symtab-find-main-language-without-symtab-expansi.patch Patch2040: gdb-symtab-don-t-deduplicate-variables-in-gdb-index.patch +Patch2041: xcoffread.c-fix-werror-dangling-pointer-issue-with-m.patch +Patch2042: avoid-manual-memory-management-in-go-lang.c.patch +Patch2043: gdb-go-handle-v3-go_0-mangled-prefix.patch # Backports from master, not yet available in next release. @@ -767,6 +770,9 @@ find -name "*.info*"|xargs rm -f %patch2038 -p1 %patch2039 -p1 %patch2040 -p1 +%patch2041 -p1 +%patch2042 -p1 +%patch2043 -p1 %patch2070 -p1 diff --git a/qa.sh b/qa.sh index 6d7bdec..6fe694e 100644 --- a/qa.sh +++ b/qa.sh @@ -304,6 +304,7 @@ kfail=( "FAIL: gdb.base/printcmds.exp: print {unsigned char\[\]}{0xffffffff}" # https://sourceware.org/bugzilla/show_bug.cgi?id=30528 + # Fixed in 15. Backportable to 14. "FAIL: gdb.dwarf2/per-bfd-sharing.exp: couldn't remove files in temporary cache dir" ) # kfail @@ -394,6 +395,10 @@ kfail_sle12=( "FAIL: gdb.fortran/module.exp: print var_d" "FAIL: gdb.fortran/module.exp: print var_x value 31" + # https://sourceware.org/bugzilla/show_bug.cgi?id=30531 + "FAIL: gdb.threads/clone-thread_db.exp: continue to clone_fn \(the program exited\)" + "FAIL: gdb.threads/clone-thread_db.exp: continue to end \(the program is no longer running\)" + ) # kfail_sle12 kfail_sle11=( @@ -452,10 +457,6 @@ kfail_factory=( # Similar error message to the one above, see if fixing that one fixes this. "FAIL: gdb.threads/clone-new-thread-event.exp: catch SIGUSR1" - # https://sourceware.org/bugzilla/show_bug.cgi?id=27238 - "FAIL: gdb.go/package.exp: gdb_breakpoint: set breakpoint at package2.Foo" - "FAIL: gdb.go/package.exp: going to first breakpoint \(the program exited\)" - # https://sourceware.org/bugzilla/show_bug.cgi?id=28551 "FAIL: gdb.go/package.exp: going to first breakpoint \\(GDB internal error\\)" @@ -613,9 +614,51 @@ kfail_powerpc64le=( # https://sourceware.org/bugzilla/show_bug.cgi?id=30542 "FAIL: gdb.base/watch-before-fork.exp: test: continue to catch fork" - # https://sourceware.org/bugzilla/show_bug.cgi?id=30543 "FAIL: gdb.python/py-send-packet.exp: call python run_auxv_send_packet_test function" + + # Cluster of fails related to hw watchpoint support. + "FAIL: gdb.ada/scoped_watch.exp:" + "FAIL: gdb.ada/task_watch.exp:" + "FAIL: gdb.ada/watch_minus_l.exp:" + "FAIL: gdb.base/watch-before-fork.exp:" + "FAIL: gdb.base/watch-bitfields.exp:" + "FAIL: gdb.base/watch-cond.exp:" + "FAIL: gdb.base/watch-cond-infcall.exp:" + "FAIL: gdb.base/watchpoint-during-step.exp:" + "FAIL: gdb.base/watchpoint.exp:" + "FAIL: gdb.base/watchpoint-hw-attach.exp:" + "FAIL: gdb.base/watchpoint-hw-hit-once.exp:" + "FAIL: gdb.base/watchpoints.exp:" + "FAIL: gdb.base/watchpoint-solib.exp:" + "FAIL: gdb.base/watchpoint-stops-at-right-insn.exp:" + "FAIL: gdb.base/watchpoint-unaligned.exp:" + "FAIL: gdb.base/watch-read.exp:" + "FAIL: gdb.base/watch_thread_num.exp:" + "FAIL: gdb.base/watch-vfork.exp:" + "FAIL: gdb.cp/watch-cp.exp:" + "FAIL: gdb.mi/mi-watch.exp:" + "FAIL: gdb.threads/step-over-trips-on-watchpoint.exp:" + "FAIL: gdb.threads/watchpoint-fork.exp:" + "FAIL: gdb.threads/watchthreads2.exp:" + "FAIL: gdb.threads/wp-replication.exp:" + "FAIL: gdb.base/display.exp:" + "FAIL: gdb.base/recurse.exp:" + "FAIL: gdb.base/gdb11531.exp:" + "FAIL: gdb.base/pr11022.exp:" + "FAIL: gdb.base/value-double-free.exp: continue \(the program exited\)" + "FAIL: gdb.base/value-double-free.exp: print empty\(\)" + "FAIL: gdb.cp/annota2.exp: watch triggered on a.x \(timeout\)" + "FAIL: gdb.cp/annota2.exp: annotate-quit" + "FAIL: gdb.cp/annota3.exp: watch triggered on a.x \(timeout\)" + "FAIL: gdb.cp/annota3.exp: annotate-quit \(pattern 1\)" + "FAIL: gdb.mi/pr11022.exp:" + "FAIL: gdb.python/py-breakpoint.exp: test_watchpoints: Test watchpoint write \(the program exited\)" + "FAIL: gdb.python/py-breakpoint.exp: test_bkpt_internal: Test watchpoint write \(the program exited\)" + "FAIL: gdb.python/py-breakpoint.exp: test_bkpt_eval_funcs: Test watchpoint write \(the program exited\)" + + # https://sourceware.org/bugzilla/show_bug.cgi?id=31004 + "FAIL: gdb.base/run-control-while-bg-execution.exp: action1=kill: action2=run: run" ) kfail_powerpc64le_sle12=( @@ -744,11 +787,16 @@ case $n in # https://sourceware.org/bugzilla/show_bug.cgi?id=28323 "SLE-12.x86_64.*gdb.ada/mi_dyn_arr.exp" + # Gdb runs out of virtual memory, we can expect an internal error. + "UNRESOLVED: gdb.base/gcore-excessive-memory.exp: attach" "UNRESOLVED: gdb.base/gcore-excessive-memory.exp: verify we can get to main" # https://sourceware.org/bugzilla/show_bug.cgi?id=30547 "UNRESOLVED: gdb.base/vfork-follow-parent.exp: resolution_method=schedule-multiple: print unblock_parent = 1" "UNRESOLVED: gdb.base/vfork-follow-parent.exp: resolution_method=schedule-multiple: continue to break_parent" + + # https://sourceware.org/bugzilla/show_bug.cgi?id=31001 + "UNRESOLVED: gdb.threads/async.exp: thread 1: current thread is 1" ) kfail_re=$(join "|" "${kfail[@]}") diff --git a/xcoffread.c-fix-werror-dangling-pointer-issue-with-m.patch b/xcoffread.c-fix-werror-dangling-pointer-issue-with-m.patch new file mode 100644 index 0000000..db00512 --- /dev/null +++ b/xcoffread.c-fix-werror-dangling-pointer-issue-with-m.patch @@ -0,0 +1,139 @@ +From c835eac78b389ce1e29aade9d0468c13854c1cb9 Mon Sep 17 00:00:00 2001 +From: Mark Wielaard +Date: Sat, 29 Apr 2023 22:46:11 +0200 +Subject: [PATCH 1/3] xcoffread.c: Fix -Werror=dangling-pointer= issue with + main_subfile. +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +GCC 13 points out that main_subfile has local function scope, but a +pointer to it is assigned to the global inclTable array subfile +element field: + +In function ‘void process_linenos(CORE_ADDR, CORE_ADDR)’, + inlined from ‘void aix_process_linenos(objfile*)’ at xcoffread.c:727:19, + inlined from ‘void aix_process_linenos(objfile*)’ at xcoffread.c:720:1: +xcoffread.c:629:37: error: storing the address of local variable ‘main_subfile’ in ‘*inclTable.19_45 + _28._inclTable::subfile’ [-Werror=dangling-pointer=] + 629 | inclTable[ii].subfile = &main_subfile; + | ~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~ +xcoffread.c: In function ‘void aix_process_linenos(objfile*)’: +xcoffread.c:579:18: note: ‘main_subfile’ declared here + 579 | struct subfile main_subfile; + | ^~~~~~~~~~~~ +xcoffread.c:496:19: note: ‘inclTable’ declared here + 496 | static InclTable *inclTable; /* global include table */ + | ^~~~~~~~~ + +Fix this by making main_subfile file static. And allocate and +deallocated together with inclTable in allocate_include_entry and +xcoff_symfile_finish. Adjust the use of main_subfile in +process_linenos to take a pointer to the subfile. +--- + gdb/xcoffread.c | 24 +++++++++++++----------- + 1 file changed, 13 insertions(+), 11 deletions(-) + +diff --git a/gdb/xcoffread.c b/gdb/xcoffread.c +index 52ae3aecb97..53779259b57 100644 +--- a/gdb/xcoffread.c ++++ b/gdb/xcoffread.c +@@ -501,6 +501,9 @@ static int inclIndx; /* last entry to table */ + static int inclLength; /* table length */ + static int inclDepth; /* nested include depth */ + ++/* subfile structure for the main compilation unit. */ ++static subfile *main_subfile; ++ + static void allocate_include_entry (void); + + static void +@@ -551,6 +554,7 @@ allocate_include_entry (void) + inclTable = XCNEWVEC (InclTable, INITIAL_INCLUDE_TABLE_LENGTH); + inclLength = INITIAL_INCLUDE_TABLE_LENGTH; + inclIndx = 0; ++ main_subfile = new subfile; + } + else if (inclIndx >= inclLength) + { +@@ -578,9 +582,6 @@ process_linenos (CORE_ADDR start, CORE_ADDR end) + file_ptr max_offset + = XCOFF_DATA (this_symtab_objfile)->max_lineno_offset; + +- /* subfile structure for the main compilation unit. */ +- struct subfile main_subfile; +- + /* In the main source file, any time we see a function entry, we + reset this variable to function's absolute starting line number. + All the following line numbers in the function are relative to +@@ -599,7 +600,7 @@ process_linenos (CORE_ADDR start, CORE_ADDR end) + /* All source lines were in the main source file. None in include + files. */ + +- enter_line_range (&main_subfile, offset, 0, start, end, ++ enter_line_range (main_subfile, offset, 0, start, end, + &main_source_baseline); + + else +@@ -616,7 +617,7 @@ process_linenos (CORE_ADDR start, CORE_ADDR end) + if (offset < inclTable[ii].begin) + { + enter_line_range +- (&main_subfile, offset, inclTable[ii].begin - linesz, ++ (main_subfile, offset, inclTable[ii].begin - linesz, + start, 0, &main_source_baseline); + } + +@@ -627,9 +628,9 @@ process_linenos (CORE_ADDR start, CORE_ADDR end) + + main_source_baseline = inclTable[ii].funStartLine; + enter_line_range +- (&main_subfile, inclTable[ii].begin, inclTable[ii].end, ++ (main_subfile, inclTable[ii].begin, inclTable[ii].end, + start, 0, &main_source_baseline); +- inclTable[ii].subfile = &main_subfile; ++ inclTable[ii].subfile = main_subfile; + } + else + { +@@ -651,24 +652,24 @@ process_linenos (CORE_ADDR start, CORE_ADDR end) + enter remaining lines of the main file, if any left. */ + if (offset < max_offset + 1 - linesz) + { +- enter_line_range (&main_subfile, offset, 0, start, end, ++ enter_line_range (main_subfile, offset, 0, start, end, + &main_source_baseline); + } + } + + /* Process main file's line numbers. */ +- if (!main_subfile.line_vector_entries.empty ()) ++ if (!main_subfile->line_vector_entries.empty ()) + { + /* Line numbers are not necessarily ordered. xlc compilation will + put static function to the end. */ +- arrange_linetable (main_subfile.line_vector_entries); ++ arrange_linetable (main_subfile->line_vector_entries); + } + + /* Now, process included files' line numbers. */ + + for (int ii = 0; ii < inclIndx; ++ii) + { +- if (inclTable[ii].subfile != ((struct subfile *) &main_subfile) ++ if (inclTable[ii].subfile != main_subfile + && !inclTable[ii].subfile->line_vector_entries.empty ()) + { + /* Line numbers are not necessarily ordered. xlc compilation will +@@ -1811,6 +1812,7 @@ xcoff_symfile_finish (struct objfile *objfile) + { + xfree (inclTable); + inclTable = NULL; ++ delete main_subfile; + } + inclIndx = inclLength = inclDepth = 0; + } + +base-commit: 38a5283b23caca5317eaeb7927a5a11eccc6eb69 +-- +2.35.3 +