2002-05-16 23:15:53 +02:00
|
|
|
|
/* C preprocessor macro expansion commands for GDB.
|
2010-01-01 08:32:07 +01:00
|
|
|
|
Copyright (C) 2002, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
|
2002-05-16 23:15:53 +02:00
|
|
|
|
Contributed by Red Hat, Inc.
|
|
|
|
|
|
|
|
|
|
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
|
2007-08-23 20:08:50 +02:00
|
|
|
|
the Free Software Foundation; either version 3 of the License, or
|
2002-05-16 23:15:53 +02:00
|
|
|
|
(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
|
2007-08-23 20:08:50 +02:00
|
|
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
2002-05-16 23:15:53 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#include "defs.h"
|
|
|
|
|
#include "macrotab.h"
|
|
|
|
|
#include "macroexp.h"
|
|
|
|
|
#include "macroscope.h"
|
|
|
|
|
#include "command.h"
|
|
|
|
|
#include "gdbcmd.h"
|
2008-07-18 22:55:33 +02:00
|
|
|
|
#include "gdb_string.h"
|
2002-05-16 23:15:53 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* The `macro' prefix command. */
|
|
|
|
|
|
|
|
|
|
static struct cmd_list_element *macrolist;
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
macro_command (char *arg, int from_tty)
|
|
|
|
|
{
|
|
|
|
|
printf_unfiltered
|
|
|
|
|
("\"macro\" must be followed by the name of a macro command.\n");
|
|
|
|
|
help_list (macrolist, "macro ", -1, gdb_stdout);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Macro expansion commands. */
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
macro_expand_command (char *exp, int from_tty)
|
|
|
|
|
{
|
|
|
|
|
struct macro_scope *ms = NULL;
|
|
|
|
|
char *expanded = NULL;
|
|
|
|
|
struct cleanup *cleanup_chain = make_cleanup (free_current_contents, &ms);
|
2010-05-16 02:18:02 +02:00
|
|
|
|
|
2002-05-16 23:15:53 +02:00
|
|
|
|
make_cleanup (free_current_contents, &expanded);
|
|
|
|
|
|
|
|
|
|
/* You know, when the user doesn't specify any expression, it would be
|
|
|
|
|
really cool if this defaulted to the last expression evaluated.
|
|
|
|
|
Then it would be easy to ask, "Hey, what did I just evaluate?" But
|
|
|
|
|
at the moment, the `print' commands don't save the last expression
|
|
|
|
|
evaluated, just its value. */
|
|
|
|
|
if (! exp || ! *exp)
|
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 05:06:14 +01:00
|
|
|
|
error (_("You must follow the `macro expand' command with the"
|
2002-05-16 23:15:53 +02:00
|
|
|
|
" expression you\n"
|
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 05:06:14 +01:00
|
|
|
|
"want to expand."));
|
2002-05-16 23:15:53 +02:00
|
|
|
|
|
|
|
|
|
ms = default_macro_scope ();
|
|
|
|
|
if (ms)
|
|
|
|
|
{
|
|
|
|
|
expanded = macro_expand (exp, standard_macro_lookup, ms);
|
|
|
|
|
fputs_filtered ("expands to: ", gdb_stdout);
|
|
|
|
|
fputs_filtered (expanded, gdb_stdout);
|
|
|
|
|
fputs_filtered ("\n", gdb_stdout);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
fputs_filtered ("GDB has no preprocessor macro information for "
|
|
|
|
|
"that code.\n",
|
|
|
|
|
gdb_stdout);
|
|
|
|
|
|
|
|
|
|
do_cleanups (cleanup_chain);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
macro_expand_once_command (char *exp, int from_tty)
|
|
|
|
|
{
|
|
|
|
|
struct macro_scope *ms = NULL;
|
|
|
|
|
char *expanded = NULL;
|
|
|
|
|
struct cleanup *cleanup_chain = make_cleanup (free_current_contents, &ms);
|
|
|
|
|
make_cleanup (free_current_contents, &expanded);
|
|
|
|
|
|
|
|
|
|
/* You know, when the user doesn't specify any expression, it would be
|
|
|
|
|
really cool if this defaulted to the last expression evaluated.
|
|
|
|
|
And it should set the once-expanded text as the new `last
|
|
|
|
|
expression'. That way, you could just hit return over and over and
|
|
|
|
|
see the expression expanded one level at a time. */
|
|
|
|
|
if (! exp || ! *exp)
|
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 05:06:14 +01:00
|
|
|
|
error (_("You must follow the `macro expand-once' command with"
|
2002-05-16 23:15:53 +02:00
|
|
|
|
" the expression\n"
|
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 05:06:14 +01:00
|
|
|
|
"you want to expand."));
|
2002-05-16 23:15:53 +02:00
|
|
|
|
|
|
|
|
|
ms = default_macro_scope ();
|
|
|
|
|
if (ms)
|
|
|
|
|
{
|
|
|
|
|
expanded = macro_expand_once (exp, standard_macro_lookup, ms);
|
|
|
|
|
fputs_filtered ("expands to: ", gdb_stdout);
|
|
|
|
|
fputs_filtered (expanded, gdb_stdout);
|
|
|
|
|
fputs_filtered ("\n", gdb_stdout);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
fputs_filtered ("GDB has no preprocessor macro information for "
|
|
|
|
|
"that code.\n",
|
|
|
|
|
gdb_stdout);
|
|
|
|
|
|
|
|
|
|
do_cleanups (cleanup_chain);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
show_pp_source_pos (struct ui_file *stream,
|
|
|
|
|
struct macro_source_file *file,
|
|
|
|
|
int line)
|
|
|
|
|
{
|
|
|
|
|
fprintf_filtered (stream, "%s:%d\n", file->filename, line);
|
|
|
|
|
|
|
|
|
|
while (file->included_by)
|
|
|
|
|
{
|
|
|
|
|
fprintf_filtered (gdb_stdout, " included at %s:%d\n",
|
|
|
|
|
file->included_by->filename,
|
|
|
|
|
file->included_at_line);
|
|
|
|
|
file = file->included_by;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
2002-06-11 22:05:03 +02:00
|
|
|
|
info_macro_command (char *name, int from_tty)
|
2002-05-16 23:15:53 +02:00
|
|
|
|
{
|
|
|
|
|
struct macro_scope *ms = NULL;
|
|
|
|
|
struct cleanup *cleanup_chain = make_cleanup (free_current_contents, &ms);
|
|
|
|
|
struct macro_definition *d;
|
|
|
|
|
|
|
|
|
|
if (! name || ! *name)
|
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 05:06:14 +01:00
|
|
|
|
error (_("You must follow the `info macro' command with the name"
|
2002-05-16 23:15:53 +02:00
|
|
|
|
" of the macro\n"
|
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 05:06:14 +01:00
|
|
|
|
"whose definition you want to see."));
|
2002-05-16 23:15:53 +02:00
|
|
|
|
|
|
|
|
|
ms = default_macro_scope ();
|
|
|
|
|
if (! ms)
|
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 05:06:14 +01:00
|
|
|
|
error (_("GDB has no preprocessor macro information for that code."));
|
2002-05-16 23:15:53 +02:00
|
|
|
|
|
|
|
|
|
d = macro_lookup_definition (ms->file, ms->line, name);
|
|
|
|
|
if (d)
|
|
|
|
|
{
|
|
|
|
|
int line;
|
|
|
|
|
struct macro_source_file *file
|
|
|
|
|
= macro_definition_location (ms->file, ms->line, name, &line);
|
|
|
|
|
|
|
|
|
|
fprintf_filtered (gdb_stdout, "Defined at ");
|
|
|
|
|
show_pp_source_pos (gdb_stdout, file, line);
|
2009-04-29 09:51:33 +02:00
|
|
|
|
if (line != 0)
|
|
|
|
|
fprintf_filtered (gdb_stdout, "#define %s", name);
|
|
|
|
|
else
|
|
|
|
|
fprintf_filtered (gdb_stdout, "-D%s", name);
|
2002-05-16 23:15:53 +02:00
|
|
|
|
if (d->kind == macro_function_like)
|
|
|
|
|
{
|
|
|
|
|
int i;
|
|
|
|
|
|
|
|
|
|
fputs_filtered ("(", gdb_stdout);
|
|
|
|
|
for (i = 0; i < d->argc; i++)
|
|
|
|
|
{
|
|
|
|
|
fputs_filtered (d->argv[i], gdb_stdout);
|
|
|
|
|
if (i + 1 < d->argc)
|
|
|
|
|
fputs_filtered (", ", gdb_stdout);
|
|
|
|
|
}
|
|
|
|
|
fputs_filtered (")", gdb_stdout);
|
|
|
|
|
}
|
2009-04-29 09:51:33 +02:00
|
|
|
|
if (line != 0)
|
|
|
|
|
fprintf_filtered (gdb_stdout, " %s\n", d->replacement);
|
|
|
|
|
else
|
|
|
|
|
fprintf_filtered (gdb_stdout, "=%s\n", d->replacement);
|
2002-05-16 23:15:53 +02:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
fprintf_filtered (gdb_stdout,
|
|
|
|
|
"The symbol `%s' has no definition as a C/C++"
|
|
|
|
|
" preprocessor macro\n"
|
|
|
|
|
"at ", name);
|
|
|
|
|
show_pp_source_pos (gdb_stdout, ms->file, ms->line);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
do_cleanups (cleanup_chain);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* User-defined macros. */
|
|
|
|
|
|
2008-07-18 22:55:33 +02:00
|
|
|
|
static void
|
|
|
|
|
skip_ws (char **expp)
|
|
|
|
|
{
|
|
|
|
|
while (macro_is_whitespace (**expp))
|
|
|
|
|
++*expp;
|
|
|
|
|
}
|
|
|
|
|
|
2008-09-27 23:40:49 +02:00
|
|
|
|
/* Try to find the bounds of an identifier. If an identifier is
|
|
|
|
|
found, returns a newly allocated string; otherwise returns NULL.
|
|
|
|
|
EXPP is a pointer to an input string; it is updated to point to the
|
|
|
|
|
text following the identifier. If IS_PARAMETER is true, this
|
|
|
|
|
function will also allow "..." forms as used in varargs macro
|
|
|
|
|
parameters. */
|
|
|
|
|
|
2008-07-18 22:55:33 +02:00
|
|
|
|
static char *
|
2008-09-27 23:40:49 +02:00
|
|
|
|
extract_identifier (char **expp, int is_parameter)
|
2008-07-18 22:55:33 +02:00
|
|
|
|
{
|
|
|
|
|
char *result;
|
|
|
|
|
char *p = *expp;
|
|
|
|
|
unsigned int len;
|
2008-09-27 23:40:49 +02:00
|
|
|
|
|
|
|
|
|
if (is_parameter && !strncmp (p, "...", 3))
|
|
|
|
|
{
|
|
|
|
|
/* Ok. */
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (! *p || ! macro_is_identifier_nondigit (*p))
|
|
|
|
|
return NULL;
|
|
|
|
|
for (++p;
|
|
|
|
|
*p && (macro_is_identifier_nondigit (*p) || macro_is_digit (*p));
|
|
|
|
|
++p)
|
|
|
|
|
;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (is_parameter && !strncmp (p, "...", 3))
|
|
|
|
|
p += 3;
|
|
|
|
|
|
2008-07-18 22:55:33 +02:00
|
|
|
|
len = p - *expp;
|
|
|
|
|
result = (char *) xmalloc (len + 1);
|
|
|
|
|
memcpy (result, *expp, len);
|
|
|
|
|
result[len] = '\0';
|
|
|
|
|
*expp += len;
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Helper function to clean up a temporarily-constructed macro object.
|
|
|
|
|
This assumes that the contents were all allocated with xmalloc. */
|
|
|
|
|
static void
|
|
|
|
|
free_macro_definition_ptr (void *ptr)
|
|
|
|
|
{
|
|
|
|
|
int i;
|
|
|
|
|
struct macro_definition *loc = (struct macro_definition *) ptr;
|
2010-05-16 02:18:02 +02:00
|
|
|
|
|
2008-07-18 22:55:33 +02:00
|
|
|
|
for (i = 0; i < loc->argc; ++i)
|
|
|
|
|
xfree ((char *) loc->argv[i]);
|
|
|
|
|
xfree ((char *) loc->argv);
|
|
|
|
|
/* Note that the 'replacement' field is not allocated. */
|
|
|
|
|
}
|
2002-05-16 23:15:53 +02:00
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
macro_define_command (char *exp, int from_tty)
|
|
|
|
|
{
|
2008-07-18 22:55:33 +02:00
|
|
|
|
struct macro_definition new_macro;
|
|
|
|
|
char *name = NULL;
|
2008-08-14 20:03:22 +02:00
|
|
|
|
struct cleanup *cleanup_chain;
|
|
|
|
|
|
|
|
|
|
if (!exp)
|
|
|
|
|
error (_("usage: macro define NAME[(ARGUMENT-LIST)] [REPLACEMENT-LIST]"));
|
|
|
|
|
|
|
|
|
|
cleanup_chain = make_cleanup (free_macro_definition_ptr, &new_macro);
|
2008-07-18 22:55:33 +02:00
|
|
|
|
make_cleanup (free_current_contents, &name);
|
|
|
|
|
|
|
|
|
|
memset (&new_macro, 0, sizeof (struct macro_definition));
|
|
|
|
|
|
|
|
|
|
skip_ws (&exp);
|
2008-09-27 23:40:49 +02:00
|
|
|
|
name = extract_identifier (&exp, 0);
|
2008-07-18 22:55:33 +02:00
|
|
|
|
if (! name)
|
|
|
|
|
error (_("Invalid macro name."));
|
|
|
|
|
if (*exp == '(')
|
|
|
|
|
{
|
|
|
|
|
/* Function-like macro. */
|
|
|
|
|
int alloced = 5;
|
|
|
|
|
char **argv = (char **) xmalloc (alloced * sizeof (char *));
|
|
|
|
|
|
|
|
|
|
new_macro.kind = macro_function_like;
|
|
|
|
|
new_macro.argc = 0;
|
|
|
|
|
new_macro.argv = (const char * const *) argv;
|
|
|
|
|
|
|
|
|
|
/* Skip the '(' and whitespace. */
|
|
|
|
|
++exp;
|
|
|
|
|
skip_ws (&exp);
|
|
|
|
|
|
|
|
|
|
while (*exp != ')')
|
|
|
|
|
{
|
|
|
|
|
int i;
|
|
|
|
|
|
|
|
|
|
if (new_macro.argc == alloced)
|
|
|
|
|
{
|
|
|
|
|
alloced *= 2;
|
|
|
|
|
argv = (char **) xrealloc (argv, alloced * sizeof (char *));
|
|
|
|
|
/* Must update new_macro as well... */
|
|
|
|
|
new_macro.argv = (const char * const *) argv;
|
|
|
|
|
}
|
2008-09-27 23:40:49 +02:00
|
|
|
|
argv[new_macro.argc] = extract_identifier (&exp, 1);
|
2008-07-18 22:55:33 +02:00
|
|
|
|
if (! argv[new_macro.argc])
|
|
|
|
|
error (_("Macro is missing an argument."));
|
|
|
|
|
++new_macro.argc;
|
|
|
|
|
|
|
|
|
|
for (i = new_macro.argc - 2; i >= 0; --i)
|
|
|
|
|
{
|
|
|
|
|
if (! strcmp (argv[i], argv[new_macro.argc - 1]))
|
|
|
|
|
error (_("Two macro arguments with identical names."));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
skip_ws (&exp);
|
|
|
|
|
if (*exp == ',')
|
|
|
|
|
{
|
|
|
|
|
++exp;
|
|
|
|
|
skip_ws (&exp);
|
|
|
|
|
}
|
|
|
|
|
else if (*exp != ')')
|
|
|
|
|
error (_("',' or ')' expected at end of macro arguments."));
|
|
|
|
|
}
|
|
|
|
|
/* Skip the closing paren. */
|
|
|
|
|
++exp;
|
2008-12-12 17:58:46 +01:00
|
|
|
|
skip_ws (&exp);
|
2008-07-18 22:55:33 +02:00
|
|
|
|
|
|
|
|
|
macro_define_function (macro_main (macro_user_macros), -1, name,
|
|
|
|
|
new_macro.argc, (const char **) new_macro.argv,
|
|
|
|
|
exp);
|
|
|
|
|
}
|
|
|
|
|
else
|
2008-12-12 17:58:46 +01:00
|
|
|
|
{
|
|
|
|
|
skip_ws (&exp);
|
|
|
|
|
macro_define_object (macro_main (macro_user_macros), -1, name, exp);
|
|
|
|
|
}
|
2008-07-18 22:55:33 +02:00
|
|
|
|
|
|
|
|
|
do_cleanups (cleanup_chain);
|
2002-05-16 23:15:53 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
macro_undef_command (char *exp, int from_tty)
|
|
|
|
|
{
|
2008-07-18 22:55:33 +02:00
|
|
|
|
char *name;
|
2008-08-14 20:03:22 +02:00
|
|
|
|
|
|
|
|
|
if (!exp)
|
|
|
|
|
error (_("usage: macro undef NAME"));
|
|
|
|
|
|
2008-07-18 22:55:33 +02:00
|
|
|
|
skip_ws (&exp);
|
2008-09-27 23:40:49 +02:00
|
|
|
|
name = extract_identifier (&exp, 0);
|
2008-07-18 22:55:33 +02:00
|
|
|
|
if (! name)
|
|
|
|
|
error (_("Invalid macro name."));
|
|
|
|
|
macro_undef (macro_main (macro_user_macros), -1, name);
|
|
|
|
|
xfree (name);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
2008-09-30 19:21:28 +02:00
|
|
|
|
print_one_macro (const char *name, const struct macro_definition *macro,
|
|
|
|
|
void *ignore)
|
2008-07-18 22:55:33 +02:00
|
|
|
|
{
|
|
|
|
|
fprintf_filtered (gdb_stdout, "macro define %s", name);
|
|
|
|
|
if (macro->kind == macro_function_like)
|
|
|
|
|
{
|
|
|
|
|
int i;
|
2010-05-16 02:18:02 +02:00
|
|
|
|
|
2008-07-18 22:55:33 +02:00
|
|
|
|
fprintf_filtered (gdb_stdout, "(");
|
|
|
|
|
for (i = 0; i < macro->argc; ++i)
|
|
|
|
|
fprintf_filtered (gdb_stdout, "%s%s", (i > 0) ? ", " : "",
|
|
|
|
|
macro->argv[i]);
|
|
|
|
|
fprintf_filtered (gdb_stdout, ")");
|
|
|
|
|
}
|
2008-12-12 17:58:46 +01:00
|
|
|
|
fprintf_filtered (gdb_stdout, " %s\n", macro->replacement);
|
2002-05-16 23:15:53 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
macro_list_command (char *exp, int from_tty)
|
|
|
|
|
{
|
2008-09-30 19:21:28 +02:00
|
|
|
|
macro_for_each (macro_user_macros, print_one_macro, NULL);
|
2002-05-16 23:15:53 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Initializing the `macrocmd' module. */
|
|
|
|
|
|
2003-06-11 15:16:30 +02:00
|
|
|
|
extern initialize_file_ftype _initialize_macrocmd; /* -Wmissing-prototypes */
|
2003-06-08 Andrew Cagney <cagney@redhat.com>
* acinclude.m4 (gcc_AC_CHECK_DECL, (gcc_AC_CHECK_DECL): Stolen
from GCC's acinclude.m4.
* configure.in: Check for getopt's delcaration.
* aclocal.m4, config.in, configure: Re-generate.
* main.c (error_init): Delete declaration.
* defs.h (error_init): Declare.
* rs6000-tdep.c (rs6000_fetch_pointer_argument): Make static.
(rs6000_convert_from_func_ptr_addr): Make static.
(_initialize_rs6000_tdep): Add declaration.
* cli/cli-cmds.c (dont_repeat): Delete declaration.
(show_commands, set_verbose, show_history): Delete declaration.
* top.h (set_verbose): Add declaration.
(show_history, set_history, show_commands): Add declaration.
(do_restore_instream_cleanup): Add declaration.
* objc-lang.c (specialcmp): Make static.
(print_object_command): Make static.
(find_objc_msgsend): Make static.
(find_objc_msgcall_submethod_helper): Make static.
(find_objc_msgcall_submethod): Make static.
(_initialize_objc_language): Add declaration.
(find_implementation_from_class): Make static.
(find_implementation): Make static.
* objc-exp.y (yylex): Delete lookup_struct_typedef declaration.
* objc-lang.h (lookup_struct_typedef): Add declaration.
* cli/cli-interp.c (_initialize_cli_interp): Add declaration.
* cli/cli-script.c (clear_hook_in_cleanup): Make static.
(do_restore_user_call_depth): Make static.
(do_restore_instream_cleanup): Delete declaration.
(dont_repeat): Delete declaration.
* cli/cli-decode.c (add_abbrev_cmd): Delete function.
* cli/cli-dump.c (_initialize_cli_dump): Add declaration.
* reggroups.c (_initialize_reggroup): Add declaration.
* cp-support.c (_initialize_cp_support): Add declaration.
* cp-abi.c (_initialize_cp_abi): Add declaration.
* hpacc-abi.c (_initialize_hpacc_abi): Add declaration.
* gnu-v3-abi.c (gnuv3_baseclass_offset): Make static.
(_initialize_gnu_v3_abi): Add declaration.
* gnu-v2-abi.c (gnuv2_value_rtti_type): Make static.
(_initialize_gnu_v2_abi): Add declaration.
* frame-base.c (_initialize_frame_base): Add declaration.
* doublest.c (floatformat_from_length): Make static.
* frame-unwind.c (_initialize_frame_unwind): Add declaration.
* frame.c (create_sentinel_frame): Make static.
(_initialize_frame): Add declaration.
* top.c (do_catch_errors): Make static.
(gdb_rl_operate_and_get_next_completion): Make static.
* typeprint.c: Include "typeprint.h".
* sentinel-frame.c (sentinel_frame_prev_register): Make static.
(sentinel_frame_this_id): Make static.
* p-valprint.c (_initialize_pascal_valprint): Add declaration.
* ui-out.c (make_cleanup_ui_out_begin_end): Delete function.
* dwarf2-frame.c (dwarf2_frame_cache): Make static.
* p-exp.y (push_current_type, pop_current_type): ISO C declaration.
* dwarf2expr.h (dwarf_expr_context): ISO C declaration.
* maint.c (maintenance_print_architecture): Make static.
* signals/signals.c (_initialize_signals): Add declaration.
* std-regs.c (_initialize_frame_reg): Add declaration.
* jv-exp.y (push_variable): ISO C definition.
(push_qualified_expression_name): Ditto.
* memattr.c (_initialize_mem): Add declaration.
* remote.c (remote_check_watch_resources): Make static.
(remote_stopped_by_watchpoint): Make static.
(remote_stopped_data_address): Make static.
* d10v-tdep.c (nr_dmap_regs): Make static.
(a0_regnum): Make static.
(d10v_frame_unwind_cache): Make static.
(d10v_frame_p): Make static.
* osabi.c (show_osabi): Make static.
(_initialize_gdb_osabi): Add extern declaration.
* gdbtypes.c (make_qualified_type): Make static.
(safe_parse_type): Make static.
* macrocmd.c (_initialize_macrocmd): Add extern declaration.
* macrotab.c (macro_bcache_free): Make static.
* interps.c (interp_set_quiet): Make static.
(interpreter_exec_cmd): Make static.
* stack.h (select_frame_command): New file.
* stack.c: Include "stack.h".
(select_frame_command_wrapper): Delete function.
(select_frame_command): Make global.
* infcall.c: Include "infcall.h".
* linespec.c: Include "linespec.h".
* symfile.c (sections_overlap): Make static.
* cp-support.h (cp_initialize_namespace): ISO C declaration.
* charset.c (_initialize_charset): Add missing prototype.
* regcache.c (init_legacy_regcache_descr): Make static.
(do_regcache_xfree): Make static.
(regcache_xfer_part): Make static.
(_initialize_regcache): Add missing prototype.
* breakpoint.c (parse_breakpoint_sals): Make static.
(breakpoint_sals_to_pc): Make static.
* interps.h (clear_interpreter_hooks): ISO C declaration.
* Makefile.in (stack_h): Define.
(stack.o, typeprint.o, mi-main.o): Update dependencies.
(mi-cmd-stack.o, infcall.o, linespec.o): Update dependencies.
Index: mi/ChangeLog
2003-06-08 Andrew Cagney <cagney@redhat.com>
* mi-parse.c (_initialize_mi_parse): Delete function.
* mi-main.c: Include "mi-main.h".
* mi-interp.c (_initialize_mi_interp): Add declaration.
* mi-cmd-stack.c: Include "stack.h".
(select_frame_command_wrapper): Delete extern declaration.
(mi_cmd_stack_select_frame): Replace select_frame_command_wrapper
with select_frame_command.
2003-06-08 20:27:14 +02:00
|
|
|
|
|
2002-05-16 23:15:53 +02:00
|
|
|
|
void
|
|
|
|
|
_initialize_macrocmd (void)
|
|
|
|
|
{
|
|
|
|
|
/* We introduce a new command prefix, `macro', under which we'll put
|
|
|
|
|
the various commands for working with preprocessor macros. */
|
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 16:49:28 +01:00
|
|
|
|
add_prefix_cmd ("macro", class_info, macro_command,
|
|
|
|
|
_("Prefix for commands dealing with C preprocessor macros."),
|
|
|
|
|
¯olist, "macro ", 0, &cmdlist);
|
2002-05-16 23:15:53 +02:00
|
|
|
|
|
2005-02-14 Andrew Cagney <cagney@gnu.org>
Mark up add_cmd.
* arch-utils.c, avr-tdep.c, breakpoint.c, corefile.c: Update.
* cp-abi.c, cp-namespace.c, cp-support.c, dummy-frame.c: Update.
* exec.c, gnu-nat.c, go32-nat.c, hppa-tdep.c, infcmd.c: Update.
* infrun.c, interps.c, macrocmd.c, maint.c, memattr.c: Update.
* mips-tdep.c, ocd.c, osabi.c, printcmd.c, regcache.c: Update.
* reggroups.c, remote-fileio.c, remote-rdi.c, remote.c: Update.
* sol-thread.c, source.c, stack.c, symfile-mem.c: Update.
* symfile.c, thread.c, tracepoint.c, valprint.c, value.c: Update.
* win32-nat.c, cli/cli-cmds.c, cli/cli-dump.c: Update.
* cli/cli-logging.c, tui/tui-regs.c: Update.
2005-02-14 19:10:11 +01:00
|
|
|
|
add_cmd ("expand", no_class, macro_expand_command, _("\
|
|
|
|
|
Fully expand any C/C++ preprocessor macro invocations in EXPRESSION.\n\
|
|
|
|
|
Show the expanded expression."),
|
|
|
|
|
¯olist);
|
2002-05-16 23:15:53 +02:00
|
|
|
|
add_alias_cmd ("exp", "expand", no_class, 1, ¯olist);
|
2005-02-14 Andrew Cagney <cagney@gnu.org>
Mark up add_cmd.
* arch-utils.c, avr-tdep.c, breakpoint.c, corefile.c: Update.
* cp-abi.c, cp-namespace.c, cp-support.c, dummy-frame.c: Update.
* exec.c, gnu-nat.c, go32-nat.c, hppa-tdep.c, infcmd.c: Update.
* infrun.c, interps.c, macrocmd.c, maint.c, memattr.c: Update.
* mips-tdep.c, ocd.c, osabi.c, printcmd.c, regcache.c: Update.
* reggroups.c, remote-fileio.c, remote-rdi.c, remote.c: Update.
* sol-thread.c, source.c, stack.c, symfile-mem.c: Update.
* symfile.c, thread.c, tracepoint.c, valprint.c, value.c: Update.
* win32-nat.c, cli/cli-cmds.c, cli/cli-dump.c: Update.
* cli/cli-logging.c, tui/tui-regs.c: Update.
2005-02-14 19:10:11 +01:00
|
|
|
|
add_cmd ("expand-once", no_class, macro_expand_once_command, _("\
|
|
|
|
|
Expand C/C++ preprocessor macro invocations appearing directly in EXPRESSION.\n\
|
|
|
|
|
Show the expanded expression.\n\
|
|
|
|
|
\n\
|
|
|
|
|
This command differs from `macro expand' in that it only expands macro\n\
|
|
|
|
|
invocations that appear directly in EXPRESSION; if expanding a macro\n\
|
|
|
|
|
introduces further macro invocations, those are left unexpanded.\n\
|
|
|
|
|
\n\
|
|
|
|
|
`macro expand-once' helps you see how a particular macro expands,\n\
|
|
|
|
|
whereas `macro expand' shows you how all the macros involved in an\n\
|
|
|
|
|
expression work together to yield a pre-processed expression."),
|
|
|
|
|
¯olist);
|
2002-05-16 23:15:53 +02:00
|
|
|
|
add_alias_cmd ("exp1", "expand-once", no_class, 1, ¯olist);
|
|
|
|
|
|
2005-02-14 Andrew Cagney <cagney@gnu.org>
Mark up add_cmd.
* arch-utils.c, avr-tdep.c, breakpoint.c, corefile.c: Update.
* cp-abi.c, cp-namespace.c, cp-support.c, dummy-frame.c: Update.
* exec.c, gnu-nat.c, go32-nat.c, hppa-tdep.c, infcmd.c: Update.
* infrun.c, interps.c, macrocmd.c, maint.c, memattr.c: Update.
* mips-tdep.c, ocd.c, osabi.c, printcmd.c, regcache.c: Update.
* reggroups.c, remote-fileio.c, remote-rdi.c, remote.c: Update.
* sol-thread.c, source.c, stack.c, symfile-mem.c: Update.
* symfile.c, thread.c, tracepoint.c, valprint.c, value.c: Update.
* win32-nat.c, cli/cli-cmds.c, cli/cli-dump.c: Update.
* cli/cli-logging.c, tui/tui-regs.c: Update.
2005-02-14 19:10:11 +01:00
|
|
|
|
add_cmd ("macro", no_class, info_macro_command,
|
|
|
|
|
_("Show the definition of MACRO, and its source location."),
|
|
|
|
|
&infolist);
|
|
|
|
|
|
|
|
|
|
add_cmd ("define", no_class, macro_define_command, _("\
|
|
|
|
|
Define a new C/C++ preprocessor macro.\n\
|
|
|
|
|
The GDB command `macro define DEFINITION' is equivalent to placing a\n\
|
|
|
|
|
preprocessor directive of the form `#define DEFINITION' such that the\n\
|
|
|
|
|
definition is visible in all the inferior's source files.\n\
|
|
|
|
|
For example:\n\
|
|
|
|
|
(gdb) macro define PI (3.1415926)\n\
|
|
|
|
|
(gdb) macro define MIN(x,y) ((x) < (y) ? (x) : (y))"),
|
|
|
|
|
¯olist);
|
|
|
|
|
|
|
|
|
|
add_cmd ("undef", no_class, macro_undef_command, _("\
|
|
|
|
|
Remove the definition of the C/C++ preprocessor macro with the given name."),
|
|
|
|
|
¯olist);
|
|
|
|
|
|
|
|
|
|
add_cmd ("list", no_class, macro_list_command,
|
|
|
|
|
_("List all the macros defined using the `macro define' command."),
|
|
|
|
|
¯olist);
|
2002-05-16 23:15:53 +02:00
|
|
|
|
}
|