public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] Fix AIX build break
@ 2024-01-12  9:20 Aditya Kamath1
  2024-01-12  9:50 ` Tom de Vries
  0 siblings, 1 reply; 26+ messages in thread
From: Aditya Kamath1 @ 2024-01-12  9:20 UTC (permalink / raw)
  To: Ulrich Weigand, Aditya Kamath1 via Gdb-patches; +Cc: Sangamesh Mallayya


[-- Attachment #1.1: Type: text/plain, Size: 1734 bytes --]

Respected community members,

Hi,

Our CI in AIX for GDB has been broken for the last two days with the following error.

CXXLD  gdb
ld: 0711-317 ERROR: Undefined symbol: _ZTH23deprecated_warning_hook
ld: 0711-317 ERROR: Undefined symbol: ._ZTH23deprecated_warning_hook
ld: 0711-345 Use the -bloadmap or -bnoquiet option to obtain more information.
collect2: error: ld returned 8 exit status
gmake: *** [Makefile:2184: gdb] Error 1

These symbols came due to the commit https://sourceware.org/git/?p=binutils-gdb.git;a=commitdiff;h=54b815ddb428944a70694e3767a0fadbdd9ca9ea

The problem in AIX is marking a variable for thread storage as thread_local that makes that symbol a weak symbol. The dump output of the complaints.o shows this as pasted here:-
# dump -tov -X64 complaints.o | grep _ZTH23deprecated_warning_hook
[32]    m   0x00000000     undef     1    weak                    _ZTH23deprecated_warning_hook
[36]    m   0x00000000     undef     1    weak                    ._ZTH23deprecated_warning_hook
[3209]  m   0x000203d8     .data     1  unamex                    _ZTH23deprecated_warning_hook

Hence in the final stage of compilation while creating the binary gdb, the ld error came and the compilation is unsuccessful since the symbol is not visible though complaints.c file was successfully compiled.

This patch is a fix for the same where instead of thread_local we used __thread and GDB now compiles in AIX. Please find attached the patch. (See: 0001-Fix-AIX-build-break.patch).

I want to know your opinion about this. Also, I do not know the impact of this change on other targets. If we can do this better, kindly let me know.

Have a nice day ahead.

Thanks and regards,
Aditya.

[-- Attachment #2: 0001-Fix-AIX-build-break.patch --]
[-- Type: application/octet-stream, Size: 2632 bytes --]

From 9fd8e08fea93e631d86cfca2856d5d8dc0da4da9 Mon Sep 17 00:00:00 2001
From: Aditya Vidyadhar Kamath <Aditya.Kamath1@ibm.com>
Date: Fri, 12 Jan 2024 01:30:58 -0600
Subject: [PATCH] Fix AIX build break.

A recent commit broke AIX build. The thread_local type defined functions
were being considered a weak symbol and hence while creating the binary these
symbols were not visible. If we use __thread instead then this issue is fixed in AIX.

This patch is a fix for the same.
---
 gdb/complaints.c | 2 +-
 gdb/complaints.h | 2 +-
 gdb/defs.h       | 2 +-
 gdb/top.c        | 2 +-
 4 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/gdb/complaints.c b/gdb/complaints.c
index eb648c655ed..306e4ed4bc8 100644
--- a/gdb/complaints.c
+++ b/gdb/complaints.c
@@ -79,7 +79,7 @@ clear_complaints ()
 
 /* See complaints.h.  */
 
-thread_local complaint_interceptor *complaint_interceptor::g_complaint_interceptor;
+__thread complaint_interceptor *complaint_interceptor::g_complaint_interceptor;
 
 /* See complaints.h.  */
 
diff --git a/gdb/complaints.h b/gdb/complaints.h
index 1626f200685..4dc1b7b70e4 100644
--- a/gdb/complaints.h
+++ b/gdb/complaints.h
@@ -103,7 +103,7 @@ class complaint_interceptor
     ATTRIBUTE_PRINTF (1, 0);
 
   /* This object.  Used by the static callback function.  */
-  static thread_local complaint_interceptor *g_complaint_interceptor;
+  static __thread complaint_interceptor *g_complaint_interceptor;
 };
 
 /* Re-emit complaints that were collected by complaint_interceptor.
diff --git a/gdb/defs.h b/gdb/defs.h
index 2f771d8dc49..089e1c1a909 100644
--- a/gdb/defs.h
+++ b/gdb/defs.h
@@ -562,7 +562,7 @@ extern void (*deprecated_print_frame_info_listing_hook) (struct symtab * s,
 							 int noerror);
 extern int (*deprecated_query_hook) (const char *, va_list)
      ATTRIBUTE_FPTR_PRINTF(1,0);
-extern thread_local void (*deprecated_warning_hook) (const char *, va_list)
+extern __thread void (*deprecated_warning_hook) (const char *, va_list)
      ATTRIBUTE_FPTR_PRINTF(1,0);
 extern void (*deprecated_readline_begin_hook) (const char *, ...)
      ATTRIBUTE_FPTR_PRINTF_1;
diff --git a/gdb/top.c b/gdb/top.c
index 009bf2b0c1c..20d8eb6029a 100644
--- a/gdb/top.c
+++ b/gdb/top.c
@@ -221,7 +221,7 @@ int (*deprecated_query_hook) (const char *, va_list);
 
 /* Replaces most of warning.  */
 
-thread_local void (*deprecated_warning_hook) (const char *, va_list);
+__thread void (*deprecated_warning_hook) (const char *, va_list);
 
 /* These three functions support getting lines of text from the user.
    They are used in sequence.  First deprecated_readline_begin_hook is
-- 
2.41.0


^ permalink raw reply	[flat|nested] 26+ messages in thread
* [PATCH] Fix AIX build break.
@ 2024-01-17 18:28 Aditya Vidyadhar Kamath
  2024-01-17 19:25 ` Tom Tromey
  0 siblings, 1 reply; 26+ messages in thread
From: Aditya Vidyadhar Kamath @ 2024-01-17 18:28 UTC (permalink / raw)
  To: tom; +Cc: gdb-patches, Aditya Vidyadhar Kamath

A recent commit broke AIX build. The thread_local type defined functions
were being considered a weak symbol and hence while creating the binary these
symbols were not visible.

This patch is a fix for the same.
---
 gdb/complaints.c |  9 ++++++++-
 gdb/defs.h       | 26 ++++++++++++++++++++++++--
 gdb/interps.c    |  1 -
 gdb/top.c        |  4 ----
 gdb/utils.c      |  8 ++++++++
 5 files changed, 40 insertions(+), 8 deletions(-)

diff --git a/gdb/complaints.c b/gdb/complaints.c
index eb648c655ed..3a5d775b216 100644
--- a/gdb/complaints.c
+++ b/gdb/complaints.c
@@ -26,6 +26,14 @@
 #include <unordered_map>
 #include <mutex>
 
+/* local deprecated warning hook.  */
+
+void (*local_warning_hook) (const char *, va_list);
+
+/* Object for warning hook.  */
+
+deprecated_warning_hook_class obj (deprecated_warning_hook? local_warning_hook: nullptr);
+
 /* Map format strings to counters.  */
 
 static std::unordered_map<const char *, int> counters;
@@ -56,7 +64,6 @@ complaint_internal (const char *fmt, ...)
   }
 
   va_start (args, fmt);
-
   if (deprecated_warning_hook)
     (*deprecated_warning_hook) (fmt, args);
   else
diff --git a/gdb/defs.h b/gdb/defs.h
index 2f771d8dc49..b132c552d17 100644
--- a/gdb/defs.h
+++ b/gdb/defs.h
@@ -562,8 +562,30 @@ extern void (*deprecated_print_frame_info_listing_hook) (struct symtab * s,
 							 int noerror);
 extern int (*deprecated_query_hook) (const char *, va_list)
      ATTRIBUTE_FPTR_PRINTF(1,0);
