* [patch] general updates and improvements to QNX NTO support
@ 2004-11-19 20:47 Kris Warkentin
2004-11-26 20:37 ` Ping: " Kris Warkentin
0 siblings, 1 reply; 12+ messages in thread
From: Kris Warkentin @ 2004-11-19 20:47 UTC (permalink / raw)
To: gdb-patches
[-- Attachment #1: Type: text/plain, Size: 2212 bytes --]
Sorry about the vagueness of the patch description. I've been working
on this off and on for a while but I've been lazy about submitting. By
and large, most of this is just about being able to switch targets to
future-proof against a multi-arch gdb.
Also I've created hooks for recognizing when we're dealing with a
Neutrino target. Unfortunately there is no nice way to recognize our
binaries so I have to fall back on cheating.
A few other things are there as well such as an 'in_dynsym_resolve_code'
for better solib support, a core sniffer and some assorted
re-arrangement of things.
I had started getting rid of some of the deprecated things (core_fns)
but was having trouble so I ripped that part of the patch out to work on
and submit later. Looks like I'm also going to have to get rid of
to_xfer_memory.
cheers,
Kris
ChangeLog entry:
2004-11-19 Kris Warkentin <kewarken@qnx.com>
* nto-tdep.h: Include osabi.h. Prototypes for generic Neutrino
osabi sniffer, signal handling initializer and
'in_dynsym_resolve_code' function.
(struct nto_target_ops): Put comments inline with struct. Add osabi
sniffer hook. Redefine macros to permit testing/assignment.
* nto-tdep.c (nto_find_and_open_solib): Allocate all buffers
dynamically to support arbitrary root paths. Check for basename of
lib in search path and then check for absolute.
(nto_in_dynsym_resolve_code): New function.
(nto_core_sniffer): New function.
(regset_core_fns): Register core sniffer.
(nto_initialize_signals): New function.
(_initialize_nto_tdep): Move signal initialization code to above to
avoid initialization race conditions.
* nto-procfs.c: Minor formatting/indenting changes.
(procfs_is_nto_target): New function.
(procfs_open): Set nto_is_nto_target.
(_initialize_procfs): Ditto. Remove notice_signals() call to avoid
initialization race conditions.
(procfs_create_inferior): Resume inferior after creation.
* i386-nto-tdep.c (init_i386nto_ops): Use new macros for assignment.
(i386nto_init_abi): Initialize signals. Set
TARGET_SO_IN_DYNSYM_RESOLVE_CODE.
(_initialize_i386nto_tdep): Register osabi sniffer.
[-- Attachment #2: new.diff --]
[-- Type: text/x-patch, Size: 17760 bytes --]
Index: i386-nto-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/i386-nto-tdep.c,v
retrieving revision 1.15
diff -u -r1.15 i386-nto-tdep.c
--- i386-nto-tdep.c 31 Oct 2004 19:52:46 -0000 1.15
+++ i386-nto-tdep.c 19 Nov 2004 20:07:18 -0000
@@ -258,15 +258,14 @@
static void
init_i386nto_ops (void)
{
- current_nto_target.nto_regset_id = i386nto_regset_id;
- current_nto_target.nto_supply_gregset = i386nto_supply_gregset;
- current_nto_target.nto_supply_fpregset = i386nto_supply_fpregset;
- current_nto_target.nto_supply_altregset = nto_dummy_supply_regset;
- current_nto_target.nto_supply_regset = i386nto_supply_regset;
- current_nto_target.nto_register_area = i386nto_register_area;
- current_nto_target.nto_regset_fill = i386nto_regset_fill;
- current_nto_target.nto_fetch_link_map_offsets =
- i386nto_svr4_fetch_link_map_offsets;
+ nto_regset_id = i386nto_regset_id;
+ nto_supply_gregset = i386nto_supply_gregset;
+ nto_supply_fpregset = i386nto_supply_fpregset;
+ nto_supply_altregset = nto_dummy_supply_regset;
+ nto_supply_regset = i386nto_supply_regset;
+ nto_register_area = i386nto_register_area;
+ nto_regset_fill = i386nto_regset_fill;
+ nto_fetch_link_map_offsets = i386nto_svr4_fetch_link_map_offsets;
}
static void
@@ -274,6 +273,9 @@
{
struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
+ /* Deal with our strange signals. */
+ nto_initialize_signals ();
+
/* NTO uses ELF. */
i386_elf_init_abi (info, gdbarch);
@@ -301,6 +303,9 @@
/* Supply a nice function to find our solibs. */
TARGET_SO_FIND_AND_OPEN_SOLIB = nto_find_and_open_solib;
+ /* Our linker code is in libc. */
+ TARGET_SO_IN_DYNSYM_RESOLVE_CODE = nto_in_dynsym_resolve_code;
+
init_i386nto_ops ();
}
@@ -309,4 +314,6 @@
{
gdbarch_register_osabi (bfd_arch_i386, 0, GDB_OSABI_QNXNTO,
i386nto_init_abi);
+ gdbarch_register_osabi_sniffer (bfd_arch_i386, bfd_target_elf_flavour,
+ nto_elf_osabi_sniffer);
}
Index: nto-procfs.c
===================================================================
RCS file: /cvs/src/src/gdb/nto-procfs.c,v
retrieving revision 1.6
diff -u -r1.6 nto-procfs.c
--- nto-procfs.c 8 Oct 2004 20:29:47 -0000 1.6
+++ nto-procfs.c 19 Nov 2004 20:07:18 -0000
@@ -97,20 +97,26 @@
is required is because QNX node descriptors are transient so
we have to re-acquire them every time. */
static unsigned
-nto_node(void)
+nto_node (void)
{
unsigned node;
- if (ND_NODE_CMP(nto_procfs_node, ND_LOCAL_NODE) == 0)
+ if (ND_NODE_CMP (nto_procfs_node, ND_LOCAL_NODE) == 0)
return ND_LOCAL_NODE;
- node = netmgr_strtond(nto_procfs_path,0);
+ node = netmgr_strtond (nto_procfs_path, 0);
if (node == -1)
- error ("Lost the QNX node. Debug session probably over.");
+ error ("Lost the QNX node. Debug session probably over.");
return (node);
}
+static enum gdb_osabi
+procfs_is_nto_target (bfd *abfd)
+{
+ return GDB_OSABI_QNXNTO;
+}
+
/* This is called when we call 'target procfs <arg>' from the (gdb) prompt.
For QNX6 (nto), the only valid arg will be a QNX node string,
eg: "/net/some_node". If arg is not a valid QNX node, we will
@@ -124,6 +130,8 @@
int fd, total_size;
procfs_sysinfo *sysinfo;
+ nto_is_nto_target = procfs_is_nto_target;
+
/* Set the default node used for spawning to this one,
and only override it if there is a valid arg. */
@@ -153,7 +161,8 @@
*endstr = 0;
}
}
- snprintf (nto_procfs_path, PATH_MAX - 1, "%s%s", nodestr ? nodestr : "", "/proc");
+ snprintf (nto_procfs_path, PATH_MAX - 1, "%s%s", nodestr ? nodestr : "",
+ "/proc");
if (nodestr)
xfree (nodestr);
@@ -271,7 +280,7 @@
if (dp == NULL)
{
fprintf_unfiltered (gdb_stderr, "failed to opendir \"%s\" - %d (%s)",
- nto_procfs_path, errno, safe_strerror (errno));
+ nto_procfs_path, errno, safe_strerror (errno));
return;
}
@@ -299,7 +308,7 @@
if (fd == -1)
{
fprintf_unfiltered (gdb_stderr, "failed to open %s - %d (%s)\n",
- buf, errno, safe_strerror (errno));
+ buf, errno, safe_strerror (errno));
closedir (dp);
return;
}
@@ -308,8 +317,8 @@
if (devctl (fd, DCMD_PROC_INFO, pidinfo, sizeof (buf), 0) != EOK)
{
fprintf_unfiltered (gdb_stderr,
- "devctl DCMD_PROC_INFO failed - %d (%s)\n", errno,
- safe_strerror (errno));
+ "devctl DCMD_PROC_INFO failed - %d (%s)\n",
+ errno, safe_strerror (errno));
break;
}
num_threads = pidinfo->num_threads;
@@ -375,7 +384,8 @@
err = devctl (ctl_fd, DCMD_PROC_MAPINFO, NULL, 0, &num);
if (err != EOK)
{
- printf ("failed devctl num mapinfos - %d (%s)\n", err, safe_strerror (err));
+ printf ("failed devctl num mapinfos - %d (%s)\n", err,
+ safe_strerror (err));
return;
}
@@ -565,7 +575,7 @@
if (devctl (ctl_fd, DCMD_PROC_STATUS, &status, sizeof (status), 0) == EOK
&& status.flags & _DEBUG_FLAG_STOPPED)
- SignalKill (nto_node(), PIDGET (ptid), 0, SIGCONT, 0, 0);
+ SignalKill (nto_node (), PIDGET (ptid), 0, SIGCONT, 0, 0);
attach_flag = 1;
nto_init_solib_absolute_prefix ();
return ptid;
@@ -778,7 +788,7 @@
siggnal = atoi (args);
if (siggnal)
- SignalKill (nto_node(), PIDGET (inferior_ptid), 0, siggnal, 0, 0);
+ SignalKill (nto_node (), PIDGET (inferior_ptid), 0, siggnal, 0, 0);
close (ctl_fd);
ctl_fd = -1;
@@ -868,8 +878,8 @@
{
if (signal_to_pass != status.info.si_signo)
{
- SignalKill (nto_node(), PIDGET (inferior_ptid), 0, signal_to_pass,
- 0, 0);
+ SignalKill (nto_node (), PIDGET (inferior_ptid), 0,
+ signal_to_pass, 0, 0);
run.flags |= _DEBUG_RUN_CLRFLT | _DEBUG_RUN_CLRSIG;
}
else /* Let it kill the program without telling us. */
@@ -892,7 +902,7 @@
{
if (!ptid_equal (inferior_ptid, null_ptid))
{
- SignalKill (nto_node(), PIDGET (inferior_ptid), 0, SIGKILL, 0, 0);
+ SignalKill (nto_node (), PIDGET (inferior_ptid), 0, SIGKILL, 0, 0);
close (ctl_fd);
}
inferior_ptid = null_ptid;
@@ -1042,7 +1052,7 @@
if (ND_NODE_CMP (nto_procfs_node, ND_LOCAL_NODE) != 0)
{
- inherit.nd = nto_node();
+ inherit.nd = nto_node ();
inherit.flags |= SPAWN_SETND;
inherit.flags &= ~SPAWN_EXEC;
}
@@ -1055,7 +1065,8 @@
sigprocmask (SIG_BLOCK, &set, NULL);
if (pid == -1)
- error ("Error spawning %s: %d (%s)", argv[0], errno, safe_strerror (errno));
+ error ("Error spawning %s: %d (%s)", argv[0], errno,
+ safe_strerror (errno));
if (fds[0] != STDIN_FILENO)
close (fds[0]);
@@ -1083,6 +1094,8 @@
|| (symfile_objfile != NULL && symfile_objfile->obfd != NULL))
SOLIB_CREATE_INFERIOR_HOOK (pid);
#endif
+ stop_soon = 0;
+ proceed (-1, TARGET_SIGNAL_DEFAULT, 0);
}
static void
@@ -1324,7 +1337,6 @@
/* Set up trace and fault sets, as gdb expects them. */
sigemptyset (&run.trace);
- notice_signals ();
/* Stuff some information. */
nto_cpuinfo_flags = SYSPAGE_ENTRY (cpuinfo)->flags;
@@ -1332,6 +1344,8 @@
add_info ("pidlist", procfs_pidlist, "pidlist");
add_info ("meminfo", procfs_meminfo, "memory information");
+
+ nto_is_nto_target = procfs_is_nto_target;
}
Index: nto-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/nto-tdep.c,v
retrieving revision 1.9
diff -u -r1.9 nto-tdep.c
--- nto-tdep.c 30 Jul 2004 19:17:19 -0000 1.9
+++ nto-tdep.c 19 Nov 2004 20:07:18 -0000
@@ -86,10 +86,10 @@
int
nto_find_and_open_solib (char *solib, unsigned o_flags, char **temp_pathname)
{
- char *buf, arch_path[PATH_MAX], *nto_root, *endian;
+ char *buf, *arch_path, *nto_root, *endian, *base;
const char *arch;
- char *path_fmt = "%s/lib:%s/usr/lib:%s/usr/photon/lib\
-:%s/usr/photon/dll:%s/lib/dll";
+ int ret;
+#define PATH_FMT "%s/lib:%s/usr/lib:%s/usr/photon/lib:%s/usr/photon/dll:%s/lib/dll"
nto_root = nto_target ();
if (strcmp (TARGET_ARCHITECTURE->arch_name, "i386") == 0)
@@ -109,13 +109,38 @@
endian = TARGET_BYTE_ORDER == BFD_ENDIAN_BIG ? "be" : "le";
}
+ /* In case nto_root is short, add strlen(solib)
+ so we can reuse arch_path below. */
+ arch_path =
+ alloca (strlen (nto_root) + strlen (arch) + strlen (endian) + 2 +
+ strlen (solib));
sprintf (arch_path, "%s/%s%s", nto_root, arch, endian);
- buf = alloca (strlen (path_fmt) + strlen (arch_path) * 5 + 1);
- sprintf (buf, path_fmt, arch_path, arch_path, arch_path, arch_path,
+ buf = alloca (strlen (PATH_FMT) + strlen (arch_path) * 5 + 1);
+ sprintf (buf, PATH_FMT, arch_path, arch_path, arch_path, arch_path,
arch_path);
- return openp (buf, OPF_TRY_CWD_FIRST, solib, o_flags, 0, temp_pathname);
+ /* Don't assume basename() isn't destructive. */
+ base = strrchr (solib, '/');
+ if (!base)
+ base = solib;
+ else
+ base++; /* Skip over '/'. */
+
+ ret = openp (buf, 1, base, o_flags, 0, temp_pathname);
+ if (ret < 0 && base != solib)
+ {
+ sprintf (arch_path, "/%s", solib);
+ ret = open (arch_path, o_flags, 0);
+ if (temp_pathname)
+ {
+ if (ret >= 0)
+ *temp_pathname = gdb_realpath (arch_path);
+ else
+ **temp_pathname = '\0';
+ }
+ }
+ return ret;
}
void
@@ -266,6 +291,53 @@
sec->endaddr = nto_truncate_ptr (sec->endaddr + LM_ADDR (so) - vaddr);
}
+/* This is cheating a bit because our linker code is in libc.so. If we
+ ever implement lazy linking, this may need to be re-examined. */
+int
+nto_in_dynsym_resolve_code (CORE_ADDR pc)
+{
+ if (in_plt_section (pc, NULL))
+ return 1;
+ return 0;
+}
+
+void
+nto_generic_supply_gpregset (const struct regset *regset,
+ struct regcache *regcache, int regnum,
+ const void *gregs, size_t len)
+{
+}
+
+void
+nto_generic_supply_fpregset (const struct regset *regset,
+ struct regcache *regcache, int regnum,
+ const void *fpregs, size_t len)
+{
+}
+
+void
+nto_generic_supply_altregset (const struct regset *regset,
+ struct regcache *regcache, int regnum,
+ const void *altregs, size_t len)
+{
+}
+
+void
+nto_dummy_supply_regset (char *regs)
+{
+ /* Do nothing. */
+}
+
+enum gdb_osabi
+nto_elf_osabi_sniffer (bfd *abfd)
+{
+ if (nto_is_nto_target)
+ {
+ return nto_is_nto_target (abfd);
+ }
+ return GDB_OSABI_UNKNOWN;
+}
+
static void
fetch_core_registers (char *core_reg_sect, unsigned core_reg_size,
int which, CORE_ADDR reg_addr)
@@ -287,12 +359,6 @@
}
}
-void
-nto_dummy_supply_regset (char *regs)
-{
- /* Do nothing. */
-}
-
/* Register that we are able to handle ELF file formats using standard
procfs "regset" structures. */
static struct core_fns regset_core_fns = {
@@ -304,18 +370,8 @@
};
void
-_initialize_nto_tdep (void)
+nto_initialize_signals (void)
{
- add_setshow_zinteger_cmd ("nto-debug", class_maintenance,
- &nto_internal_debugging, "\
-Set QNX NTO internal debugging.", "\
-Show QNX NTO internal debugging.", "\
-When non-zero, nto specific debug info is\n\
-displayed. Different information is displayed\n\
-for different positive values.", "\
-QNX NTO internal debugging is %s.",
- NULL, NULL, &setdebuglist, &showdebuglist);
-
/* We use SIG45 for pulses, or something, so nostop, noprint
and pass them. */
signal_stop_update (target_signal_from_name ("SIG45"), 0);
@@ -334,7 +390,19 @@
signal_print_update (SIGPHOTON, 0);
signal_pass_update (SIGPHOTON, 1);
#endif
+}
+void
+_initialize_nto_tdep (void)
+{
+ add_setshow_zinteger_cmd ("nto-debug", class_maintenance,
+ &nto_internal_debugging, "\
+Set QNX NTO internal debugging.", "\
+Show QNX NTO internal debugging.", "\
+When non-zero, nto specific debug info is\n\
+displayed. Different information is displayed\n\
+for different positive values.", "\
+QNX NTO internal debugging is %s.", NULL, NULL, &setdebuglist, &showdebuglist);
/* Register core file support. */
deprecated_add_core_fns (®set_core_fns);
}
Index: nto-tdep.h
===================================================================
RCS file: /cvs/src/src/gdb/nto-tdep.h,v
retrieving revision 1.2
diff -u -r1.2 nto-tdep.h
--- nto-tdep.h 6 May 2003 16:47:47 -0000 1.2
+++ nto-tdep.h 19 Nov 2004 20:07:18 -0000
@@ -26,6 +26,8 @@
#include "defs.h"
#include "solist.h"
+#include "osabi.h"
+#include "regset.h"
/* Generic functions in nto-tdep.c. */
@@ -36,39 +38,38 @@
int proc_iterate_over_mappings (int (*func) (int, CORE_ADDR));
-void nto_relocate_section_addresses (struct so_list *, struct section_table *);
+void nto_relocate_section_addresses (struct so_list *,
+ struct section_table *);
int nto_map_arch_to_cputype (const char *);
int nto_find_and_open_solib (char *, unsigned, char **);
+enum gdb_osabi nto_elf_osabi_sniffer (bfd *abfd);
+
+void nto_initialize_signals (void);
+
+void nto_generic_supply_gpregset (const struct regset *, struct regcache *,
+ int, const void *, size_t);
+
+void nto_generic_supply_fpregset (const struct regset *, struct regcache *,
+ int, const void *, size_t);
+
+void nto_generic_supply_altregset (const struct regset *, struct regcache *,
+ int, const void *, size_t);
+
/* Dummy function for initializing nto_target_ops on targets which do
not define a particular regset. */
void nto_dummy_supply_regset (char *regs);
+int nto_in_dynsym_resolve_code (CORE_ADDR pc);
+
/* Target operations defined for Neutrino targets (<target>-nto-tdep.c). */
struct nto_target_ops
{
- int nto_internal_debugging;
- unsigned nto_cpuinfo_flags;
- int nto_cpuinfo_valid;
-
- int (*nto_regset_id) (int);
- void (*nto_supply_gregset) (char *);
- void (*nto_supply_fpregset) (char *);
- void (*nto_supply_altregset) (char *);
- void (*nto_supply_regset) (int, char *);
- int (*nto_register_area) (int, int, unsigned *);
- int (*nto_regset_fill) (int, char *);
- struct link_map_offsets *(*nto_fetch_link_map_offsets) (void);
-};
-
-extern struct nto_target_ops current_nto_target;
-
/* For 'maintenance debug nto-debug' command. */
-#define nto_internal_debugging \
- (current_nto_target.nto_internal_debugging)
+ int nto_internal_debugging;
/* The CPUINFO flags from the remote. Currently used by
i386 for fxsave but future proofing other hosts.
@@ -76,47 +77,69 @@
depending on our host/target. It would only be invalid
if we were talking to an older pdebug which didn't support
the cpuinfo message. */
-#define nto_cpuinfo_flags \
- (current_nto_target.nto_cpuinfo_flags)
+ unsigned nto_cpuinfo_flags;
/* True if successfully retrieved cpuinfo from remote. */
-#define nto_cpuinfo_valid \
- (current_nto_target.nto_cpuinfo_valid)
+ int nto_cpuinfo_valid;
/* Given a register, return an id that represents the Neutrino
regset it came from. If reg == -1 update all regsets. */
-#define nto_regset_id(reg) \
- (*current_nto_target.nto_regset_id) (reg)
+ int (*nto_regset_id) (int);
-#define nto_supply_gregset(regs) \
- (*current_nto_target.nto_supply_gregset) (regs)
+ void (*nto_supply_gregset) (char *);
-#define nto_supply_fpregset(regs) \
- (*current_nto_target.nto_supply_fpregset) (regs)
+ void (*nto_supply_fpregset) (char *);
-#define nto_supply_altregset(regs) \
- (*current_nto_target.nto_supply_altregset) (regs)
+ void (*nto_supply_altregset) (char *);
/* Given a regset, tell gdb about registers stored in data. */
-#define nto_supply_regset(regset, data) \
- (*current_nto_target.nto_supply_regset) (regset, data)
+ void (*nto_supply_regset) (int, char *);
/* Given a register and regset, calculate the offset into the regset
and stuff it into the last argument. If regno is -1, calculate the
size of the entire regset. Returns length of data, -1 if unknown
regset, 0 if unknown register. */
-#define nto_register_area(reg, regset, off) \
- (*current_nto_target.nto_register_area) (reg, regset, off)
+ int (*nto_register_area) (int, int, unsigned *);
/* Build the Neutrino register set info into the data buffer.
Return -1 if unknown regset, 0 otherwise. */
-#define nto_regset_fill(regset, data) \
- (*current_nto_target.nto_regset_fill) (regset, data)
+ int (*nto_regset_fill) (int, char *);
/* Gives the fetch_link_map_offsets function exposure outside of
solib-svr4.c so that we can override relocate_section_addresses(). */
-#define nto_fetch_link_map_offsets() \
- (*current_nto_target.nto_fetch_link_map_offsets) ()
+ struct link_map_offsets *(*nto_fetch_link_map_offsets) (void);
+
+/* Used by nto_elf_osabi_sniffer to determine if we're connected to an
+ Neutrino target. */
+ enum gdb_osabi (*nto_is_nto_target) (bfd *abfd);
+};
+
+extern struct nto_target_ops current_nto_target;
+
+#define nto_internal_debugging (current_nto_target.nto_internal_debugging)
+
+#define nto_cpuinfo_flags (current_nto_target.nto_cpuinfo_flags)
+
+#define nto_cpuinfo_valid (current_nto_target.nto_cpuinfo_valid)
+
+#define nto_regset_id (current_nto_target.nto_regset_id)
+
+#define nto_supply_gregset (current_nto_target.nto_supply_gregset)
+
+#define nto_supply_fpregset (current_nto_target.nto_supply_fpregset)
+
+#define nto_supply_altregset (current_nto_target.nto_supply_altregset)
+
+#define nto_supply_regset (current_nto_target.nto_supply_regset)
+
+#define nto_register_area (current_nto_target.nto_register_area)
+
+#define nto_regset_fill (current_nto_target.nto_regset_fill)
+
+#define nto_fetch_link_map_offsets \
+(current_nto_target.nto_fetch_link_map_offsets)
+
+#define nto_is_nto_target (current_nto_target.nto_is_nto_target)
/* Keep this consistant with neutrino syspage.h. */
enum
^ permalink raw reply [flat|nested] 12+ messages in thread
* Ping: [patch] general updates and improvements to QNX NTO support
2004-11-19 20:47 [patch] general updates and improvements to QNX NTO support Kris Warkentin
@ 2004-11-26 20:37 ` Kris Warkentin
2004-12-03 16:09 ` Kris Warkentin
0 siblings, 1 reply; 12+ messages in thread
From: Kris Warkentin @ 2004-11-26 20:37 UTC (permalink / raw)
To: gdb-patches
Pinging sources.redhat.com [12.107.209.250] with 21229 bytes of data:
Kris Warkentin wrote:
> Sorry about the vagueness of the patch description. I've been working
> on this off and on for a while but I've been lazy about submitting.
> By and large, most of this is just about being able to switch targets
> to future-proof against a multi-arch gdb.
>
> Also I've created hooks for recognizing when we're dealing with a
> Neutrino target. Unfortunately there is no nice way to recognize our
> binaries so I have to fall back on cheating.
>
> A few other things are there as well such as an
> 'in_dynsym_resolve_code' for better solib support, a core sniffer and
> some assorted re-arrangement of things.
>
> I had started getting rid of some of the deprecated things (core_fns)
> but was having trouble so I ripped that part of the patch out to work
> on and submit later. Looks like I'm also going to have to get rid of
> to_xfer_memory.
>
> cheers,
>
> Kris
>
> ChangeLog entry:
> 2004-11-19 Kris Warkentin <kewarken@qnx.com>
>
> * nto-tdep.h: Include osabi.h. Prototypes for generic Neutrino
> osabi sniffer, signal handling initializer and
> 'in_dynsym_resolve_code' function.
> (struct nto_target_ops): Put comments inline with struct. Add osabi
> sniffer hook. Redefine macros to permit testing/assignment.
> * nto-tdep.c (nto_find_and_open_solib): Allocate all buffers
> dynamically to support arbitrary root paths. Check for basename of
> lib in search path and then check for absolute.
> (nto_in_dynsym_resolve_code): New function.
> (nto_core_sniffer): New function.
> (regset_core_fns): Register core sniffer.
> (nto_initialize_signals): New function.
> (_initialize_nto_tdep): Move signal initialization code to above to
> avoid initialization race conditions.
> * nto-procfs.c: Minor formatting/indenting changes.
> (procfs_is_nto_target): New function.
> (procfs_open): Set nto_is_nto_target.
> (_initialize_procfs): Ditto. Remove notice_signals() call to avoid
> initialization race conditions.
> (procfs_create_inferior): Resume inferior after creation.
> * i386-nto-tdep.c (init_i386nto_ops): Use new macros for assignment.
> (i386nto_init_abi): Initialize signals. Set
> TARGET_SO_IN_DYNSYM_RESOLVE_CODE.
> (_initialize_i386nto_tdep): Register osabi sniffer.
>
>------------------------------------------------------------------------
>
>Index: i386-nto-tdep.c
>===================================================================
>RCS file: /cvs/src/src/gdb/i386-nto-tdep.c,v
>retrieving revision 1.15
>diff -u -r1.15 i386-nto-tdep.c
>--- i386-nto-tdep.c 31 Oct 2004 19:52:46 -0000 1.15
>+++ i386-nto-tdep.c 19 Nov 2004 20:07:18 -0000
>@@ -258,15 +258,14 @@
> static void
> init_i386nto_ops (void)
> {
>- current_nto_target.nto_regset_id = i386nto_regset_id;
>- current_nto_target.nto_supply_gregset = i386nto_supply_gregset;
>- current_nto_target.nto_supply_fpregset = i386nto_supply_fpregset;
>- current_nto_target.nto_supply_altregset = nto_dummy_supply_regset;
>- current_nto_target.nto_supply_regset = i386nto_supply_regset;
>- current_nto_target.nto_register_area = i386nto_register_area;
>- current_nto_target.nto_regset_fill = i386nto_regset_fill;
>- current_nto_target.nto_fetch_link_map_offsets =
>- i386nto_svr4_fetch_link_map_offsets;
>+ nto_regset_id = i386nto_regset_id;
>+ nto_supply_gregset = i386nto_supply_gregset;
>+ nto_supply_fpregset = i386nto_supply_fpregset;
>+ nto_supply_altregset = nto_dummy_supply_regset;
>+ nto_supply_regset = i386nto_supply_regset;
>+ nto_register_area = i386nto_register_area;
>+ nto_regset_fill = i386nto_regset_fill;
>+ nto_fetch_link_map_offsets = i386nto_svr4_fetch_link_map_offsets;
> }
>
> static void
>@@ -274,6 +273,9 @@
> {
> struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
>
>+ /* Deal with our strange signals. */
>+ nto_initialize_signals ();
>+
> /* NTO uses ELF. */
> i386_elf_init_abi (info, gdbarch);
>
>@@ -301,6 +303,9 @@
> /* Supply a nice function to find our solibs. */
> TARGET_SO_FIND_AND_OPEN_SOLIB = nto_find_and_open_solib;
>
>+ /* Our linker code is in libc. */
>+ TARGET_SO_IN_DYNSYM_RESOLVE_CODE = nto_in_dynsym_resolve_code;
>+
> init_i386nto_ops ();
> }
>
>@@ -309,4 +314,6 @@
> {
> gdbarch_register_osabi (bfd_arch_i386, 0, GDB_OSABI_QNXNTO,
> i386nto_init_abi);
>+ gdbarch_register_osabi_sniffer (bfd_arch_i386, bfd_target_elf_flavour,
>+ nto_elf_osabi_sniffer);
> }
>Index: nto-procfs.c
>===================================================================
>RCS file: /cvs/src/src/gdb/nto-procfs.c,v
>retrieving revision 1.6
>diff -u -r1.6 nto-procfs.c
>--- nto-procfs.c 8 Oct 2004 20:29:47 -0000 1.6
>+++ nto-procfs.c 19 Nov 2004 20:07:18 -0000
>@@ -97,20 +97,26 @@
> is required is because QNX node descriptors are transient so
> we have to re-acquire them every time. */
> static unsigned
>-nto_node(void)
>+nto_node (void)
> {
> unsigned node;
>
>- if (ND_NODE_CMP(nto_procfs_node, ND_LOCAL_NODE) == 0)
>+ if (ND_NODE_CMP (nto_procfs_node, ND_LOCAL_NODE) == 0)
> return ND_LOCAL_NODE;
>
>- node = netmgr_strtond(nto_procfs_path,0);
>+ node = netmgr_strtond (nto_procfs_path, 0);
> if (node == -1)
>- error ("Lost the QNX node. Debug session probably over.");
>+ error ("Lost the QNX node. Debug session probably over.");
>
> return (node);
> }
>
>+static enum gdb_osabi
>+procfs_is_nto_target (bfd *abfd)
>+{
>+ return GDB_OSABI_QNXNTO;
>+}
>+
> /* This is called when we call 'target procfs <arg>' from the (gdb) prompt.
> For QNX6 (nto), the only valid arg will be a QNX node string,
> eg: "/net/some_node". If arg is not a valid QNX node, we will
>@@ -124,6 +130,8 @@
> int fd, total_size;
> procfs_sysinfo *sysinfo;
>
>+ nto_is_nto_target = procfs_is_nto_target;
>+
> /* Set the default node used for spawning to this one,
> and only override it if there is a valid arg. */
>
>@@ -153,7 +161,8 @@
> *endstr = 0;
> }
> }
>- snprintf (nto_procfs_path, PATH_MAX - 1, "%s%s", nodestr ? nodestr : "", "/proc");
>+ snprintf (nto_procfs_path, PATH_MAX - 1, "%s%s", nodestr ? nodestr : "",
>+ "/proc");
> if (nodestr)
> xfree (nodestr);
>
>@@ -271,7 +280,7 @@
> if (dp == NULL)
> {
> fprintf_unfiltered (gdb_stderr, "failed to opendir \"%s\" - %d (%s)",
>- nto_procfs_path, errno, safe_strerror (errno));
>+ nto_procfs_path, errno, safe_strerror (errno));
> return;
> }
>
>@@ -299,7 +308,7 @@
> if (fd == -1)
> {
> fprintf_unfiltered (gdb_stderr, "failed to open %s - %d (%s)\n",
>- buf, errno, safe_strerror (errno));
>+ buf, errno, safe_strerror (errno));
> closedir (dp);
> return;
> }
>@@ -308,8 +317,8 @@
> if (devctl (fd, DCMD_PROC_INFO, pidinfo, sizeof (buf), 0) != EOK)
> {
> fprintf_unfiltered (gdb_stderr,
>- "devctl DCMD_PROC_INFO failed - %d (%s)\n", errno,
>- safe_strerror (errno));
>+ "devctl DCMD_PROC_INFO failed - %d (%s)\n",
>+ errno, safe_strerror (errno));
> break;
> }
> num_threads = pidinfo->num_threads;
>@@ -375,7 +384,8 @@
> err = devctl (ctl_fd, DCMD_PROC_MAPINFO, NULL, 0, &num);
> if (err != EOK)
> {
>- printf ("failed devctl num mapinfos - %d (%s)\n", err, safe_strerror (err));
>+ printf ("failed devctl num mapinfos - %d (%s)\n", err,
>+ safe_strerror (err));
> return;
> }
>
>@@ -565,7 +575,7 @@
>
> if (devctl (ctl_fd, DCMD_PROC_STATUS, &status, sizeof (status), 0) == EOK
> && status.flags & _DEBUG_FLAG_STOPPED)
>- SignalKill (nto_node(), PIDGET (ptid), 0, SIGCONT, 0, 0);
>+ SignalKill (nto_node (), PIDGET (ptid), 0, SIGCONT, 0, 0);
> attach_flag = 1;
> nto_init_solib_absolute_prefix ();
> return ptid;
>@@ -778,7 +788,7 @@
> siggnal = atoi (args);
>
> if (siggnal)
>- SignalKill (nto_node(), PIDGET (inferior_ptid), 0, siggnal, 0, 0);
>+ SignalKill (nto_node (), PIDGET (inferior_ptid), 0, siggnal, 0, 0);
>
> close (ctl_fd);
> ctl_fd = -1;
>@@ -868,8 +878,8 @@
> {
> if (signal_to_pass != status.info.si_signo)
> {
>- SignalKill (nto_node(), PIDGET (inferior_ptid), 0, signal_to_pass,
>- 0, 0);
>+ SignalKill (nto_node (), PIDGET (inferior_ptid), 0,
>+ signal_to_pass, 0, 0);
> run.flags |= _DEBUG_RUN_CLRFLT | _DEBUG_RUN_CLRSIG;
> }
> else /* Let it kill the program without telling us. */
>@@ -892,7 +902,7 @@
> {
> if (!ptid_equal (inferior_ptid, null_ptid))
> {
>- SignalKill (nto_node(), PIDGET (inferior_ptid), 0, SIGKILL, 0, 0);
>+ SignalKill (nto_node (), PIDGET (inferior_ptid), 0, SIGKILL, 0, 0);
> close (ctl_fd);
> }
> inferior_ptid = null_ptid;
>@@ -1042,7 +1052,7 @@
>
> if (ND_NODE_CMP (nto_procfs_node, ND_LOCAL_NODE) != 0)
> {
>- inherit.nd = nto_node();
>+ inherit.nd = nto_node ();
> inherit.flags |= SPAWN_SETND;
> inherit.flags &= ~SPAWN_EXEC;
> }
>@@ -1055,7 +1065,8 @@
> sigprocmask (SIG_BLOCK, &set, NULL);
>
> if (pid == -1)
>- error ("Error spawning %s: %d (%s)", argv[0], errno, safe_strerror (errno));
>+ error ("Error spawning %s: %d (%s)", argv[0], errno,
>+ safe_strerror (errno));
>
> if (fds[0] != STDIN_FILENO)
> close (fds[0]);
>@@ -1083,6 +1094,8 @@
> || (symfile_objfile != NULL && symfile_objfile->obfd != NULL))
> SOLIB_CREATE_INFERIOR_HOOK (pid);
> #endif
>+ stop_soon = 0;
>+ proceed (-1, TARGET_SIGNAL_DEFAULT, 0);
> }
>
> static void
>@@ -1324,7 +1337,6 @@
>
> /* Set up trace and fault sets, as gdb expects them. */
> sigemptyset (&run.trace);
>- notice_signals ();
>
> /* Stuff some information. */
> nto_cpuinfo_flags = SYSPAGE_ENTRY (cpuinfo)->flags;
>@@ -1332,6 +1344,8 @@
>
> add_info ("pidlist", procfs_pidlist, "pidlist");
> add_info ("meminfo", procfs_meminfo, "memory information");
>+
>+ nto_is_nto_target = procfs_is_nto_target;
> }
>
>
>Index: nto-tdep.c
>===================================================================
>RCS file: /cvs/src/src/gdb/nto-tdep.c,v
>retrieving revision 1.9
>diff -u -r1.9 nto-tdep.c
>--- nto-tdep.c 30 Jul 2004 19:17:19 -0000 1.9
>+++ nto-tdep.c 19 Nov 2004 20:07:18 -0000
>@@ -86,10 +86,10 @@
> int
> nto_find_and_open_solib (char *solib, unsigned o_flags, char **temp_pathname)
> {
>- char *buf, arch_path[PATH_MAX], *nto_root, *endian;
>+ char *buf, *arch_path, *nto_root, *endian, *base;
> const char *arch;
>- char *path_fmt = "%s/lib:%s/usr/lib:%s/usr/photon/lib\
>-:%s/usr/photon/dll:%s/lib/dll";
>+ int ret;
>+#define PATH_FMT "%s/lib:%s/usr/lib:%s/usr/photon/lib:%s/usr/photon/dll:%s/lib/dll"
>
> nto_root = nto_target ();
> if (strcmp (TARGET_ARCHITECTURE->arch_name, "i386") == 0)
>@@ -109,13 +109,38 @@
> endian = TARGET_BYTE_ORDER == BFD_ENDIAN_BIG ? "be" : "le";
> }
>
>+ /* In case nto_root is short, add strlen(solib)
>+ so we can reuse arch_path below. */
>+ arch_path =
>+ alloca (strlen (nto_root) + strlen (arch) + strlen (endian) + 2 +
>+ strlen (solib));
> sprintf (arch_path, "%s/%s%s", nto_root, arch, endian);
>
>- buf = alloca (strlen (path_fmt) + strlen (arch_path) * 5 + 1);
>- sprintf (buf, path_fmt, arch_path, arch_path, arch_path, arch_path,
>+ buf = alloca (strlen (PATH_FMT) + strlen (arch_path) * 5 + 1);
>+ sprintf (buf, PATH_FMT, arch_path, arch_path, arch_path, arch_path,
> arch_path);
>
>- return openp (buf, OPF_TRY_CWD_FIRST, solib, o_flags, 0, temp_pathname);
>+ /* Don't assume basename() isn't destructive. */
>+ base = strrchr (solib, '/');
>+ if (!base)
>+ base = solib;
>+ else
>+ base++; /* Skip over '/'. */
>+
>+ ret = openp (buf, 1, base, o_flags, 0, temp_pathname);
>+ if (ret < 0 && base != solib)
>+ {
>+ sprintf (arch_path, "/%s", solib);
>+ ret = open (arch_path, o_flags, 0);
>+ if (temp_pathname)
>+ {
>+ if (ret >= 0)
>+ *temp_pathname = gdb_realpath (arch_path);
>+ else
>+ **temp_pathname = '\0';
>+ }
>+ }
>+ return ret;
> }
>
> void
>@@ -266,6 +291,53 @@
> sec->endaddr = nto_truncate_ptr (sec->endaddr + LM_ADDR (so) - vaddr);
> }
>
>+/* This is cheating a bit because our linker code is in libc.so. If we
>+ ever implement lazy linking, this may need to be re-examined. */
>+int
>+nto_in_dynsym_resolve_code (CORE_ADDR pc)
>+{
>+ if (in_plt_section (pc, NULL))
>+ return 1;
>+ return 0;
>+}
>+
>+void
>+nto_generic_supply_gpregset (const struct regset *regset,
>+ struct regcache *regcache, int regnum,
>+ const void *gregs, size_t len)
>+{
>+}
>+
>+void
>+nto_generic_supply_fpregset (const struct regset *regset,
>+ struct regcache *regcache, int regnum,
>+ const void *fpregs, size_t len)
>+{
>+}
>+
>+void
>+nto_generic_supply_altregset (const struct regset *regset,
>+ struct regcache *regcache, int regnum,
>+ const void *altregs, size_t len)
>+{
>+}
>+
>+void
>+nto_dummy_supply_regset (char *regs)
>+{
>+ /* Do nothing. */
>+}
>+
>+enum gdb_osabi
>+nto_elf_osabi_sniffer (bfd *abfd)
>+{
>+ if (nto_is_nto_target)
>+ {
>+ return nto_is_nto_target (abfd);
>+ }
>+ return GDB_OSABI_UNKNOWN;
>+}
>+
> static void
> fetch_core_registers (char *core_reg_sect, unsigned core_reg_size,
> int which, CORE_ADDR reg_addr)
>@@ -287,12 +359,6 @@
> }
> }
>
>-void
>-nto_dummy_supply_regset (char *regs)
>-{
>- /* Do nothing. */
>-}
>-
> /* Register that we are able to handle ELF file formats using standard
> procfs "regset" structures. */
> static struct core_fns regset_core_fns = {
>@@ -304,18 +370,8 @@
> };
>
> void
>-_initialize_nto_tdep (void)
>+nto_initialize_signals (void)
> {
>- add_setshow_zinteger_cmd ("nto-debug", class_maintenance,
>- &nto_internal_debugging, "\
>-Set QNX NTO internal debugging.", "\
>-Show QNX NTO internal debugging.", "\
>-When non-zero, nto specific debug info is\n\
>-displayed. Different information is displayed\n\
>-for different positive values.", "\
>-QNX NTO internal debugging is %s.",
>- NULL, NULL, &setdebuglist, &showdebuglist);
>-
> /* We use SIG45 for pulses, or something, so nostop, noprint
> and pass them. */
> signal_stop_update (target_signal_from_name ("SIG45"), 0);
>@@ -334,7 +390,19 @@
> signal_print_update (SIGPHOTON, 0);
> signal_pass_update (SIGPHOTON, 1);
> #endif
>+}
>
>+void
>+_initialize_nto_tdep (void)
>+{
>+ add_setshow_zinteger_cmd ("nto-debug", class_maintenance,
>+ &nto_internal_debugging, "\
>+Set QNX NTO internal debugging.", "\
>+Show QNX NTO internal debugging.", "\
>+When non-zero, nto specific debug info is\n\
>+displayed. Different information is displayed\n\
>+for different positive values.", "\
>+QNX NTO internal debugging is %s.", NULL, NULL, &setdebuglist, &showdebuglist);
> /* Register core file support. */
> deprecated_add_core_fns (®set_core_fns);
> }
>Index: nto-tdep.h
>===================================================================
>RCS file: /cvs/src/src/gdb/nto-tdep.h,v
>retrieving revision 1.2
>diff -u -r1.2 nto-tdep.h
>--- nto-tdep.h 6 May 2003 16:47:47 -0000 1.2
>+++ nto-tdep.h 19 Nov 2004 20:07:18 -0000
>@@ -26,6 +26,8 @@
>
> #include "defs.h"
> #include "solist.h"
>+#include "osabi.h"
>+#include "regset.h"
>
> /* Generic functions in nto-tdep.c. */
>
>@@ -36,39 +38,38 @@
>
> int proc_iterate_over_mappings (int (*func) (int, CORE_ADDR));
>
>-void nto_relocate_section_addresses (struct so_list *, struct section_table *);
>+void nto_relocate_section_addresses (struct so_list *,
>+ struct section_table *);
>
> int nto_map_arch_to_cputype (const char *);
>
> int nto_find_and_open_solib (char *, unsigned, char **);
>
>+enum gdb_osabi nto_elf_osabi_sniffer (bfd *abfd);
>+
>+void nto_initialize_signals (void);
>+
>+void nto_generic_supply_gpregset (const struct regset *, struct regcache *,
>+ int, const void *, size_t);
>+
>+void nto_generic_supply_fpregset (const struct regset *, struct regcache *,
>+ int, const void *, size_t);
>+
>+void nto_generic_supply_altregset (const struct regset *, struct regcache *,
>+ int, const void *, size_t);
>+
> /* Dummy function for initializing nto_target_ops on targets which do
> not define a particular regset. */
> void nto_dummy_supply_regset (char *regs);
>
>+int nto_in_dynsym_resolve_code (CORE_ADDR pc);
>+
> /* Target operations defined for Neutrino targets (<target>-nto-tdep.c). */
>
> struct nto_target_ops
> {
>- int nto_internal_debugging;
>- unsigned nto_cpuinfo_flags;
>- int nto_cpuinfo_valid;
>-
>- int (*nto_regset_id) (int);
>- void (*nto_supply_gregset) (char *);
>- void (*nto_supply_fpregset) (char *);
>- void (*nto_supply_altregset) (char *);
>- void (*nto_supply_regset) (int, char *);
>- int (*nto_register_area) (int, int, unsigned *);
>- int (*nto_regset_fill) (int, char *);
>- struct link_map_offsets *(*nto_fetch_link_map_offsets) (void);
>-};
>-
>-extern struct nto_target_ops current_nto_target;
>-
> /* For 'maintenance debug nto-debug' command. */
>-#define nto_internal_debugging \
>- (current_nto_target.nto_internal_debugging)
>+ int nto_internal_debugging;
>
> /* The CPUINFO flags from the remote. Currently used by
> i386 for fxsave but future proofing other hosts.
>@@ -76,47 +77,69 @@
> depending on our host/target. It would only be invalid
> if we were talking to an older pdebug which didn't support
> the cpuinfo message. */
>-#define nto_cpuinfo_flags \
>- (current_nto_target.nto_cpuinfo_flags)
>+ unsigned nto_cpuinfo_flags;
>
> /* True if successfully retrieved cpuinfo from remote. */
>-#define nto_cpuinfo_valid \
>- (current_nto_target.nto_cpuinfo_valid)
>+ int nto_cpuinfo_valid;
>
> /* Given a register, return an id that represents the Neutrino
> regset it came from. If reg == -1 update all regsets. */
>-#define nto_regset_id(reg) \
>- (*current_nto_target.nto_regset_id) (reg)
>+ int (*nto_regset_id) (int);
>
>-#define nto_supply_gregset(regs) \
>- (*current_nto_target.nto_supply_gregset) (regs)
>+ void (*nto_supply_gregset) (char *);
>
>-#define nto_supply_fpregset(regs) \
>- (*current_nto_target.nto_supply_fpregset) (regs)
>+ void (*nto_supply_fpregset) (char *);
>
>-#define nto_supply_altregset(regs) \
>- (*current_nto_target.nto_supply_altregset) (regs)
>+ void (*nto_supply_altregset) (char *);
>
> /* Given a regset, tell gdb about registers stored in data. */
>-#define nto_supply_regset(regset, data) \
>- (*current_nto_target.nto_supply_regset) (regset, data)
>+ void (*nto_supply_regset) (int, char *);
>
> /* Given a register and regset, calculate the offset into the regset
> and stuff it into the last argument. If regno is -1, calculate the
> size of the entire regset. Returns length of data, -1 if unknown
> regset, 0 if unknown register. */
>-#define nto_register_area(reg, regset, off) \
>- (*current_nto_target.nto_register_area) (reg, regset, off)
>+ int (*nto_register_area) (int, int, unsigned *);
>
> /* Build the Neutrino register set info into the data buffer.
> Return -1 if unknown regset, 0 otherwise. */
>-#define nto_regset_fill(regset, data) \
>- (*current_nto_target.nto_regset_fill) (regset, data)
>+ int (*nto_regset_fill) (int, char *);
>
> /* Gives the fetch_link_map_offsets function exposure outside of
> solib-svr4.c so that we can override relocate_section_addresses(). */
>-#define nto_fetch_link_map_offsets() \
>- (*current_nto_target.nto_fetch_link_map_offsets) ()
>+ struct link_map_offsets *(*nto_fetch_link_map_offsets) (void);
>+
>+/* Used by nto_elf_osabi_sniffer to determine if we're connected to an
>+ Neutrino target. */
>+ enum gdb_osabi (*nto_is_nto_target) (bfd *abfd);
>+};
>+
>+extern struct nto_target_ops current_nto_target;
>+
>+#define nto_internal_debugging (current_nto_target.nto_internal_debugging)
>+
>+#define nto_cpuinfo_flags (current_nto_target.nto_cpuinfo_flags)
>+
>+#define nto_cpuinfo_valid (current_nto_target.nto_cpuinfo_valid)
>+
>+#define nto_regset_id (current_nto_target.nto_regset_id)
>+
>+#define nto_supply_gregset (current_nto_target.nto_supply_gregset)
>+
>+#define nto_supply_fpregset (current_nto_target.nto_supply_fpregset)
>+
>+#define nto_supply_altregset (current_nto_target.nto_supply_altregset)
>+
>+#define nto_supply_regset (current_nto_target.nto_supply_regset)
>+
>+#define nto_register_area (current_nto_target.nto_register_area)
>+
>+#define nto_regset_fill (current_nto_target.nto_regset_fill)
>+
>+#define nto_fetch_link_map_offsets \
>+(current_nto_target.nto_fetch_link_map_offsets)
>+
>+#define nto_is_nto_target (current_nto_target.nto_is_nto_target)
>
> /* Keep this consistant with neutrino syspage.h. */
> enum
>
>
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: Ping: [patch] general updates and improvements to QNX NTO support
2004-11-26 20:37 ` Ping: " Kris Warkentin
@ 2004-12-03 16:09 ` Kris Warkentin
2004-12-03 16:17 ` Mark Kettenis
0 siblings, 1 reply; 12+ messages in thread
From: Kris Warkentin @ 2004-12-03 16:09 UTC (permalink / raw)
To: Kris Warkentin; +Cc: gdb-patches
Weekly ping. It's really not that bad....I ran gdb_indent.sh on
it....it's only affecting QNX specific stuff....I tested it on Windows,
Linux and Neutrino...
Can I check it in? Pretty please? I promise I won't spam the mailing
list any more. ;-)
cheers,
Kris
Kris Warkentin wrote:
> Pinging sources.redhat.com [12.107.209.250] with 21229 bytes of data:
>
> Kris Warkentin wrote:
>
>> Sorry about the vagueness of the patch description. I've been
>> working on this off and on for a while but I've been lazy about
>> submitting. By and large, most of this is just about being able to
>> switch targets to future-proof against a multi-arch gdb.
>>
>> Also I've created hooks for recognizing when we're dealing with a
>> Neutrino target. Unfortunately there is no nice way to recognize our
>> binaries so I have to fall back on cheating.
>>
>> A few other things are there as well such as an
>> 'in_dynsym_resolve_code' for better solib support, a core sniffer and
>> some assorted re-arrangement of things.
>>
>> I had started getting rid of some of the deprecated things (core_fns)
>> but was having trouble so I ripped that part of the patch out to work
>> on and submit later. Looks like I'm also going to have to get rid of
>> to_xfer_memory.
>>
>> cheers,
>>
>> Kris
>>
>> ChangeLog entry:
>> 2004-11-19 Kris Warkentin <kewarken@qnx.com>
>>
>> * nto-tdep.h: Include osabi.h. Prototypes for generic Neutrino
>> osabi sniffer, signal handling initializer and
>> 'in_dynsym_resolve_code' function.
>> (struct nto_target_ops): Put comments inline with struct. Add osabi
>> sniffer hook. Redefine macros to permit testing/assignment.
>> * nto-tdep.c (nto_find_and_open_solib): Allocate all buffers
>> dynamically to support arbitrary root paths. Check for basename of
>> lib in search path and then check for absolute.
>> (nto_in_dynsym_resolve_code): New function.
>> (nto_core_sniffer): New function.
>> (regset_core_fns): Register core sniffer.
>> (nto_initialize_signals): New function.
>> (_initialize_nto_tdep): Move signal initialization code to above to
>> avoid initialization race conditions.
>> * nto-procfs.c: Minor formatting/indenting changes.
>> (procfs_is_nto_target): New function.
>> (procfs_open): Set nto_is_nto_target.
>> (_initialize_procfs): Ditto. Remove notice_signals() call to avoid
>> initialization race conditions.
>> (procfs_create_inferior): Resume inferior after creation.
>> * i386-nto-tdep.c (init_i386nto_ops): Use new macros for assignment.
>> (i386nto_init_abi): Initialize signals. Set
>> TARGET_SO_IN_DYNSYM_RESOLVE_CODE.
>> (_initialize_i386nto_tdep): Register osabi sniffer.
>>
>> ------------------------------------------------------------------------
>>
>> Index: i386-nto-tdep.c
>> ===================================================================
>> RCS file: /cvs/src/src/gdb/i386-nto-tdep.c,v
>> retrieving revision 1.15
>> diff -u -r1.15 i386-nto-tdep.c
>> --- i386-nto-tdep.c 31 Oct 2004 19:52:46 -0000 1.15
>> +++ i386-nto-tdep.c 19 Nov 2004 20:07:18 -0000
>> @@ -258,15 +258,14 @@
>> static void
>> init_i386nto_ops (void)
>> {
>> - current_nto_target.nto_regset_id = i386nto_regset_id;
>> - current_nto_target.nto_supply_gregset = i386nto_supply_gregset;
>> - current_nto_target.nto_supply_fpregset = i386nto_supply_fpregset;
>> - current_nto_target.nto_supply_altregset = nto_dummy_supply_regset;
>> - current_nto_target.nto_supply_regset = i386nto_supply_regset;
>> - current_nto_target.nto_register_area = i386nto_register_area;
>> - current_nto_target.nto_regset_fill = i386nto_regset_fill;
>> - current_nto_target.nto_fetch_link_map_offsets =
>> - i386nto_svr4_fetch_link_map_offsets;
>> + nto_regset_id = i386nto_regset_id;
>> + nto_supply_gregset = i386nto_supply_gregset;
>> + nto_supply_fpregset = i386nto_supply_fpregset;
>> + nto_supply_altregset = nto_dummy_supply_regset;
>> + nto_supply_regset = i386nto_supply_regset;
>> + nto_register_area = i386nto_register_area;
>> + nto_regset_fill = i386nto_regset_fill;
>> + nto_fetch_link_map_offsets = i386nto_svr4_fetch_link_map_offsets;
>> }
>>
>> static void
>> @@ -274,6 +273,9 @@
>> {
>> struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
>>
>> + /* Deal with our strange signals. */
>> + nto_initialize_signals ();
>> +
>> /* NTO uses ELF. */
>> i386_elf_init_abi (info, gdbarch);
>>
>> @@ -301,6 +303,9 @@
>> /* Supply a nice function to find our solibs. */
>> TARGET_SO_FIND_AND_OPEN_SOLIB = nto_find_and_open_solib;
>>
>> + /* Our linker code is in libc. */
>> + TARGET_SO_IN_DYNSYM_RESOLVE_CODE = nto_in_dynsym_resolve_code;
>> +
>> init_i386nto_ops ();
>> }
>>
>> @@ -309,4 +314,6 @@
>> {
>> gdbarch_register_osabi (bfd_arch_i386, 0, GDB_OSABI_QNXNTO,
>> i386nto_init_abi);
>> + gdbarch_register_osabi_sniffer (bfd_arch_i386,
>> bfd_target_elf_flavour,
>> + nto_elf_osabi_sniffer);
>> }
>> Index: nto-procfs.c
>> ===================================================================
>> RCS file: /cvs/src/src/gdb/nto-procfs.c,v
>> retrieving revision 1.6
>> diff -u -r1.6 nto-procfs.c
>> --- nto-procfs.c 8 Oct 2004 20:29:47 -0000 1.6
>> +++ nto-procfs.c 19 Nov 2004 20:07:18 -0000
>> @@ -97,20 +97,26 @@
>> is required is because QNX node descriptors are transient so
>> we have to re-acquire them every time. */
>> static unsigned
>> -nto_node(void)
>> +nto_node (void)
>> {
>> unsigned node;
>>
>> - if (ND_NODE_CMP(nto_procfs_node, ND_LOCAL_NODE) == 0)
>> + if (ND_NODE_CMP (nto_procfs_node, ND_LOCAL_NODE) == 0)
>> return ND_LOCAL_NODE;
>>
>> - node = netmgr_strtond(nto_procfs_path,0);
>> + node = netmgr_strtond (nto_procfs_path, 0);
>> if (node == -1)
>> - error ("Lost the QNX node. Debug session probably over.");
>> + error ("Lost the QNX node. Debug session probably over.");
>>
>> return (node);
>> }
>>
>> +static enum gdb_osabi
>> +procfs_is_nto_target (bfd *abfd)
>> +{
>> + return GDB_OSABI_QNXNTO;
>> +}
>> +
>> /* This is called when we call 'target procfs <arg>' from the (gdb)
>> prompt.
>> For QNX6 (nto), the only valid arg will be a QNX node string,
>> eg: "/net/some_node". If arg is not a valid QNX node, we will
>> @@ -124,6 +130,8 @@
>> int fd, total_size;
>> procfs_sysinfo *sysinfo;
>>
>> + nto_is_nto_target = procfs_is_nto_target;
>> +
>> /* Set the default node used for spawning to this one,
>> and only override it if there is a valid arg. */
>>
>> @@ -153,7 +161,8 @@
>> *endstr = 0;
>> }
>> }
>> - snprintf (nto_procfs_path, PATH_MAX - 1, "%s%s", nodestr ? nodestr
>> : "", "/proc");
>> + snprintf (nto_procfs_path, PATH_MAX - 1, "%s%s", nodestr ? nodestr
>> : "",
>> + "/proc");
>> if (nodestr)
>> xfree (nodestr);
>>
>> @@ -271,7 +280,7 @@
>> if (dp == NULL)
>> {
>> fprintf_unfiltered (gdb_stderr, "failed to opendir \"%s\" - %d
>> (%s)",
>> - nto_procfs_path, errno, safe_strerror (errno));
>> + nto_procfs_path, errno, safe_strerror (errno));
>> return;
>> }
>>
>> @@ -299,7 +308,7 @@
>> if (fd == -1)
>> {
>> fprintf_unfiltered (gdb_stderr, "failed to open %s - %d (%s)\n",
>> - buf, errno, safe_strerror (errno));
>> + buf, errno, safe_strerror (errno));
>> closedir (dp);
>> return;
>> }
>> @@ -308,8 +317,8 @@
>> if (devctl (fd, DCMD_PROC_INFO, pidinfo, sizeof (buf), 0) != EOK)
>> {
>> fprintf_unfiltered (gdb_stderr,
>> - "devctl DCMD_PROC_INFO failed - %d (%s)\n", errno,
>> - safe_strerror (errno));
>> + "devctl DCMD_PROC_INFO failed - %d (%s)\n",
>> + errno, safe_strerror (errno));
>> break;
>> }
>> num_threads = pidinfo->num_threads;
>> @@ -375,7 +384,8 @@
>> err = devctl (ctl_fd, DCMD_PROC_MAPINFO, NULL, 0, &num);
>> if (err != EOK)
>> {
>> - printf ("failed devctl num mapinfos - %d (%s)\n", err,
>> safe_strerror (err));
>> + printf ("failed devctl num mapinfos - %d (%s)\n", err,
>> + safe_strerror (err));
>> return;
>> }
>>
>> @@ -565,7 +575,7 @@
>>
>> if (devctl (ctl_fd, DCMD_PROC_STATUS, &status, sizeof (status), 0)
>> == EOK
>> && status.flags & _DEBUG_FLAG_STOPPED)
>> - SignalKill (nto_node(), PIDGET (ptid), 0, SIGCONT, 0, 0);
>> + SignalKill (nto_node (), PIDGET (ptid), 0, SIGCONT, 0, 0);
>> attach_flag = 1;
>> nto_init_solib_absolute_prefix ();
>> return ptid;
>> @@ -778,7 +788,7 @@
>> siggnal = atoi (args);
>>
>> if (siggnal)
>> - SignalKill (nto_node(), PIDGET (inferior_ptid), 0, siggnal, 0, 0);
>> + SignalKill (nto_node (), PIDGET (inferior_ptid), 0, siggnal, 0, 0);
>>
>> close (ctl_fd);
>> ctl_fd = -1;
>> @@ -868,8 +878,8 @@
>> {
>> if (signal_to_pass != status.info.si_signo)
>> {
>> - SignalKill (nto_node(), PIDGET (inferior_ptid), 0,
>> signal_to_pass,
>> - 0, 0);
>> + SignalKill (nto_node (), PIDGET (inferior_ptid), 0,
>> + signal_to_pass, 0, 0);
>> run.flags |= _DEBUG_RUN_CLRFLT | _DEBUG_RUN_CLRSIG;
>> }
>> else /* Let it kill the program without telling us. */
>> @@ -892,7 +902,7 @@
>> {
>> if (!ptid_equal (inferior_ptid, null_ptid))
>> {
>> - SignalKill (nto_node(), PIDGET (inferior_ptid), 0, SIGKILL, 0,
>> 0);
>> + SignalKill (nto_node (), PIDGET (inferior_ptid), 0, SIGKILL,
>> 0, 0);
>> close (ctl_fd);
>> }
>> inferior_ptid = null_ptid;
>> @@ -1042,7 +1052,7 @@
>>
>> if (ND_NODE_CMP (nto_procfs_node, ND_LOCAL_NODE) != 0)
>> {
>> - inherit.nd = nto_node();
>> + inherit.nd = nto_node ();
>> inherit.flags |= SPAWN_SETND;
>> inherit.flags &= ~SPAWN_EXEC;
>> }
>> @@ -1055,7 +1065,8 @@
>> sigprocmask (SIG_BLOCK, &set, NULL);
>>
>> if (pid == -1)
>> - error ("Error spawning %s: %d (%s)", argv[0], errno,
>> safe_strerror (errno));
>> + error ("Error spawning %s: %d (%s)", argv[0], errno,
>> + safe_strerror (errno));
>>
>> if (fds[0] != STDIN_FILENO)
>> close (fds[0]);
>> @@ -1083,6 +1094,8 @@
>> || (symfile_objfile != NULL && symfile_objfile->obfd != NULL))
>> SOLIB_CREATE_INFERIOR_HOOK (pid);
>> #endif
>> + stop_soon = 0;
>> + proceed (-1, TARGET_SIGNAL_DEFAULT, 0);
>> }
>>
>> static void
>> @@ -1324,7 +1337,6 @@
>>
>> /* Set up trace and fault sets, as gdb expects them. */
>> sigemptyset (&run.trace);
>> - notice_signals ();
>>
>> /* Stuff some information. */
>> nto_cpuinfo_flags = SYSPAGE_ENTRY (cpuinfo)->flags;
>> @@ -1332,6 +1344,8 @@
>>
>> add_info ("pidlist", procfs_pidlist, "pidlist");
>> add_info ("meminfo", procfs_meminfo, "memory information");
>> +
>> + nto_is_nto_target = procfs_is_nto_target;
>> }
>>
>>
>> Index: nto-tdep.c
>> ===================================================================
>> RCS file: /cvs/src/src/gdb/nto-tdep.c,v
>> retrieving revision 1.9
>> diff -u -r1.9 nto-tdep.c
>> --- nto-tdep.c 30 Jul 2004 19:17:19 -0000 1.9
>> +++ nto-tdep.c 19 Nov 2004 20:07:18 -0000
>> @@ -86,10 +86,10 @@
>> int
>> nto_find_and_open_solib (char *solib, unsigned o_flags, char
>> **temp_pathname)
>> {
>> - char *buf, arch_path[PATH_MAX], *nto_root, *endian;
>> + char *buf, *arch_path, *nto_root, *endian, *base;
>> const char *arch;
>> - char *path_fmt = "%s/lib:%s/usr/lib:%s/usr/photon/lib\
>> -:%s/usr/photon/dll:%s/lib/dll";
>> + int ret;
>> +#define PATH_FMT
>> "%s/lib:%s/usr/lib:%s/usr/photon/lib:%s/usr/photon/dll:%s/lib/dll"
>>
>> nto_root = nto_target ();
>> if (strcmp (TARGET_ARCHITECTURE->arch_name, "i386") == 0)
>> @@ -109,13 +109,38 @@
>> endian = TARGET_BYTE_ORDER == BFD_ENDIAN_BIG ? "be" : "le";
>> }
>>
>> + /* In case nto_root is short, add strlen(solib)
>> + so we can reuse arch_path below. */
>> + arch_path =
>> + alloca (strlen (nto_root) + strlen (arch) + strlen (endian) + 2 +
>> + strlen (solib));
>> sprintf (arch_path, "%s/%s%s", nto_root, arch, endian);
>>
>> - buf = alloca (strlen (path_fmt) + strlen (arch_path) * 5 + 1);
>> - sprintf (buf, path_fmt, arch_path, arch_path, arch_path, arch_path,
>> + buf = alloca (strlen (PATH_FMT) + strlen (arch_path) * 5 + 1);
>> + sprintf (buf, PATH_FMT, arch_path, arch_path, arch_path, arch_path,
>> arch_path);
>>
>> - return openp (buf, OPF_TRY_CWD_FIRST, solib, o_flags, 0,
>> temp_pathname);
>> + /* Don't assume basename() isn't destructive. */
>> + base = strrchr (solib, '/');
>> + if (!base)
>> + base = solib;
>> + else
>> + base++; /* Skip over '/'. */
>> +
>> + ret = openp (buf, 1, base, o_flags, 0, temp_pathname);
>> + if (ret < 0 && base != solib)
>> + {
>> + sprintf (arch_path, "/%s", solib);
>> + ret = open (arch_path, o_flags, 0);
>> + if (temp_pathname)
>> + {
>> + if (ret >= 0)
>> + *temp_pathname = gdb_realpath (arch_path);
>> + else
>> + **temp_pathname = '\0';
>> + }
>> + }
>> + return ret;
>> }
>>
>> void
>> @@ -266,6 +291,53 @@
>> sec->endaddr = nto_truncate_ptr (sec->endaddr + LM_ADDR (so) - vaddr);
>> }
>>
>> +/* This is cheating a bit because our linker code is in libc.so. If we
>> + ever implement lazy linking, this may need to be re-examined. */
>> +int
>> +nto_in_dynsym_resolve_code (CORE_ADDR pc)
>> +{
>> + if (in_plt_section (pc, NULL))
>> + return 1;
>> + return 0;
>> +}
>> +
>> +void
>> +nto_generic_supply_gpregset (const struct regset *regset,
>> + struct regcache *regcache, int regnum,
>> + const void *gregs, size_t len)
>> +{
>> +}
>> +
>> +void
>> +nto_generic_supply_fpregset (const struct regset *regset,
>> + struct regcache *regcache, int regnum,
>> + const void *fpregs, size_t len)
>> +{
>> +}
>> +
>> +void
>> +nto_generic_supply_altregset (const struct regset *regset,
>> + struct regcache *regcache, int regnum,
>> + const void *altregs, size_t len)
>> +{
>> +}
>> +
>> +void
>> +nto_dummy_supply_regset (char *regs)
>> +{
>> + /* Do nothing. */
>> +}
>> +
>> +enum gdb_osabi
>> +nto_elf_osabi_sniffer (bfd *abfd)
>> +{
>> + if (nto_is_nto_target)
>> + {
>> + return nto_is_nto_target (abfd);
>> + }
>> + return GDB_OSABI_UNKNOWN;
>> +}
>> +
>> static void
>> fetch_core_registers (char *core_reg_sect, unsigned core_reg_size,
>> int which, CORE_ADDR reg_addr)
>> @@ -287,12 +359,6 @@
>> }
>> }
>>
>> -void
>> -nto_dummy_supply_regset (char *regs)
>> -{
>> - /* Do nothing. */
>> -}
>> -
>> /* Register that we are able to handle ELF file formats using standard
>> procfs "regset" structures. */
>> static struct core_fns regset_core_fns = {
>> @@ -304,18 +370,8 @@
>> };
>>
>> void
>> -_initialize_nto_tdep (void)
>> +nto_initialize_signals (void)
>> {
>> - add_setshow_zinteger_cmd ("nto-debug", class_maintenance,
>> - &nto_internal_debugging, "\
>> -Set QNX NTO internal debugging.", "\
>> -Show QNX NTO internal debugging.", "\
>> -When non-zero, nto specific debug info is\n\
>> -displayed. Different information is displayed\n\
>> -for different positive values.", "\
>> -QNX NTO internal debugging is %s.",
>> - NULL, NULL, &setdebuglist, &showdebuglist);
>> -
>> /* We use SIG45 for pulses, or something, so nostop, noprint
>> and pass them. */
>> signal_stop_update (target_signal_from_name ("SIG45"), 0);
>> @@ -334,7 +390,19 @@
>> signal_print_update (SIGPHOTON, 0);
>> signal_pass_update (SIGPHOTON, 1);
>> #endif
>> +}
>>
>> +void
>> +_initialize_nto_tdep (void)
>> +{
>> + add_setshow_zinteger_cmd ("nto-debug", class_maintenance,
>> + &nto_internal_debugging, "\
>> +Set QNX NTO internal debugging.", "\
>> +Show QNX NTO internal debugging.", "\
>> +When non-zero, nto specific debug info is\n\
>> +displayed. Different information is displayed\n\
>> +for different positive values.", "\
>> +QNX NTO internal debugging is %s.", NULL, NULL, &setdebuglist,
>> &showdebuglist);
>> /* Register core file support. */
>> deprecated_add_core_fns (®set_core_fns);
>> }
>> Index: nto-tdep.h
>> ===================================================================
>> RCS file: /cvs/src/src/gdb/nto-tdep.h,v
>> retrieving revision 1.2
>> diff -u -r1.2 nto-tdep.h
>> --- nto-tdep.h 6 May 2003 16:47:47 -0000 1.2
>> +++ nto-tdep.h 19 Nov 2004 20:07:18 -0000
>> @@ -26,6 +26,8 @@
>>
>> #include "defs.h"
>> #include "solist.h"
>> +#include "osabi.h"
>> +#include "regset.h"
>>
>> /* Generic functions in nto-tdep.c. */
>>
>> @@ -36,39 +38,38 @@
>>
>> int proc_iterate_over_mappings (int (*func) (int, CORE_ADDR));
>>
>> -void nto_relocate_section_addresses (struct so_list *, struct
>> section_table *);
>> +void nto_relocate_section_addresses (struct so_list *,
>> + struct section_table *);
>>
>> int nto_map_arch_to_cputype (const char *);
>>
>> int nto_find_and_open_solib (char *, unsigned, char **);
>>
>> +enum gdb_osabi nto_elf_osabi_sniffer (bfd *abfd);
>> +
>> +void nto_initialize_signals (void);
>> +
>> +void nto_generic_supply_gpregset (const struct regset *, struct
>> regcache *,
>> + int, const void *, size_t);
>> +
>> +void nto_generic_supply_fpregset (const struct regset *, struct
>> regcache *,
>> + int, const void *, size_t);
>> +
>> +void nto_generic_supply_altregset (const struct regset *, struct
>> regcache *,
>> + int, const void *, size_t);
>> +
>> /* Dummy function for initializing nto_target_ops on targets which do
>> not define a particular regset. */
>> void nto_dummy_supply_regset (char *regs);
>>
>> +int nto_in_dynsym_resolve_code (CORE_ADDR pc);
>> +
>> /* Target operations defined for Neutrino targets
>> (<target>-nto-tdep.c). */
>>
>> struct nto_target_ops
>> {
>> - int nto_internal_debugging;
>> - unsigned nto_cpuinfo_flags;
>> - int nto_cpuinfo_valid;
>> -
>> - int (*nto_regset_id) (int);
>> - void (*nto_supply_gregset) (char *);
>> - void (*nto_supply_fpregset) (char *);
>> - void (*nto_supply_altregset) (char *);
>> - void (*nto_supply_regset) (int, char *);
>> - int (*nto_register_area) (int, int, unsigned *);
>> - int (*nto_regset_fill) (int, char *);
>> - struct link_map_offsets *(*nto_fetch_link_map_offsets) (void);
>> -};
>> -
>> -extern struct nto_target_ops current_nto_target;
>> -
>> /* For 'maintenance debug nto-debug' command. */
>> -#define nto_internal_debugging \
>> - (current_nto_target.nto_internal_debugging)
>> + int nto_internal_debugging;
>>
>> /* The CPUINFO flags from the remote. Currently used by
>> i386 for fxsave but future proofing other hosts.
>> @@ -76,47 +77,69 @@
>> depending on our host/target. It would only be invalid
>> if we were talking to an older pdebug which didn't support
>> the cpuinfo message. */
>> -#define nto_cpuinfo_flags \
>> - (current_nto_target.nto_cpuinfo_flags)
>> + unsigned nto_cpuinfo_flags;
>>
>> /* True if successfully retrieved cpuinfo from remote. */
>> -#define nto_cpuinfo_valid \
>> - (current_nto_target.nto_cpuinfo_valid)
>> + int nto_cpuinfo_valid;
>>
>> /* Given a register, return an id that represents the Neutrino
>> regset it came from. If reg == -1 update all regsets. */
>> -#define nto_regset_id(reg) \
>> - (*current_nto_target.nto_regset_id) (reg)
>> + int (*nto_regset_id) (int);
>>
>> -#define nto_supply_gregset(regs) \
>> - (*current_nto_target.nto_supply_gregset) (regs)
>> + void (*nto_supply_gregset) (char *);
>>
>> -#define nto_supply_fpregset(regs) \
>> - (*current_nto_target.nto_supply_fpregset) (regs)
>> + void (*nto_supply_fpregset) (char *);
>>
>> -#define nto_supply_altregset(regs) \
>> - (*current_nto_target.nto_supply_altregset) (regs)
>> + void (*nto_supply_altregset) (char *);
>>
>> /* Given a regset, tell gdb about registers stored in data. */
>> -#define nto_supply_regset(regset, data) \
>> - (*current_nto_target.nto_supply_regset) (regset, data)
>> + void (*nto_supply_regset) (int, char *);
>>
>> /* Given a register and regset, calculate the offset into the regset
>> and stuff it into the last argument. If regno is -1, calculate the
>> size of the entire regset. Returns length of data, -1 if unknown
>> regset, 0 if unknown register. */
>> -#define nto_register_area(reg, regset, off) \
>> - (*current_nto_target.nto_register_area) (reg, regset, off)
>> + int (*nto_register_area) (int, int, unsigned *);
>>
>> /* Build the Neutrino register set info into the data buffer.
>> Return -1 if unknown regset, 0 otherwise. */
>> -#define nto_regset_fill(regset, data) \
>> - (*current_nto_target.nto_regset_fill) (regset, data)
>> + int (*nto_regset_fill) (int, char *);
>>
>> /* Gives the fetch_link_map_offsets function exposure outside of
>> solib-svr4.c so that we can override
>> relocate_section_addresses(). */
>> -#define nto_fetch_link_map_offsets() \
>> - (*current_nto_target.nto_fetch_link_map_offsets) ()
>> + struct link_map_offsets *(*nto_fetch_link_map_offsets) (void);
>> +
>> +/* Used by nto_elf_osabi_sniffer to determine if we're connected to an
>> + Neutrino target. */
>> + enum gdb_osabi (*nto_is_nto_target) (bfd *abfd);
>> +};
>> +
>> +extern struct nto_target_ops current_nto_target;
>> +
>> +#define nto_internal_debugging
>> (current_nto_target.nto_internal_debugging)
>> +
>> +#define nto_cpuinfo_flags (current_nto_target.nto_cpuinfo_flags)
>> +
>> +#define nto_cpuinfo_valid (current_nto_target.nto_cpuinfo_valid)
>> +
>> +#define nto_regset_id (current_nto_target.nto_regset_id)
>> +
>> +#define nto_supply_gregset (current_nto_target.nto_supply_gregset)
>> +
>> +#define nto_supply_fpregset (current_nto_target.nto_supply_fpregset)
>> +
>> +#define nto_supply_altregset (current_nto_target.nto_supply_altregset)
>> +
>> +#define nto_supply_regset (current_nto_target.nto_supply_regset)
>> +
>> +#define nto_register_area (current_nto_target.nto_register_area)
>> +
>> +#define nto_regset_fill (current_nto_target.nto_regset_fill)
>> +
>> +#define nto_fetch_link_map_offsets \
>> +(current_nto_target.nto_fetch_link_map_offsets)
>> +
>> +#define nto_is_nto_target (current_nto_target.nto_is_nto_target)
>>
>> /* Keep this consistant with neutrino syspage.h. */
>> enum
>>
>>
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: Ping: [patch] general updates and improvements to QNX NTO support
2004-12-03 16:09 ` Kris Warkentin
@ 2004-12-03 16:17 ` Mark Kettenis
2004-12-03 17:01 ` Kris Warkentin
0 siblings, 1 reply; 12+ messages in thread
From: Mark Kettenis @ 2004-12-03 16:17 UTC (permalink / raw)
To: kewarken; +Cc: kewarken, gdb-patches
Date: Fri, 03 Dec 2004 11:12:14 -0500
From: Kris Warkentin <kewarken@qnx.com>
Weekly ping. It's really not that bad....I ran gdb_indent.sh on
it....it's only affecting QNX specific stuff....I tested it on Windows,
Linux and Neutrino...
It is bad. It defines variables in a header file. That's
unacceptable. What's your motivation for getting rid of `struct
nto_target_ops' in the first place? Seems like a step in the wrong
direction to me.
Please fix this, then resubmit. I promise to look at it in a timely
fashion if you do.
Mark
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: Ping: [patch] general updates and improvements to QNX NTO support
2004-12-03 16:17 ` Mark Kettenis
@ 2004-12-03 17:01 ` Kris Warkentin
2004-12-03 17:23 ` Kris Warkentin
2004-12-03 17:44 ` Mark Kettenis
0 siblings, 2 replies; 12+ messages in thread
From: Kris Warkentin @ 2004-12-03 17:01 UTC (permalink / raw)
To: Mark Kettenis; +Cc: gdb-patches
Hmm....I think the diff hard to read. I haven't gotten rid of struct
nto_target_ops in nto-tdep.h. All I did is move the comments into the
definition of the structure from outside with the defines.
I also changed the macro defines so that I can assign and test. ie.
old:
define nto_regset_fill(regset, data)
(*current_nto_target.nto_regset_fill) (regset, data)
new:
#define nto_regset_fill (current_nto_target.nto_regset_fill)
That way I can easily switch targets in code.
I am defining current_nto_target in nto-tdep.h as being extern but I
don't declare it there. Is having a global verboten? I has assumed it
was okay since we have many precedents like inferior_ptid and
current_target and such.
cheers,
Kris
Mark Kettenis wrote:
> Date: Fri, 03 Dec 2004 11:12:14 -0500
> From: Kris Warkentin <kewarken@qnx.com>
>
> Weekly ping. It's really not that bad....I ran gdb_indent.sh on
> it....it's only affecting QNX specific stuff....I tested it on Windows,
> Linux and Neutrino...
>
>It is bad. It defines variables in a header file. That's
>unacceptable. What's your motivation for getting rid of `struct
>nto_target_ops' in the first place? Seems like a step in the wrong
>direction to me.
>
>Please fix this, then resubmit. I promise to look at it in a timely
>fashion if you do.
>
>Mark
>
>
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: Ping: [patch] general updates and improvements to QNX NTO support
2004-12-03 17:01 ` Kris Warkentin
@ 2004-12-03 17:23 ` Kris Warkentin
2004-12-03 17:44 ` Mark Kettenis
1 sibling, 0 replies; 12+ messages in thread
From: Kris Warkentin @ 2004-12-03 17:23 UTC (permalink / raw)
To: Mark Kettenis; +Cc: gdb-patches
Kris Warkentin wrote:
> I am defining current_nto_target in nto-tdep.h as being extern but I
> don't declare it there. Is having a global verboten? I has assumed
> it was okay since we have many precedents like inferior_ptid and
> current_target and such.
Oops...I mean I declare it in nto-tdep.h. It's defined elsewhere.
Always get those two mixed up.
cheers,
Kris
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: Ping: [patch] general updates and improvements to QNX NTO support
2004-12-03 17:01 ` Kris Warkentin
2004-12-03 17:23 ` Kris Warkentin
@ 2004-12-03 17:44 ` Mark Kettenis
2004-12-06 16:53 ` Revised: " Kris Warkentin
1 sibling, 1 reply; 12+ messages in thread
From: Mark Kettenis @ 2004-12-03 17:44 UTC (permalink / raw)
To: kewarken; +Cc: gdb-patches
Date: Fri, 03 Dec 2004 11:47:09 -0500
From: Kris Warkentin <kewarken@qnx.com>
Hmm....I think the diff hard to read. I haven't gotten rid of struct
nto_target_ops in nto-tdep.h. All I did is move the comments into the
definition of the structure from outside with the defines.
Ah, OK. Sorry, I misread that.
I also changed the macro defines so that I can assign and test. ie.
old:
define nto_regset_fill(regset, data)
(*current_nto_target.nto_regset_fill) (regset, data)
new:
#define nto_regset_fill (current_nto_target.nto_regset_fill)
That way I can easily switch targets in code.
Hmm. In that case wouldn't it be better to turn current_nto_target
into a pointer, and having a `struct nto_target_ops' for each target
such that you can switch targets by simply doing a pointer assignment?
That would probably get rid of all the macros.
I am defining current_nto_target in nto-tdep.h as being extern but I
don't declare it there. Is having a global verboten? I has assumed it
was okay since we have many precedents like inferior_ptid and
current_target and such.
Declaring variables as `extern' in a header file is fine, although you
should avoid globals if as much as possible.
Mark
^ permalink raw reply [flat|nested] 12+ messages in thread
* Revised: [patch] general updates and improvements to QNX NTO support
2004-12-03 17:44 ` Mark Kettenis
@ 2004-12-06 16:53 ` Kris Warkentin
2004-12-09 0:52 ` Mark Kettenis
0 siblings, 1 reply; 12+ messages in thread
From: Kris Warkentin @ 2004-12-06 16:53 UTC (permalink / raw)
To: Mark Kettenis; +Cc: gdb-patches
[-- Attachment #1: Type: text/plain, Size: 2537 bytes --]
Based on Mark's comments, I've refactored this patch to provide a
cleaner interface to nto_tdep.c. I created an nto_set_target function
so that the targets can initialize their own nto_target_ops and set the
target properly rather than initializing current_nto_target.
I thought about completely hiding the implementation by turning all the
macros into functions which just call the current target functions but
I'm not sure if it's worth it. Specifically I'm thinking about cases
where other modules need access to members of current_nto_target. For
instance, the remote and procfs modules need to set various flags and
hooks so if I were to hide current_nto_target, I'd need setter/getter
functions. Certainly that is the cleaner 'OO' approach. If it needs
changing later, I might also store a list of targets in nto-tdep.c. It
doesn't seem like a high priority right now though since we probably
won't be multi-arching our gdb any time soon.
cheers,
Kris
2004-12-06 Kris Warkentin <kewarken@qnx.com>
* nto-tdep.h: Include osabi.h. Prototypes for generic Neutrino
osabi sniffer, signal handling initializer, 'in_dynsym_resolve_code'
function and nto_set_target function.
(struct nto_target_ops): Put comments inline with struct. Add osabi
sniffer hook. Redefine macros to permit testing/assignment. Remove
nto_ prefix from members.
* nto-tdep.c (nto_find_and_open_solib): Allocate all buffers
dynamically to support arbitrary root paths. Check for basename of
lib in search path and then check for absolute.
(nto_in_dynsym_resolve_code): New function.
(nto_core_sniffer): New function.
(regset_core_fns): Register core sniffer.
(nto_initialize_signals): New function.
(_initialize_nto_tdep): Move signal initialization code to above to
avoid initialization race conditions.
(nto_set_target): New function.
* nto-procfs.c: Minor formatting/indenting changes.
(procfs_is_nto_target): New function.
(procfs_open): Set nto_is_nto_target.
(_initialize_procfs): Ditto. Remove notice_signals() call to avoid
initialization race conditions.
(procfs_create_inferior): Resume inferior after creation.
* i386-nto-tdep.c: Declare i386_nto_target.
(init_i386nto_ops): Initialize i386_nto_target instead of
current_nto_target.
(i386nto_init_abi): Initialize signals. Call nto_set_target. Set
TARGET_SO_IN_DYNSYM_RESOLVE_CODE.
(_initialize_i386nto_tdep): Call init_i386nto_ops. Register osabi
sniffer.
[-- Attachment #2: new.diff --]
[-- Type: text/x-patch, Size: 19394 bytes --]
Index: i386-nto-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/i386-nto-tdep.c,v
retrieving revision 1.15
diff -u -r1.15 i386-nto-tdep.c
--- i386-nto-tdep.c 31 Oct 2004 19:52:46 -0000 1.15
+++ i386-nto-tdep.c 6 Dec 2004 15:05:48 -0000
@@ -59,6 +59,8 @@
(-1 * 4) /* filler */
};
+static struct nto_target_ops i386_nto_target;
+
/* Given a gdb regno, return the offset into Neutrino's register structure
or -1 if register is unknown. */
static int
@@ -258,14 +260,14 @@
static void
init_i386nto_ops (void)
{
- current_nto_target.nto_regset_id = i386nto_regset_id;
- current_nto_target.nto_supply_gregset = i386nto_supply_gregset;
- current_nto_target.nto_supply_fpregset = i386nto_supply_fpregset;
- current_nto_target.nto_supply_altregset = nto_dummy_supply_regset;
- current_nto_target.nto_supply_regset = i386nto_supply_regset;
- current_nto_target.nto_register_area = i386nto_register_area;
- current_nto_target.nto_regset_fill = i386nto_regset_fill;
- current_nto_target.nto_fetch_link_map_offsets =
+ i386_nto_target.regset_id = i386nto_regset_id;
+ i386_nto_target.supply_gregset = i386nto_supply_gregset;
+ i386_nto_target.supply_fpregset = i386nto_supply_fpregset;
+ i386_nto_target.supply_altregset = nto_dummy_supply_regset;
+ i386_nto_target.supply_regset = i386nto_supply_regset;
+ i386_nto_target.register_area = i386nto_register_area;
+ i386_nto_target.regset_fill = i386nto_regset_fill;
+ i386_nto_target.fetch_link_map_offsets =
i386nto_svr4_fetch_link_map_offsets;
}
@@ -274,6 +276,9 @@
{
struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
+ /* Deal with our strange signals. */
+ nto_initialize_signals ();
+
/* NTO uses ELF. */
i386_elf_init_abi (info, gdbarch);
@@ -301,12 +306,18 @@
/* Supply a nice function to find our solibs. */
TARGET_SO_FIND_AND_OPEN_SOLIB = nto_find_and_open_solib;
- init_i386nto_ops ();
+ /* Our linker code is in libc. */
+ TARGET_SO_IN_DYNSYM_RESOLVE_CODE = nto_in_dynsym_resolve_code;
+
+ nto_set_target (&i386_nto_target);
}
void
_initialize_i386nto_tdep (void)
{
+ init_i386nto_ops ();
gdbarch_register_osabi (bfd_arch_i386, 0, GDB_OSABI_QNXNTO,
i386nto_init_abi);
+ gdbarch_register_osabi_sniffer (bfd_arch_i386, bfd_target_elf_flavour,
+ nto_elf_osabi_sniffer);
}
Index: nto-procfs.c
===================================================================
RCS file: /cvs/src/src/gdb/nto-procfs.c,v
retrieving revision 1.6
diff -u -r1.6 nto-procfs.c
--- nto-procfs.c 8 Oct 2004 20:29:47 -0000 1.6
+++ nto-procfs.c 6 Dec 2004 15:05:48 -0000
@@ -97,20 +97,26 @@
is required is because QNX node descriptors are transient so
we have to re-acquire them every time. */
static unsigned
-nto_node(void)
+nto_node (void)
{
unsigned node;
- if (ND_NODE_CMP(nto_procfs_node, ND_LOCAL_NODE) == 0)
+ if (ND_NODE_CMP (nto_procfs_node, ND_LOCAL_NODE) == 0)
return ND_LOCAL_NODE;
- node = netmgr_strtond(nto_procfs_path,0);
+ node = netmgr_strtond (nto_procfs_path, 0);
if (node == -1)
- error ("Lost the QNX node. Debug session probably over.");
+ error ("Lost the QNX node. Debug session probably over.");
return (node);
}
+static enum gdb_osabi
+procfs_is_nto_target (bfd *abfd)
+{
+ return GDB_OSABI_QNXNTO;
+}
+
/* This is called when we call 'target procfs <arg>' from the (gdb) prompt.
For QNX6 (nto), the only valid arg will be a QNX node string,
eg: "/net/some_node". If arg is not a valid QNX node, we will
@@ -124,6 +130,8 @@
int fd, total_size;
procfs_sysinfo *sysinfo;
+ nto_is_nto_target = procfs_is_nto_target;
+
/* Set the default node used for spawning to this one,
and only override it if there is a valid arg. */
@@ -153,7 +161,8 @@
*endstr = 0;
}
}
- snprintf (nto_procfs_path, PATH_MAX - 1, "%s%s", nodestr ? nodestr : "", "/proc");
+ snprintf (nto_procfs_path, PATH_MAX - 1, "%s%s", nodestr ? nodestr : "",
+ "/proc");
if (nodestr)
xfree (nodestr);
@@ -271,7 +280,7 @@
if (dp == NULL)
{
fprintf_unfiltered (gdb_stderr, "failed to opendir \"%s\" - %d (%s)",
- nto_procfs_path, errno, safe_strerror (errno));
+ nto_procfs_path, errno, safe_strerror (errno));
return;
}
@@ -299,7 +308,7 @@
if (fd == -1)
{
fprintf_unfiltered (gdb_stderr, "failed to open %s - %d (%s)\n",
- buf, errno, safe_strerror (errno));
+ buf, errno, safe_strerror (errno));
closedir (dp);
return;
}
@@ -308,8 +317,8 @@
if (devctl (fd, DCMD_PROC_INFO, pidinfo, sizeof (buf), 0) != EOK)
{
fprintf_unfiltered (gdb_stderr,
- "devctl DCMD_PROC_INFO failed - %d (%s)\n", errno,
- safe_strerror (errno));
+ "devctl DCMD_PROC_INFO failed - %d (%s)\n",
+ errno, safe_strerror (errno));
break;
}
num_threads = pidinfo->num_threads;
@@ -375,7 +384,8 @@
err = devctl (ctl_fd, DCMD_PROC_MAPINFO, NULL, 0, &num);
if (err != EOK)
{
- printf ("failed devctl num mapinfos - %d (%s)\n", err, safe_strerror (err));
+ printf ("failed devctl num mapinfos - %d (%s)\n", err,
+ safe_strerror (err));
return;
}
@@ -565,7 +575,7 @@
if (devctl (ctl_fd, DCMD_PROC_STATUS, &status, sizeof (status), 0) == EOK
&& status.flags & _DEBUG_FLAG_STOPPED)
- SignalKill (nto_node(), PIDGET (ptid), 0, SIGCONT, 0, 0);
+ SignalKill (nto_node (), PIDGET (ptid), 0, SIGCONT, 0, 0);
attach_flag = 1;
nto_init_solib_absolute_prefix ();
return ptid;
@@ -778,7 +788,7 @@
siggnal = atoi (args);
if (siggnal)
- SignalKill (nto_node(), PIDGET (inferior_ptid), 0, siggnal, 0, 0);
+ SignalKill (nto_node (), PIDGET (inferior_ptid), 0, siggnal, 0, 0);
close (ctl_fd);
ctl_fd = -1;
@@ -868,8 +878,8 @@
{
if (signal_to_pass != status.info.si_signo)
{
- SignalKill (nto_node(), PIDGET (inferior_ptid), 0, signal_to_pass,
- 0, 0);
+ SignalKill (nto_node (), PIDGET (inferior_ptid), 0,
+ signal_to_pass, 0, 0);
run.flags |= _DEBUG_RUN_CLRFLT | _DEBUG_RUN_CLRSIG;
}
else /* Let it kill the program without telling us. */
@@ -892,7 +902,7 @@
{
if (!ptid_equal (inferior_ptid, null_ptid))
{
- SignalKill (nto_node(), PIDGET (inferior_ptid), 0, SIGKILL, 0, 0);
+ SignalKill (nto_node (), PIDGET (inferior_ptid), 0, SIGKILL, 0, 0);
close (ctl_fd);
}
inferior_ptid = null_ptid;
@@ -1042,7 +1052,7 @@
if (ND_NODE_CMP (nto_procfs_node, ND_LOCAL_NODE) != 0)
{
- inherit.nd = nto_node();
+ inherit.nd = nto_node ();
inherit.flags |= SPAWN_SETND;
inherit.flags &= ~SPAWN_EXEC;
}
@@ -1055,7 +1065,8 @@
sigprocmask (SIG_BLOCK, &set, NULL);
if (pid == -1)
- error ("Error spawning %s: %d (%s)", argv[0], errno, safe_strerror (errno));
+ error ("Error spawning %s: %d (%s)", argv[0], errno,
+ safe_strerror (errno));
if (fds[0] != STDIN_FILENO)
close (fds[0]);
@@ -1083,6 +1094,8 @@
|| (symfile_objfile != NULL && symfile_objfile->obfd != NULL))
SOLIB_CREATE_INFERIOR_HOOK (pid);
#endif
+ stop_soon = 0;
+ proceed (-1, TARGET_SIGNAL_DEFAULT, 0);
}
static void
@@ -1324,7 +1337,6 @@
/* Set up trace and fault sets, as gdb expects them. */
sigemptyset (&run.trace);
- notice_signals ();
/* Stuff some information. */
nto_cpuinfo_flags = SYSPAGE_ENTRY (cpuinfo)->flags;
@@ -1332,6 +1344,8 @@
add_info ("pidlist", procfs_pidlist, "pidlist");
add_info ("meminfo", procfs_meminfo, "memory information");
+
+ nto_is_nto_target = procfs_is_nto_target;
}
Index: nto-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/nto-tdep.c,v
retrieving revision 1.9
diff -u -r1.9 nto-tdep.c
--- nto-tdep.c 30 Jul 2004 19:17:19 -0000 1.9
+++ nto-tdep.c 6 Dec 2004 15:05:48 -0000
@@ -65,6 +65,19 @@
#endif
}
+void
+nto_set_target(struct nto_target_ops *targ)
+{
+ nto_regset_id = targ->regset_id;
+ nto_supply_gregset = targ->supply_gregset;
+ nto_supply_fpregset = targ->supply_fpregset;
+ nto_supply_altregset = targ->supply_altregset;
+ nto_supply_regset = targ->supply_regset;
+ nto_register_area = targ->register_area;
+ nto_regset_fill = targ->regset_fill;
+ nto_fetch_link_map_offsets = targ->fetch_link_map_offsets;
+}
+
/* Take a string such as i386, rs6000, etc. and map it onto CPUTYPE_X86,
CPUTYPE_PPC, etc. as defined in nto-share/dsmsgs.h. */
int
@@ -86,10 +99,10 @@
int
nto_find_and_open_solib (char *solib, unsigned o_flags, char **temp_pathname)
{
- char *buf, arch_path[PATH_MAX], *nto_root, *endian;
+ char *buf, *arch_path, *nto_root, *endian, *base;
const char *arch;
- char *path_fmt = "%s/lib:%s/usr/lib:%s/usr/photon/lib\
-:%s/usr/photon/dll:%s/lib/dll";
+ int ret;
+#define PATH_FMT "%s/lib:%s/usr/lib:%s/usr/photon/lib:%s/usr/photon/dll:%s/lib/dll"
nto_root = nto_target ();
if (strcmp (TARGET_ARCHITECTURE->arch_name, "i386") == 0)
@@ -109,13 +122,38 @@
endian = TARGET_BYTE_ORDER == BFD_ENDIAN_BIG ? "be" : "le";
}
+ /* In case nto_root is short, add strlen(solib)
+ so we can reuse arch_path below. */
+ arch_path =
+ alloca (strlen (nto_root) + strlen (arch) + strlen (endian) + 2 +
+ strlen (solib));
sprintf (arch_path, "%s/%s%s", nto_root, arch, endian);
- buf = alloca (strlen (path_fmt) + strlen (arch_path) * 5 + 1);
- sprintf (buf, path_fmt, arch_path, arch_path, arch_path, arch_path,
+ buf = alloca (strlen (PATH_FMT) + strlen (arch_path) * 5 + 1);
+ sprintf (buf, PATH_FMT, arch_path, arch_path, arch_path, arch_path,
arch_path);
- return openp (buf, OPF_TRY_CWD_FIRST, solib, o_flags, 0, temp_pathname);
+ /* Don't assume basename() isn't destructive. */
+ base = strrchr (solib, '/');
+ if (!base)
+ base = solib;
+ else
+ base++; /* Skip over '/'. */
+
+ ret = openp (buf, 1, base, o_flags, 0, temp_pathname);
+ if (ret < 0 && base != solib)
+ {
+ sprintf (arch_path, "/%s", solib);
+ ret = open (arch_path, o_flags, 0);
+ if (temp_pathname)
+ {
+ if (ret >= 0)
+ *temp_pathname = gdb_realpath (arch_path);
+ else
+ **temp_pathname = '\0';
+ }
+ }
+ return ret;
}
void
@@ -266,6 +304,53 @@
sec->endaddr = nto_truncate_ptr (sec->endaddr + LM_ADDR (so) - vaddr);
}
+/* This is cheating a bit because our linker code is in libc.so. If we
+ ever implement lazy linking, this may need to be re-examined. */
+int
+nto_in_dynsym_resolve_code (CORE_ADDR pc)
+{
+ if (in_plt_section (pc, NULL))
+ return 1;
+ return 0;
+}
+
+void
+nto_generic_supply_gpregset (const struct regset *regset,
+ struct regcache *regcache, int regnum,
+ const void *gregs, size_t len)
+{
+}
+
+void
+nto_generic_supply_fpregset (const struct regset *regset,
+ struct regcache *regcache, int regnum,
+ const void *fpregs, size_t len)
+{
+}
+
+void
+nto_generic_supply_altregset (const struct regset *regset,
+ struct regcache *regcache, int regnum,
+ const void *altregs, size_t len)
+{
+}
+
+void
+nto_dummy_supply_regset (char *regs)
+{
+ /* Do nothing. */
+}
+
+enum gdb_osabi
+nto_elf_osabi_sniffer (bfd *abfd)
+{
+ if (nto_is_nto_target)
+ {
+ return nto_is_nto_target (abfd);
+ }
+ return GDB_OSABI_UNKNOWN;
+}
+
static void
fetch_core_registers (char *core_reg_sect, unsigned core_reg_size,
int which, CORE_ADDR reg_addr)
@@ -287,12 +372,6 @@
}
}
-void
-nto_dummy_supply_regset (char *regs)
-{
- /* Do nothing. */
-}
-
/* Register that we are able to handle ELF file formats using standard
procfs "regset" structures. */
static struct core_fns regset_core_fns = {
@@ -304,18 +383,8 @@
};
void
-_initialize_nto_tdep (void)
+nto_initialize_signals (void)
{
- add_setshow_zinteger_cmd ("nto-debug", class_maintenance,
- &nto_internal_debugging, "\
-Set QNX NTO internal debugging.", "\
-Show QNX NTO internal debugging.", "\
-When non-zero, nto specific debug info is\n\
-displayed. Different information is displayed\n\
-for different positive values.", "\
-QNX NTO internal debugging is %s.",
- NULL, NULL, &setdebuglist, &showdebuglist);
-
/* We use SIG45 for pulses, or something, so nostop, noprint
and pass them. */
signal_stop_update (target_signal_from_name ("SIG45"), 0);
@@ -334,7 +403,19 @@
signal_print_update (SIGPHOTON, 0);
signal_pass_update (SIGPHOTON, 1);
#endif
+}
+void
+_initialize_nto_tdep (void)
+{
+ add_setshow_zinteger_cmd ("nto-debug", class_maintenance,
+ &nto_internal_debugging, "\
+Set QNX NTO internal debugging.", "\
+Show QNX NTO internal debugging.", "\
+When non-zero, nto specific debug info is\n\
+displayed. Different information is displayed\n\
+for different positive values.", "\
+QNX NTO internal debugging is %s.", NULL, NULL, &setdebuglist, &showdebuglist);
/* Register core file support. */
deprecated_add_core_fns (®set_core_fns);
}
Index: nto-tdep.h
===================================================================
RCS file: /cvs/src/src/gdb/nto-tdep.h,v
retrieving revision 1.2
diff -u -r1.2 nto-tdep.h
--- nto-tdep.h 6 May 2003 16:47:47 -0000 1.2
+++ nto-tdep.h 6 Dec 2004 15:05:48 -0000
@@ -26,49 +26,15 @@
#include "defs.h"
#include "solist.h"
-
-/* Generic functions in nto-tdep.c. */
-
-extern void nto_init_solib_absolute_prefix (void);
-
-char **nto_parse_redirection (char *start_argv[], char **in,
- char **out, char **err);
-
-int proc_iterate_over_mappings (int (*func) (int, CORE_ADDR));
-
-void nto_relocate_section_addresses (struct so_list *, struct section_table *);
-
-int nto_map_arch_to_cputype (const char *);
-
-int nto_find_and_open_solib (char *, unsigned, char **);
-
-/* Dummy function for initializing nto_target_ops on targets which do
- not define a particular regset. */
-void nto_dummy_supply_regset (char *regs);
+#include "osabi.h"
+#include "regset.h"
/* Target operations defined for Neutrino targets (<target>-nto-tdep.c). */
struct nto_target_ops
{
- int nto_internal_debugging;
- unsigned nto_cpuinfo_flags;
- int nto_cpuinfo_valid;
-
- int (*nto_regset_id) (int);
- void (*nto_supply_gregset) (char *);
- void (*nto_supply_fpregset) (char *);
- void (*nto_supply_altregset) (char *);
- void (*nto_supply_regset) (int, char *);
- int (*nto_register_area) (int, int, unsigned *);
- int (*nto_regset_fill) (int, char *);
- struct link_map_offsets *(*nto_fetch_link_map_offsets) (void);
-};
-
-extern struct nto_target_ops current_nto_target;
-
/* For 'maintenance debug nto-debug' command. */
-#define nto_internal_debugging \
- (current_nto_target.nto_internal_debugging)
+ int internal_debugging;
/* The CPUINFO flags from the remote. Currently used by
i386 for fxsave but future proofing other hosts.
@@ -76,47 +42,69 @@
depending on our host/target. It would only be invalid
if we were talking to an older pdebug which didn't support
the cpuinfo message. */
-#define nto_cpuinfo_flags \
- (current_nto_target.nto_cpuinfo_flags)
+ unsigned cpuinfo_flags;
/* True if successfully retrieved cpuinfo from remote. */
-#define nto_cpuinfo_valid \
- (current_nto_target.nto_cpuinfo_valid)
+ int cpuinfo_valid;
/* Given a register, return an id that represents the Neutrino
regset it came from. If reg == -1 update all regsets. */
-#define nto_regset_id(reg) \
- (*current_nto_target.nto_regset_id) (reg)
+ int (*regset_id) (int);
-#define nto_supply_gregset(regs) \
- (*current_nto_target.nto_supply_gregset) (regs)
+ void (*supply_gregset) (char *);
-#define nto_supply_fpregset(regs) \
- (*current_nto_target.nto_supply_fpregset) (regs)
+ void (*supply_fpregset) (char *);
-#define nto_supply_altregset(regs) \
- (*current_nto_target.nto_supply_altregset) (regs)
+ void (*supply_altregset) (char *);
/* Given a regset, tell gdb about registers stored in data. */
-#define nto_supply_regset(regset, data) \
- (*current_nto_target.nto_supply_regset) (regset, data)
+ void (*supply_regset) (int, char *);
/* Given a register and regset, calculate the offset into the regset
and stuff it into the last argument. If regno is -1, calculate the
size of the entire regset. Returns length of data, -1 if unknown
regset, 0 if unknown register. */
-#define nto_register_area(reg, regset, off) \
- (*current_nto_target.nto_register_area) (reg, regset, off)
+ int (*register_area) (int, int, unsigned *);
/* Build the Neutrino register set info into the data buffer.
Return -1 if unknown regset, 0 otherwise. */
-#define nto_regset_fill(regset, data) \
- (*current_nto_target.nto_regset_fill) (regset, data)
+ int (*regset_fill) (int, char *);
/* Gives the fetch_link_map_offsets function exposure outside of
solib-svr4.c so that we can override relocate_section_addresses(). */
-#define nto_fetch_link_map_offsets() \
- (*current_nto_target.nto_fetch_link_map_offsets) ()
+ struct link_map_offsets *(*fetch_link_map_offsets) (void);
+
+/* Used by nto_elf_osabi_sniffer to determine if we're connected to an
+ Neutrino target. */
+ enum gdb_osabi (*is_nto_target) (bfd *abfd);
+};
+
+extern struct nto_target_ops current_nto_target;
+
+#define nto_internal_debugging (current_nto_target.internal_debugging)
+
+#define nto_cpuinfo_flags (current_nto_target.cpuinfo_flags)
+
+#define nto_cpuinfo_valid (current_nto_target.cpuinfo_valid)
+
+#define nto_regset_id (current_nto_target.regset_id)
+
+#define nto_supply_gregset (current_nto_target.supply_gregset)
+
+#define nto_supply_fpregset (current_nto_target.supply_fpregset)
+
+#define nto_supply_altregset (current_nto_target.supply_altregset)
+
+#define nto_supply_regset (current_nto_target.supply_regset)
+
+#define nto_register_area (current_nto_target.register_area)
+
+#define nto_regset_fill (current_nto_target.regset_fill)
+
+#define nto_fetch_link_map_offsets \
+(current_nto_target.fetch_link_map_offsets)
+
+#define nto_is_nto_target (current_nto_target.is_nto_target)
/* Keep this consistant with neutrino syspage.h. */
enum
@@ -153,4 +141,41 @@
qnx_reg64 padding[1024];
} nto_regset_t;
+/* Generic functions in nto-tdep.c. */
+
+void nto_init_solib_absolute_prefix (void);
+
+void nto_set_target(struct nto_target_ops *);
+
+char **nto_parse_redirection (char *start_argv[], char **in,
+ char **out, char **err);
+
+int proc_iterate_over_mappings (int (*func) (int, CORE_ADDR));
+
+void nto_relocate_section_addresses (struct so_list *,
+ struct section_table *);
+
+int nto_map_arch_to_cputype (const char *);
+
+int nto_find_and_open_solib (char *, unsigned, char **);
+
+enum gdb_osabi nto_elf_osabi_sniffer (bfd *abfd);
+
+void nto_initialize_signals (void);
+
+void nto_generic_supply_gpregset (const struct regset *, struct regcache *,
+ int, const void *, size_t);
+
+void nto_generic_supply_fpregset (const struct regset *, struct regcache *,
+ int, const void *, size_t);
+
+void nto_generic_supply_altregset (const struct regset *, struct regcache *,
+ int, const void *, size_t);
+
+/* Dummy function for initializing nto_target_ops on targets which do
+ not define a particular regset. */
+void nto_dummy_supply_regset (char *regs);
+
+int nto_in_dynsym_resolve_code (CORE_ADDR pc);
+
#endif
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: Revised: [patch] general updates and improvements to QNX NTO support
2004-12-06 16:53 ` Revised: " Kris Warkentin
@ 2004-12-09 0:52 ` Mark Kettenis
2004-12-09 15:45 ` Kris Warkentin
0 siblings, 1 reply; 12+ messages in thread
From: Mark Kettenis @ 2004-12-09 0:52 UTC (permalink / raw)
To: kewarken; +Cc: gdb-patches
Date: Mon, 06 Dec 2004 10:30:46 -0500
From: Kris Warkentin <kewarken@qnx.com>
Based on Mark's comments, I've refactored this patch to provide a
cleaner interface to nto_tdep.c. I created an nto_set_target function
so that the targets can initialize their own nto_target_ops and set the
target properly rather than initializing current_nto_target.
Thanks. That looks good! I still think you should avoid the
#define nto_xxx_yyy (current_nto_target.xxx_yyy)
defines. They're hiding the fact that you're using a global variable.
Consider a patch that uses current_nto_target.xxx_yyy directly
pre-approved. I've got one additional nit, please see below.
I thought about completely hiding the implementation by turning all the
macros into functions which just call the current target functions but
I'm not sure if it's worth it. Specifically I'm thinking about cases
where other modules need access to members of current_nto_target. For
instance, the remote and procfs modules need to set various flags and
hooks so if I were to hide current_nto_target, I'd need setter/getter
functions. Certainly that is the cleaner 'OO' approach. If it needs
changing later, I might also store a list of targets in nto-tdep.c. It
doesn't seem like a high priority right now though since we probably
won't be multi-arching our gdb any time soon.
This can be done when the need arises.
+enum gdb_osabi
+nto_elf_osabi_sniffer (bfd *abfd)
+{
+ if (nto_is_nto_target)
+ {
+ return nto_is_nto_target (abfd);
+ }
+ return GDB_OSABI_UNKNOWN;
+}
+
Could you remove the redundant braces here? With that change, this is
OK.
Thanks,
Mark
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: Revised: [patch] general updates and improvements to QNX NTO support
2004-12-09 0:52 ` Mark Kettenis
@ 2004-12-09 15:45 ` Kris Warkentin
2004-12-09 22:31 ` Mark Kettenis
0 siblings, 1 reply; 12+ messages in thread
From: Kris Warkentin @ 2004-12-09 15:45 UTC (permalink / raw)
To: Mark Kettenis; +Cc: gdb-patches
Mark Kettenis wrote:
> Date: Mon, 06 Dec 2004 10:30:46 -0500
> From: Kris Warkentin <kewarken@qnx.com>
>
> Based on Mark's comments, I've refactored this patch to provide a
> cleaner interface to nto_tdep.c. I created an nto_set_target function
> so that the targets can initialize their own nto_target_ops and set the
> target properly rather than initializing current_nto_target.
>
>Thanks. That looks good! I still think you should avoid the
>
> #define nto_xxx_yyy (current_nto_target.xxx_yyy)
>
>defines. They're hiding the fact that you're using a global variable.
>Consider a patch that uses current_nto_target.xxx_yyy directly
>pre-approved. I've got one additional nit, please see below.
>
>
Question. I use the nto_xxx_yyy functions _everywhere_ in our code.
Would it be acceptable if I changed the define to be like target.h as in:
#define nto_xxx_yyy(args) (*current_nto_target.xxx_yyy) (args)
Then the only time I would do the full current_nto_target.xxx_yyy is in
cases like below where it needs to be obvious that I'm testing or
setting a global variable. Its just that there are so many instances of
these macros in our target support that the syntactic sugar is very
attractive for code readability.
> +enum gdb_osabi
> +nto_elf_osabi_sniffer (bfd *abfd)
> +{
> + if (nto_is_nto_target)
> + {
> + return nto_is_nto_target (abfd);
> + }
> + return GDB_OSABI_UNKNOWN;
> +}
> +
>
>Could you remove the redundant braces here? With that change, this is
>OK.
>
No problem. Thanks.
Kris
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: Revised: [patch] general updates and improvements to QNX NTO support
2004-12-09 15:45 ` Kris Warkentin
@ 2004-12-09 22:31 ` Mark Kettenis
0 siblings, 0 replies; 12+ messages in thread
From: Mark Kettenis @ 2004-12-09 22:31 UTC (permalink / raw)
To: kewarken; +Cc: gdb-patches
Date: Thu, 09 Dec 2004 09:05:05 -0500
From: Kris Warkentin <kewarken@qnx.com>
Mark Kettenis wrote:
> Date: Mon, 06 Dec 2004 10:30:46 -0500
> From: Kris Warkentin <kewarken@qnx.com>
>
> Based on Mark's comments, I've refactored this patch to provide a
> cleaner interface to nto_tdep.c. I created an nto_set_target function
> so that the targets can initialize their own nto_target_ops and set the
> target properly rather than initializing current_nto_target.
>
>Thanks. That looks good! I still think you should avoid the
>
> #define nto_xxx_yyy (current_nto_target.xxx_yyy)
>
>defines. They're hiding the fact that you're using a global variable.
>Consider a patch that uses current_nto_target.xxx_yyy directly
>pre-approved. I've got one additional nit, please see below.
>
>
Question. I use the nto_xxx_yyy functions _everywhere_ in our code.
Would it be acceptable if I changed the define to be like target.h as in:
#define nto_xxx_yyy(args) (*current_nto_target.xxx_yyy) (args)
Then the only time I would do the full current_nto_target.xxx_yyy is in
cases like below where it needs to be obvious that I'm testing or
setting a global variable. Its just that there are so many instances of
these macros in our target support that the syntactic sugar is very
attractive for code readability.
Bugger. I let that patch fool me again. Thought the defines were
new, but of course they're not. Forget what I said about them and
check your patch in as is. That is...
> +enum gdb_osabi
> +nto_elf_osabi_sniffer (bfd *abfd)
> +{
> + if (nto_is_nto_target)
> + {
> + return nto_is_nto_target (abfd);
> + }
> + return GDB_OSABI_UNKNOWN;
> +}
> +
>
>Could you remove the redundant braces here? With that change, this is
>OK.
>
No problem. Thanks.
with that change please.
Cheers,
Mark
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: Ping: [patch] general updates and improvements to QNX NTO support
@ 2004-12-03 23:16 Kris Warkentin
0 siblings, 0 replies; 12+ messages in thread
From: Kris Warkentin @ 2004-12-03 23:16 UTC (permalink / raw)
To: gdb-patches
Mark Kettenis wrote:
> Ah, OK. Sorry, I misread that.
>
>
No problem...kind of a funny looking diff.
> I also changed the macro defines so that I can assign and test. ie.
>
> old:
> define nto_regset_fill(regset, data)
(*current_nto_target.nto_regset_fill) (regset, data)
>
> new:
> #define nto_regset_fill (current_nto_target.nto_regset_fill)
>
> That way I can easily switch targets in code.
>
> Hmm. In that case wouldn't it be better to turn current_nto_target
> into a pointer, and having a `struct nto_target_ops' for each target
> such that you can switch targets by simply doing a pointer assignment?
> That would probably get rid of all the macros.
>
>
That's a good idea and I actually do something very similar in our
remote support (which I haven't submitted yet) As it stands, rather
than just switching a pointer, I initialize all the members in
init_i386nto_ops. I have similar init functions for arm, sh, mips and
ppc. I'm not sure how I'd get rid of the macros though....it's still
convenient to have a generic nto_regset_fill function macro rather than
having to dereference. Plus, it's handy to be able to check for
validity before using a function like in nto_elf_osabi_sniffer. I'm
just thinking that if gdb were truly multi-arched, there could be a
situation where my nto_target_ops haven't been initialized and something
like a sniffer could crash. I could be wrong about that though.
> I am defining current_nto_target in nto-tdep.h as being extern but
I don't declare it there. Is having a global verboten? I has assumed
it was okay since we have many precedents like inferior_ptid and
current_target and such.
>
> Declaring variables as `extern' in a header file is fine, although you
> should avoid globals if as much as possible.
>
I did it that way to be consistent with the current_target idea within
gdb. We actually have five targets so it makes it easier to switch
things around. I'd welcome any ideas for improvement though. Not much
originality on all this - I pretty much tried to do things exactly the
way target.h does. I hope I don't lose marks for plaigarism... ;-)
cheers,
Kris
^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2004-12-09 22:05 UTC | newest]
Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-11-19 20:47 [patch] general updates and improvements to QNX NTO support Kris Warkentin
2004-11-26 20:37 ` Ping: " Kris Warkentin
2004-12-03 16:09 ` Kris Warkentin
2004-12-03 16:17 ` Mark Kettenis
2004-12-03 17:01 ` Kris Warkentin
2004-12-03 17:23 ` Kris Warkentin
2004-12-03 17:44 ` Mark Kettenis
2004-12-06 16:53 ` Revised: " Kris Warkentin
2004-12-09 0:52 ` Mark Kettenis
2004-12-09 15:45 ` Kris Warkentin
2004-12-09 22:31 ` Mark Kettenis
2004-12-03 23:16 Ping: " Kris Warkentin
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox