Simplify get_frame_unwind_table

Message ID 20250117190453.1405884-1-tromey@adacore.com
State New
Headers
Series Simplify get_frame_unwind_table |

Checks

Context Check Description
linaro-tcwg-bot/tcwg_gdb_build--master-aarch64 fail Patch failed to apply
linaro-tcwg-bot/tcwg_gdb_build--master-arm fail Patch failed to apply

Commit Message

Tom Tromey Jan. 17, 2025, 7:04 p.m. UTC
  This simplifies get_frame_unwind_table, changing it to use the
registry 'emplace' method and to pass the initialization iterators to
the constructor.  This fixes a build problem on x86 -- reported by the
auto-builder -- as a side effect.
---
 gdb/frame-unwind.c | 13 ++++---------
 1 file changed, 4 insertions(+), 9 deletions(-)
  

Comments

Guinevere Larsen Jan. 17, 2025, 7:14 p.m. UTC | #1
On 1/17/25 4:04 PM, Tom Tromey wrote:
> This simplifies get_frame_unwind_table, changing it to use the
> registry 'emplace' method and to pass the initialization iterators to
> the constructor.  This fixes a build problem on x86 -- reported by the
> auto-builder -- as a side effect.

I've tested this on buildbot and it fix the build. I encourage you to 
push it!

Tested-By: Guinevere Larsen <guinevere@redhat.com>
  
Guinevere Larsen Jan. 17, 2025, 8:33 p.m. UTC | #2
On 1/17/25 4:14 PM, Guinevere Larsen wrote:
> On 1/17/25 4:04 PM, Tom Tromey wrote:
>> This simplifies get_frame_unwind_table, changing it to use the
>> registry 'emplace' method and to pass the initialization iterators to
>> the constructor.  This fixes a build problem on x86 -- reported by the
>> auto-builder -- as a side effect.
>
> I've tested this on buildbot and it fix the build. I encourage you to 
> push it!
>
> Tested-By: Guinevere Larsen <guinevere@redhat.com>
>
Oh, seems like I replied this too early. Build fails on debian-armhf, 
see log here: 
https://builder.sourceware.org/buildbot/#/builders/72/builds/5614/steps/4/logs/stdio
  
Tom Tromey Jan. 17, 2025, 9:27 p.m. UTC | #3
>> Tested-By: Guinevere Larsen <guinevere@redhat.com>

Guinevere> Oh, seems like I replied this too early. Build fails on debian-armhf,
Guinevere> see log here:
Guinevere> https://builder.sourceware.org/buildbot/#/builders/72/builds/5614/steps/4/logs/stdio

Ah well.  I already pushed it.

My only theory for what's going wrong there is compiler bug.
I think the code looks ok.

Tom
  
Tom de Vries Jan. 18, 2025, 3:25 p.m. UTC | #4
On 1/17/25 22:27, Tom Tromey wrote:
>>> Tested-By: Guinevere Larsen <guinevere@redhat.com>
> 
> Guinevere> Oh, seems like I replied this too early. Build fails on debian-armhf,
> Guinevere> see log here:
> Guinevere> https://builder.sourceware.org/buildbot/#/builders/72/builds/5614/steps/4/logs/stdio
> 
> Ah well.  I already pushed it.
> 
> My only theory for what's going wrong there is compiler bug.
> I think the code looks ok.

FWIW, I've build gdb with gcc 12.4.0 on debian testing, and didn't 
manage to reproduce this problem.

Thanks,
- Tom
  

Patch

diff --git a/gdb/frame-unwind.c b/gdb/frame-unwind.c
index fab9b3c981a..33b23f91feb 100644
--- a/gdb/frame-unwind.c
+++ b/gdb/frame-unwind.c
@@ -73,15 +73,10 @@  static std::vector<const frame_unwind *> &
 get_frame_unwind_table (struct gdbarch *gdbarch)
 {
   std::vector<const frame_unwind *> *table = frame_unwind_data.get (gdbarch);
-  if (table != nullptr)
-    return *table;
-
-  table = new std::vector<const frame_unwind *>;
-  table->insert (table->begin (), standard_unwinders.begin (),
-		 standard_unwinders.end ());
-
-  frame_unwind_data.set (gdbarch, table);
-
+  if (table == nullptr)
+    table = frame_unwind_data.emplace (gdbarch,
+				       standard_unwinders.begin (),
+				       standard_unwinders.end ());
   return *table;
 }