This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[PATCH] Share code to determine whether target is running on uClinux.
- From: Yao Qi <yao at codesourcery dot com>
- To: <gdb-patches at sourceware dot org>
- Date: Mon, 2 Sep 2013 21:17:41 +0800
- Subject: [PATCH] Share code to determine whether target is running on uClinux.
- Authentication-results: sourceware.org; auth=none
Hi,
I happen to see that the code to determine whether target is running
on uClinux is duplicated, in both linux-tdep.c and m68klinux-tdep.c.
This patch is to move the code into a function linux_is_uclinux.
The function is named 'linux_is_uclinux' because I find all the
external functions in linux-tdep.c have a "linux_" prefix.
gdb:
2013-09-02 Yao Qi <yao@codesourcery.com>
* linux-tdep.c (linux_is_uclinux): New function. Code moved
from linux_has_shared_address_space.
(linux_has_shared_address_space): Call linux_is_uclinux.
* linux-tdep.h (linux_is_uclinux): Declare.
* m68klinux-tdep.c (m68k_linux_get_sigtramp_info): Call
linux_is_uclinux.
---
gdb/linux-tdep.c | 21 ++++++++++++---------
gdb/linux-tdep.h | 2 ++
gdb/m68klinux-tdep.c | 12 +++---------
3 files changed, 17 insertions(+), 18 deletions(-)
diff --git a/gdb/linux-tdep.c b/gdb/linux-tdep.c
index fbdca46..eb8ea2b 100644
--- a/gdb/linux-tdep.c
+++ b/gdb/linux-tdep.c
@@ -241,19 +241,22 @@ linux_get_siginfo_type (struct gdbarch *gdbarch)
return siginfo_type;
}
-static int
-linux_has_shared_address_space (struct gdbarch *gdbarch)
+/* Return true if the target is running on uClinux instead of normal
+ Linux kernel. */
+
+int
+linux_is_uclinux (void)
{
- /* Determine whether we are running on uClinux or normal Linux
- kernel. */
CORE_ADDR dummy;
- int target_is_uclinux;
- target_is_uclinux
- = (target_auxv_search (¤t_target, AT_NULL, &dummy) > 0
- && target_auxv_search (¤t_target, AT_PAGESZ, &dummy) == 0);
+ return (target_auxv_search (¤t_target, AT_NULL, &dummy) > 0
+ && target_auxv_search (¤t_target, AT_PAGESZ, &dummy) == 0);
+}
- return target_is_uclinux;
+static int
+linux_has_shared_address_space (struct gdbarch *gdbarch)
+{
+ return linux_is_uclinux ();
}
/* This is how we want PTIDs from core files to be printed. */
diff --git a/gdb/linux-tdep.h b/gdb/linux-tdep.h
index 5841f29..a61c20e 100644
--- a/gdb/linux-tdep.h
+++ b/gdb/linux-tdep.h
@@ -42,4 +42,6 @@ extern int linux_gdb_signal_to_target (struct gdbarch *gdbarch,
extern void linux_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch);
+extern int linux_is_uclinux (void);
+
#endif /* linux-tdep.h */
diff --git a/gdb/m68klinux-tdep.c b/gdb/m68klinux-tdep.c
index be90885..0382f68 100644
--- a/gdb/m68klinux-tdep.c
+++ b/gdb/m68klinux-tdep.c
@@ -228,16 +228,10 @@ m68k_linux_get_sigtramp_info (struct frame_info *this_frame)
CORE_ADDR sp;
struct m68k_linux_sigtramp_info info;
+ /* Determine whether we are running on a uClinux or normal GNU/Linux
+ target so we can use the correct sigcontext layouts. */
if (target_is_uclinux == -1)
- {
- /* Determine whether we are running on a uClinux or normal GNU/Linux
- target so we can use the correct sigcontext layouts. */
- CORE_ADDR dummy;
-
- target_is_uclinux
- = (target_auxv_search (¤t_target, AT_NULL, &dummy) > 0
- && target_auxv_search (¤t_target, AT_PAGESZ, &dummy) == 0);
- }
+ target_is_uclinux = linux_is_uclinux ();
sp = get_frame_register_unsigned (this_frame, M68K_SP_REGNUM);
--
1.7.7.6