-extern thread_local void (*deprecated_warning_hook) (const char *, va_list)
-     ATTRIBUTE_FPTR_PRINTF(1,0);
+
+static thread_local void (*deprecated_warning_hook) (const char *, va_list) = nullptr;
+typedef void (*deprecated_warning_hook_handler) (const char *, va_list) ATTRIBUTE_FPTR_PRINTF(1,0);
+
+class deprecated_warning_hook_class
+{
+  public:
+    deprecated_warning_hook_class (deprecated_warning_hook_handler new_handler);
+    ~deprecated_warning_hook_class ();
+  private:
+    deprecated_warning_hook_handler old_handler;
+};
+
+deprecated_warning_hook_class::deprecated_warning_hook_class (deprecated_warning_hook_handler new_handler)
+{
+  old_handler = deprecated_warning_hook;
+  deprecated_warning_hook = new_handler;
+}
+
+deprecated_warning_hook_class::~deprecated_warning_hook_class ()
+{
+  deprecated_warning_hook = old_handler;
+}
+
 extern void (*deprecated_readline_begin_hook) (const char *, ...)
      ATTRIBUTE_FPTR_PRINTF_1;
 extern char *(*deprecated_readline_hook) (const char *);
diff --git a/gdb/interps.c b/gdb/interps.c
index bec2c85e2fd..1d8d05de858 100644
--- a/gdb/interps.c
+++ b/gdb/interps.c
@@ -273,7 +273,6 @@ clear_interpreter_hooks (void)
   deprecated_print_frame_info_listing_hook = 0;
   /*print_frame_more_info_hook = 0; */
   deprecated_query_hook = 0;
-  deprecated_warning_hook = 0;
   deprecated_readline_begin_hook = 0;
   deprecated_readline_hook = 0;
   deprecated_readline_end_hook = 0;
diff --git a/gdb/top.c b/gdb/top.c
index 009bf2b0c1c..5708e530684 100644
--- a/gdb/top.c
+++ b/gdb/top.c
@@ -219,10 +219,6 @@ void (*deprecated_print_frame_info_listing_hook) (struct symtab * s,
 
 int (*deprecated_query_hook) (const char *, va_list);
 
-/* Replaces most of warning.  */
-
-thread_local void (*deprecated_warning_hook) (const char *, va_list);
-
 /* These three functions support getting lines of text from the user.
    They are used in sequence.  First deprecated_readline_begin_hook is
    called with a text string that might be (for example) a message for
diff --git a/gdb/utils.c b/gdb/utils.c
index 9ae9494d51d..c15790aea6a 100644
--- a/gdb/utils.c
+++ b/gdb/utils.c
@@ -82,6 +82,14 @@
 #include "pager.h"
 #include "run-on-main-thread.h"
 
+/* local warning hook.  */
+
+void (*local_warning_hook) (const char *, va_list);
+
+/* Object for warning hook.  */
+
+deprecated_warning_hook_class deprecated_warning_hook_obj(local_warning_hook);
+
 void (*deprecated_error_begin_hook) (void);
 
 /* Prototypes for local functions */
-- 
2.41.0


^ permalink raw reply	[flat|nested] 26+ messages in thread
* [PATCH] Fix AIX build break.
@ 2023-08-11  8:49 Aditya Kamath1
  2023-08-11  9:43 ` Ulrich Weigand
  0 siblings, 1 reply; 26+ messages in thread
From: Aditya Kamath1 @ 2023-08-11  8:49 UTC (permalink / raw)
  To: Ulrich Weigand, Aditya Kamath1 via Gdb-patches; +Cc: Sangamesh Mallayya


[-- Attachment #1.1: Type: text/plain, Size: 509 bytes --]

Respected Ulrich and GDB community members,

Hi,

In the recent commit {https://sourceware.org/git/?p=binutils-gdb.git;a=commitdiff;h=6d30ada87b7a515a0f623687e2faadc1d4acf440} the parameters of the scoped_restore_current_inferior_for_memory function was changed and in AIX we did not update the same.

This fixed the build and threads debugging works alright.

Kindly accept this patch and commit the same. Let me know if any changes needed.

Have a nice day ahead.

Thanks and regards,
Aditya.

[-- Attachment #2: 0001-Fix-AIX-build-break.patch --]
[-- Type: application/octet-stream, Size: 1585 bytes --]

From c662a9f01e6da808351d4e92a666eeba092e8026 Mon Sep 17 00:00:00 2001
From: Aditya Vidyadhar Kamath <Aditya.Kamath1@ibm.com>
Date: Fri, 11 Aug 2023 03:43:23 -0500
Subject: [PATCH] Fix AIX build break.

In a recent commit the signature of the scoped_restore_current_inferior_for_memory function was changed and in AIX we did not update the same.

This patch updates it in aix-thread.c file fixed the break and the thread debugging works alright as a result.
---
 gdb/aix-thread.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/gdb/aix-thread.c b/gdb/aix-thread.c
index 8c45116f355..1f7b3c511cf 100644
--- a/gdb/aix-thread.c
+++ b/gdb/aix-thread.c
@@ -615,8 +615,7 @@ pdc_read_data (pthdb_user_t user_current_pid, void *buf,
   /* This is needed to eliminate the dependency of current thread
      which is null so that thread reads the correct target memory.  */
   {
-    scoped_restore_current_inferior_for_memory save_inferior
-      (inf, ptid_t (user_current_pid));
+    scoped_restore_current_inferior_for_memory save_inferior (inf);
     status = target_read_memory (addr, (gdb_byte *) buf, len);
   }
   ret = status == 0 ? PDC_SUCCESS : PDC_FAILURE;
@@ -643,8 +642,7 @@ pdc_write_data (pthdb_user_t user_current_pid, void *buf,
 		user_current_pid, (long) buf, hex_string (addr), len);
 
   {
-    scoped_restore_current_inferior_for_memory save_inferior
-      (inf, ptid_t (user_current_pid));
+    scoped_restore_current_inferior_for_memory save_inferior (inf);
     status = target_write_memory (addr, (gdb_byte *) buf, len);
   }
 
-- 
2.38.3


^ permalink raw reply	[flat|nested] 26+ messages in thread

end of thread, other threads:[~2024-02-06 15:54 UTC | newest]

Thread overview: 26+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-01-12  9:20 [PATCH] Fix AIX build break Aditya Kamath1
2024-01-12  9:50 ` Tom de Vries
2024-01-12 15:56   ` Tom Tromey
2024-01-15  9:57     ` [RFC] " Aditya Kamath1
2024-01-16  9:42     ` [PATCH] " Aditya Kamath1
2024-01-17 15:09       ` Tom Tromey
  -- strict thread matches above, loose matches on Subject: below --
2024-01-17 18:28 Aditya Vidyadhar Kamath
2024-01-17 19:25 ` Tom Tromey
2024-01-19 11:58   ` Aditya Kamath1
2024-01-19 16:25     ` Tom Tromey
2024-01-20 15:03       ` Aditya Kamath1
2024-01-24  0:53         ` Aditya Kamath1
2024-01-25 14:45           ` Aditya Kamath1
2024-01-25 19:53             ` Tom Tromey
2024-01-26  8:37               ` Aditya Kamath1
2024-01-31  0:40                 ` Tom Tromey
2024-01-31  9:15                   ` Aditya Kamath1
2024-02-01  0:37                     ` Tom Tromey
2024-02-01  3:03                       ` Aditya Kamath1
2024-02-06 12:36                         ` Ciaran Woodward
2024-02-06 14:49                           ` Tom Tromey
2024-02-06 15:04                             ` Ciaran Woodward
2024-02-06 15:54                           ` Aditya Kamath1
2023-08-11  8:49 Aditya Kamath1
2023-08-11  9:43 ` Ulrich Weigand
2023-08-11  9:53   ` Aditya Kamath1

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).