1999-08-09 21:36:23 +00:00
|
|
|
/* Kernel Object Display generic routines and callbacks
|
2005-12-17 22:34:03 +00:00
|
|
|
Copyright (C) 1998, 1999, 2000 Free Software Foundation, Inc.
|
1999-08-09 21:36:23 +00:00
|
|
|
|
|
|
|
Written by Fernando Nasser <fnasser@cygnus.com> for Cygnus Solutions.
|
|
|
|
|
|
|
|
This file is part of GDB.
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation; either version 2 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to the Free Software
|
2005-12-17 22:34:03 +00:00
|
|
|
Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
|
|
|
Boston, MA 02110-1301, USA. */
|
1999-08-09 21:36:23 +00:00
|
|
|
|
|
|
|
#include "defs.h"
|
|
|
|
#include "command.h"
|
|
|
|
#include "gdbcmd.h"
|
|
|
|
#include "target.h"
|
|
|
|
#include "gdb_string.h"
|
1999-09-22 03:28:34 +00:00
|
|
|
#include "kod.h"
|
1999-08-09 21:36:23 +00:00
|
|
|
|
|
|
|
/* Prototypes for exported functions. */
|
|
|
|
void _initialize_kod (void);
|
|
|
|
|
|
|
|
/* Prototypes for local functions. */
|
|
|
|
static void info_kod_command (char *, int);
|
|
|
|
static void load_kod_library (char *);
|
|
|
|
|
|
|
|
/* Prototypes for callbacks. These are passed into the KOD modules. */
|
|
|
|
static void gdb_kod_display (char *);
|
|
|
|
static void gdb_kod_query (char *, char *, int *);
|
|
|
|
|
|
|
|
/* These functions are imported from the KOD module.
|
|
|
|
|
|
|
|
gdb_kod_open - initiates the KOD connection to the remote. The
|
|
|
|
first argument is the display function the module should use to
|
|
|
|
communicate with the user. The second argument is the query
|
|
|
|
function the display should use to communicate with the target.
|
|
|
|
This should call error() if there is an error. Otherwise it should
|
|
|
|
return a malloc()d string of the form:
|
|
|
|
|
|
|
|
NAME VERSION - DESCRIPTION
|
|
|
|
|
|
|
|
Neither NAME nor VERSION should contain a hyphen.
|
|
|
|
|
|
|
|
|
|
|
|
gdb_kod_request - This is used when the user enters an "info
|
|
|
|
<module>" request. The remaining arguments are passed as the first
|
|
|
|
argument. The second argument is the standard `from_tty'
|
|
|
|
argument.
|
|
|
|
|
|
|
|
|
|
|
|
gdb_kod_close - This is called when the KOD connection to the
|
|
|
|
remote should be terminated. */
|
|
|
|
|
1999-09-22 03:28:34 +00:00
|
|
|
static char *(*gdb_kod_open) (kod_display_callback_ftype *display,
|
|
|
|
kod_query_callback_ftype *query);
|
1999-08-09 21:36:23 +00:00
|
|
|
static void (*gdb_kod_request) (char *, int);
|
|
|
|
static void (*gdb_kod_close) ();
|
|
|
|
|
|
|
|
|
|
|
|
/* Name of inferior's operating system. */
|
|
|
|
char *operating_system;
|
|
|
|
|
|
|
|
/* We save a copy of the OS so that we can properly reset when
|
|
|
|
switching OS's. */
|
|
|
|
static char *old_operating_system;
|
|
|
|
|
|
|
|
/* Print a line of data generated by the module. */
|
|
|
|
|
|
|
|
static void
|
|
|
|
gdb_kod_display (char *arg)
|
|
|
|
{
|
|
|
|
printf_filtered ("%s", arg);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Queries the target on behalf of the module. */
|
|
|
|
|
|
|
|
static void
|
|
|
|
gdb_kod_query (char *arg, char *result, int *maxsiz)
|
|
|
|
{
|
2003-10-17 18:24:49 +00:00
|
|
|
LONGEST bufsiz = 0;
|
1999-08-09 21:36:23 +00:00
|
|
|
|
2003-10-17 18:24:49 +00:00
|
|
|
/* Check if current target has remote_query capabilities. If not,
|
|
|
|
it does not have kod either. */
|
|
|
|
bufsiz = target_read_partial (¤t_target, TARGET_OBJECT_KOD,
|
|
|
|
NULL, NULL, 0, 0);
|
|
|
|
if (bufsiz < 0)
|
1999-08-09 21:36:23 +00:00
|
|
|
{
|
|
|
|
strcpy (result,
|
|
|
|
"ERR: Kernel Object Display not supported by current target\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Just get the maximum buffer size. */
|
|
|
|
|
|
|
|
/* Check if *we* were called just for getting the buffer size. */
|
|
|
|
if (*maxsiz == 0)
|
|
|
|
{
|
|
|
|
*maxsiz = bufsiz;
|
|
|
|
strcpy (result, "OK");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Check if caller can handle a buffer this large, if not, adjust. */
|
|
|
|
if (bufsiz > *maxsiz)
|
|
|
|
bufsiz = *maxsiz;
|
|
|
|
|
|
|
|
/* See if buffer can hold the query (usually it can, as the query is
|
|
|
|
short). */
|
|
|
|
if (strlen (arg) >= bufsiz)
|
2005-02-10 Andrew Cagney <cagney@gnu.org>
Mark up all error and warning messages.
* ada-lang.c, amd64-tdep.c, arch-utils.c, breakpoint.c: Update.
* bsd-kvm.c, bsd-uthread.c, coff-solib.h, coffread.c: Update.
* core-aout.c, core-regset.c, corefile.c, corelow.c: Update.
* cp-abi.c, cp-support.c, cp-valprint.c, cris-tdep.c: Update.
* dbxread.c, demangle.c, doublest.c, dsrec.c: Update.
* dve3900-rom.c, dwarf2expr.c, dwarf2loc.c: Update.
* dwarf2read.c, dwarfread.c, elfread.c, eval.c: Update.
* event-top.c, exec.c, expprint.c, f-lang.c: Update.
* f-typeprint.c, f-valprint.c, fbsd-nat.c, findvar.c: Update.
* frame.c, frv-linux-tdep.c, gcore.c, gdbtypes.c: Update.
* gnu-nat.c, gnu-v2-abi.c, gnu-v3-abi.c, go32-nat.c: Update.
* hpacc-abi.c, hppa-hpux-nat.c, hppa-hpux-tdep.c: Update.
* hppa-linux-nat.c, hppa-linux-tdep.c, hppa-tdep.c: Update.
* hpread.c, hpux-thread.c, i386-linux-nat.c: Update.
* i386-linux-tdep.c, i386-tdep.c, i386bsd-nat.c: Update.
* i386gnu-nat.c, i387-tdep.c, ia64-linux-nat.c: Update.
* ia64-tdep.c, inf-child.c, inf-ptrace.c, inf-ttrace.c: Update.
* infcall.c, infcmd.c, inflow.c, infptrace.c, infrun.c: Update.
* inftarg.c, interps.c, irix5-nat.c, jv-lang.c: Update.
* kod-cisco.c, kod.c, language.c, libunwind-frame.c: Update.
* linespec.c, linux-nat.c, linux-thread-db.c, m2-lang.c: Update.
* m32r-rom.c, m68hc11-tdep.c, m68k-tdep.c: Update.
* m68klinux-nat.c, macrocmd.c, macroexp.c, main.c: Update.
* maint.c, mdebugread.c, mem-break.c, memattr.c: Update.
* mips-linux-tdep.c, mips-tdep.c, mipsread.c, monitor.c: Update.
* nlmread.c, nto-procfs.c, objc-lang.c, objfiles.c: Update.
* observer.c, ocd.c, p-lang.c, p-typeprint.c: Update.
* p-valprint.c, pa64solib.c, parse.c, ppc-linux-tdep.c: Update.
* ppcnbsd-tdep.c, printcmd.c, procfs.c, remote-e7000.c: Update.
* remote-fileio.c, remote-m32r-sdi.c, remote-rdi.c: Update.
* remote-rdp.c, remote-sim.c, remote-st.c: Update.
* remote-utils.c, remote-utils.h, remote.c: Update.
* rom68k-rom.c, rs6000-nat.c, s390-tdep.c, scm-lang.c: Update.
* ser-e7kpc.c, ser-tcp.c, ser-unix.c, sh-tdep.c: Update.
* sh3-rom.c, shnbsd-tdep.c, sol-thread.c, solib-aix5.c: Update.
* solib-frv.c, solib-irix.c, solib-osf.c, solib-pa64.c: Update.
* solib-som.c, solib-sunos.c, solib-svr4.c, solib.c: Update.
* somread.c, somsolib.c, source.c, stabsread.c: Update.
* stack.c, std-regs.c, symfile-mem.c, symfile.c: Update.
* symmisc.c, symtab.c, target.c, thread.c, top.c: Update.
* tracepoint.c, trad-frame.c, typeprint.c, utils.c: Update.
* uw-thread.c, valarith.c, valops.c, valprint.c: Update.
* value.c, varobj.c, version.in, win32-nat.c, wince.c: Update.
* xcoffread.c, xcoffsolib.c, cli/cli-cmds.c: Update.
* cli/cli-decode.c, cli/cli-dump.c, cli/cli-logging.c: Update.
* cli/cli-script.c, cli/cli-setshow.c, mi/mi-cmd-break.c: Update.
* mi/mi-cmd-disas.c, mi/mi-cmd-env.c, mi/mi-cmd-file.c: Update.
* mi/mi-cmd-stack.c, mi/mi-cmd-var.c, mi/mi-getopt.c: Update.
* mi/mi-symbol-cmds.c, tui/tui-layout.c, tui/tui-stack.c: Update.
* tui/tui-win.c: Update.
2005-02-11 04:06:14 +00:00
|
|
|
error (_("kod: query argument too long"));
|
1999-08-09 21:36:23 +00:00
|
|
|
|
|
|
|
/* Send actual request. */
|
2003-10-17 18:24:49 +00:00
|
|
|
if (target_read_partial (¤t_target, TARGET_OBJECT_KOD,
|
|
|
|
arg, result, 0, bufsiz) < 0)
|
1999-08-09 21:36:23 +00:00
|
|
|
strcpy (result, "ERR: remote query failed");
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Print name of kod command after selecting the appropriate kod
|
|
|
|
formatting library module. As a side effect we create a new "info"
|
|
|
|
subcommand which is what the user actually uses to query the OS. */
|
|
|
|
|
|
|
|
static void
|
|
|
|
kod_set_os (char *arg, int from_tty, struct cmd_list_element *command)
|
|
|
|
{
|
|
|
|
char *p;
|
|
|
|
|
|
|
|
/* If we had already had an open OS, close it. */
|
|
|
|
if (gdb_kod_close)
|
|
|
|
(*gdb_kod_close) ();
|
|
|
|
|
|
|
|
/* Also remove the old OS's command. */
|
|
|
|
if (old_operating_system)
|
|
|
|
{
|
|
|
|
delete_cmd (old_operating_system, &infolist);
|
2000-12-15 01:01:51 +00:00
|
|
|
xfree (old_operating_system);
|
1999-08-09 21:36:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (! operating_system || ! *operating_system)
|
|
|
|
{
|
|
|
|
/* If user set operating system to empty, we want to forget we
|
|
|
|
had a module open. Setting these variables is just nice for
|
|
|
|
debugging and clarity. */
|
|
|
|
gdb_kod_open = NULL;
|
|
|
|
gdb_kod_request = NULL;
|
|
|
|
gdb_kod_close = NULL;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
char *kodlib;
|
|
|
|
|
2002-03-17 19:29:37 +00:00
|
|
|
old_operating_system = xstrdup (operating_system);
|
|
|
|
|
1999-08-09 21:36:23 +00:00
|
|
|
load_kod_library (operating_system);
|
|
|
|
|
|
|
|
kodlib = (*gdb_kod_open) (gdb_kod_display, gdb_kod_query);
|
|
|
|
|
|
|
|
/* Add kod related info commands to gdb. */
|
|
|
|
add_info (operating_system, info_kod_command,
|
2005-02-15 Andrew Cagney <cagney@gnu.org>
Mark up add_com, add_info and add_prefix_cmd.
* breakpoint.c, cp-support.c, dcache.c, dwarf2read.c: Update.
* exec.c, f-valprint.c, frame.c, gcore.c, gnu-nat.c: Update.
* go32-nat.c, infcmd.c, inflow.c, infptrace.c, infrun.c: Update.
* kod.c, language.c, linux-nat.c, m32r-rom.c, macrocmd.c: Update.
* maint.c, memattr.c, mips-tdep.c, nto-procfs.c, objc-lang.c: Update.
* ocd.c, pa64solib.c, printcmd.c, procfs.c, regcache.c: Update.
* remote-e7000.c, remote-m32r-sdi.c, remote-mips.c: Update.
* remote-sds.c, remote-sim.c, remote-st.c, remote-utils.c: Update.
* remote.c, rs6000-tdep.c, ser-go32.c, serial.c: Update.
* sh-tdep.c, solib.c, somsolib.c, source.c, stack.c: Update.
* symfile.c, symtab.c, target.c, thread.c, top.c: Update.
* tracepoint.c, typeprint.c, utils.c, valprint.c: Update.
* win32-nat.c, xcoffsolib.c, cli/cli-cmds.c, cli/cli-dump.c: Update.
* cli/cli-logging.c, tui/tui-layout.c, tui/tui-regs.c: Update.
* tui/tui-stack.c, tui/tui-win.c: Update.
2005-02-15 15:49:28 +00:00
|
|
|
_("Displays information about Kernel Objects."));
|
1999-08-09 21:36:23 +00:00
|
|
|
|
|
|
|
p = strrchr (kodlib, '-');
|
|
|
|
if (p != NULL)
|
|
|
|
p++;
|
|
|
|
else
|
|
|
|
p = "Unknown KOD library";
|
|
|
|
printf_filtered ("%s - %s\n", operating_system, p);
|
|
|
|
|
2000-12-15 01:01:51 +00:00
|
|
|
xfree (kodlib);
|
1999-08-09 21:36:23 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Print information about currently known kernel objects of the
|
|
|
|
specified type or a list of all known kernel object types if
|
|
|
|
argument is empty. */
|
|
|
|
|
|
|
|
static void
|
|
|
|
info_kod_command (char *arg, int from_tty)
|
|
|
|
{
|
|
|
|
(*gdb_kod_request) (arg, from_tty);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Print name of kod command after selecting the appropriate kod
|
|
|
|
formatting library module. */
|
|
|
|
|
|
|
|
static void
|
|
|
|
load_kod_library (char *lib)
|
|
|
|
{
|
|
|
|
#if 0
|
|
|
|
/* FIXME: Don't have the eCos code here. */
|
|
|
|
if (! strcmp (lib, "ecos"))
|
|
|
|
{
|
|
|
|
gdb_kod_open = ecos_kod_open;
|
|
|
|
gdb_kod_request = ecos_kod_request;
|
|
|
|
gdb_kod_close = ecos_kod_close;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
#endif /* 0 */
|
|
|
|
if (! strcmp (lib, "cisco"))
|
|
|
|
{
|
|
|
|
gdb_kod_open = cisco_kod_open;
|
|
|
|
gdb_kod_request = cisco_kod_request;
|
|
|
|
gdb_kod_close = cisco_kod_close;
|
|
|
|
}
|
|
|
|
else
|
2005-02-10 Andrew Cagney <cagney@gnu.org>
Mark up all error and warning messages.
* ada-lang.c, amd64-tdep.c, arch-utils.c, breakpoint.c: Update.
* bsd-kvm.c, bsd-uthread.c, coff-solib.h, coffread.c: Update.
* core-aout.c, core-regset.c, corefile.c, corelow.c: Update.
* cp-abi.c, cp-support.c, cp-valprint.c, cris-tdep.c: Update.
* dbxread.c, demangle.c, doublest.c, dsrec.c: Update.
* dve3900-rom.c, dwarf2expr.c, dwarf2loc.c: Update.
* dwarf2read.c, dwarfread.c, elfread.c, eval.c: Update.
* event-top.c, exec.c, expprint.c, f-lang.c: Update.
* f-typeprint.c, f-valprint.c, fbsd-nat.c, findvar.c: Update.
* frame.c, frv-linux-tdep.c, gcore.c, gdbtypes.c: Update.
* gnu-nat.c, gnu-v2-abi.c, gnu-v3-abi.c, go32-nat.c: Update.
* hpacc-abi.c, hppa-hpux-nat.c, hppa-hpux-tdep.c: Update.
* hppa-linux-nat.c, hppa-linux-tdep.c, hppa-tdep.c: Update.
* hpread.c, hpux-thread.c, i386-linux-nat.c: Update.
* i386-linux-tdep.c, i386-tdep.c, i386bsd-nat.c: Update.
* i386gnu-nat.c, i387-tdep.c, ia64-linux-nat.c: Update.
* ia64-tdep.c, inf-child.c, inf-ptrace.c, inf-ttrace.c: Update.
* infcall.c, infcmd.c, inflow.c, infptrace.c, infrun.c: Update.
* inftarg.c, interps.c, irix5-nat.c, jv-lang.c: Update.
* kod-cisco.c, kod.c, language.c, libunwind-frame.c: Update.
* linespec.c, linux-nat.c, linux-thread-db.c, m2-lang.c: Update.
* m32r-rom.c, m68hc11-tdep.c, m68k-tdep.c: Update.
* m68klinux-nat.c, macrocmd.c, macroexp.c, main.c: Update.
* maint.c, mdebugread.c, mem-break.c, memattr.c: Update.
* mips-linux-tdep.c, mips-tdep.c, mipsread.c, monitor.c: Update.
* nlmread.c, nto-procfs.c, objc-lang.c, objfiles.c: Update.
* observer.c, ocd.c, p-lang.c, p-typeprint.c: Update.
* p-valprint.c, pa64solib.c, parse.c, ppc-linux-tdep.c: Update.
* ppcnbsd-tdep.c, printcmd.c, procfs.c, remote-e7000.c: Update.
* remote-fileio.c, remote-m32r-sdi.c, remote-rdi.c: Update.
* remote-rdp.c, remote-sim.c, remote-st.c: Update.
* remote-utils.c, remote-utils.h, remote.c: Update.
* rom68k-rom.c, rs6000-nat.c, s390-tdep.c, scm-lang.c: Update.
* ser-e7kpc.c, ser-tcp.c, ser-unix.c, sh-tdep.c: Update.
* sh3-rom.c, shnbsd-tdep.c, sol-thread.c, solib-aix5.c: Update.
* solib-frv.c, solib-irix.c, solib-osf.c, solib-pa64.c: Update.
* solib-som.c, solib-sunos.c, solib-svr4.c, solib.c: Update.
* somread.c, somsolib.c, source.c, stabsread.c: Update.
* stack.c, std-regs.c, symfile-mem.c, symfile.c: Update.
* symmisc.c, symtab.c, target.c, thread.c, top.c: Update.
* tracepoint.c, trad-frame.c, typeprint.c, utils.c: Update.
* uw-thread.c, valarith.c, valops.c, valprint.c: Update.
* value.c, varobj.c, version.in, win32-nat.c, wince.c: Update.
* xcoffread.c, xcoffsolib.c, cli/cli-cmds.c: Update.
* cli/cli-decode.c, cli/cli-dump.c, cli/cli-logging.c: Update.
* cli/cli-script.c, cli/cli-setshow.c, mi/mi-cmd-break.c: Update.
* mi/mi-cmd-disas.c, mi/mi-cmd-env.c, mi/mi-cmd-file.c: Update.
* mi/mi-cmd-stack.c, mi/mi-cmd-var.c, mi/mi-getopt.c: Update.
* mi/mi-symbol-cmds.c, tui/tui-layout.c, tui/tui-stack.c: Update.
* tui/tui-win.c: Update.
2005-02-11 04:06:14 +00:00
|
|
|
error (_("Unknown operating system: %s."), operating_system);
|
1999-08-09 21:36:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2000-07-30 01:48:28 +00:00
|
|
|
_initialize_kod (void)
|
1999-08-09 21:36:23 +00:00
|
|
|
{
|
|
|
|
struct cmd_list_element *c;
|
|
|
|
|
2005-02-21 06:21:09 +00:00
|
|
|
add_setshow_string_cmd ("os", no_class, &operating_system, _("\
|
|
|
|
Set operating system"), _("\
|
|
|
|
Show operating system"), NULL,
|
|
|
|
kod_set_os,
|
|
|
|
NULL, /* FIXME: i18n: */
|
|
|
|
&setlist, &showlist);
|
1999-08-09 21:36:23 +00:00
|
|
|
}
|