2002-05-16 23:15:53 +02:00
|
|
|
|
/* C preprocessor macro expansion commands for GDB.
|
2015-01-01 10:32:14 +01:00
|
|
|
|
Copyright (C) 2002-2015 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"
|
2011-11-12 18:01:12 +01:00
|
|
|
|
#include "cli/cli-utils.h"
|
2002-05-16 23:15:53 +02:00
|
|
|
|
#include "command.h"
|
|
|
|
|
#include "gdbcmd.h"
|
2012-06-30 00:46:46 +02:00
|
|
|
|
#include "linespec.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");
|
make calls to help_list use enumerator
Currently there are many calls to help_list that pass the constant -1
as the "class" value. However, the parameter is declared as being of
type enum command_class, and uses of the constant violate this
abstraction.
This patch fixes the error everywhere it occurs in the gdb sources.
Tested by rebuilding.
2014-06-13 Tom Tromey <tromey@redhat.com>
* cp-support.c (maint_cplus_command): Pass all_commands, not -1,
to help_list.
* guile/guile.c (info_guile_command): Pass all_commands, not -1,
to help_list.
* tui/tui-win.c (tui_command): Pass all_commands, not -1, to
help_list.
* tui/tui-regs.c (tui_reg_command): Pass all_commands, not -1, to
help_list.Pass all_commands, not -1, to help_list.
* cli/cli-dump.c (dump_command, append_command)
(srec_dump_command, ihex_dump_command, tekhex_dump_command)
(binary_dump_command, binary_append_command): Pass all_commands,
not -1, to help_list.
* cli/cli-cmds.c (info_command, set_debug): Pass all_commands, not
-1, to help_list.
* valprint.c (set_print, set_print_raw): Pass all_commands, not
-1, to help_list.
* typeprint.c (set_print_type): Pass all_commands, not -1, to
help_list.
* top.c (set_history): Pass all_commands, not -1, to help_list.
* target-descriptions.c (set_tdesc_cmd, unset_tdesc_cmd): Pass
all_commands, not -1, to help_list.
* symfile.c (overlay_command): Pass all_commands, not -1, to
help_list.
* spu-tdep.c (info_spu_command): Pass all_commands, not -1, to
help_list.
* serial.c (serial_set_cmd): Pass all_commands, not -1, to
help_list.
* ser-tcp.c (set_tcp_cmd, show_tcp_cmd): Pass all_commands, not
-1, to help_list.
* remote.c (remote_command, set_remote_cmd): Pass all_commands,
not -1, to help_list.
* ravenscar-thread.c (set_ravenscar_command): Pass all_commands,
not -1, to help_list.
* maint.c (maintenance_command, maintenance_info_command)
(maintenance_print_command, maintenance_set_cmd): Pass
all_commands, not -1, to help_list.
* macrocmd.c (macro_command): Pass all_commands, not -1, to
help_list.
* language.c (set_check): Pass all_commands, not -1, to help_list.
* infcmd.c (unset_command): Pass all_commands, not -1, to
help_list.
* frame.c (set_backtrace_cmd): Pass all_commands, not -1, to
help_list.
* dwarf2read.c (set_dwarf2_cmd): Pass all_commands, not -1, to
help_list.
* dcache.c (set_dcache_command): Pass all_commands, not -1, to
help_list.
* breakpoint.c (save_command): Pass all_commands, not -1, to
help_list.
* ada-lang.c (maint_set_ada_cmd, set_ada_command): Pass
all_commands, not -1, to help_list.
2014-06-05 16:25:00 +02:00
|
|
|
|
help_list (macrolist, "macro ", all_commands, gdb_stdout);
|
2002-05-16 23:15:53 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Macro expansion commands. */
|
|
|
|
|
|
|
|
|
|
|
2011-11-12 18:01:12 +01:00
|
|
|
|
/* Prints an informational message regarding the lack of macro information. */
|
2013-07-01 21:52:32 +02:00
|
|
|
|
static void
|
|
|
|
|
macro_inform_no_debuginfo (void)
|
2011-11-12 18:01:12 +01:00
|
|
|
|
{
|
2013-01-11 22:34:29 +01:00
|
|
|
|
puts_filtered ("GDB has no preprocessor macro information for that code.\n");
|
2011-11-12 18:01:12 +01:00
|
|
|
|
}
|
|
|
|
|
|
2002-05-16 23:15:53 +02:00
|
|
|
|
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
|
2011-11-12 18:01:12 +01:00
|
|
|
|
macro_inform_no_debuginfo ();
|
2002-05-16 23:15:53 +02:00
|
|
|
|
|
|
|
|
|
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
|
2011-11-12 18:01:12 +01:00
|
|
|
|
macro_inform_no_debuginfo ();
|
2002-05-16 23:15:53 +02:00
|
|
|
|
|
|
|
|
|
do_cleanups (cleanup_chain);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2011-07-21 17:13:30 +02:00
|
|
|
|
/* Outputs the include path of a macro starting at FILE and LINE to STREAM.
|
2002-05-16 23:15:53 +02:00
|
|
|
|
|
2011-07-21 17:13:30 +02:00
|
|
|
|
Care should be taken that this function does not cause any lookups into
|
|
|
|
|
the splay tree so that it can be safely used while iterating. */
|
2002-05-16 23:15:53 +02:00
|
|
|
|
static void
|
|
|
|
|
show_pp_source_pos (struct ui_file *stream,
|
|
|
|
|
struct macro_source_file *file,
|
|
|
|
|
int line)
|
|
|
|
|
{
|
2013-02-03 17:25:56 +01:00
|
|
|
|
char *fullname;
|
|
|
|
|
|
|
|
|
|
fullname = macro_source_fullname (file);
|
|
|
|
|
fprintf_filtered (stream, "%s:%d\n", fullname, line);
|
|
|
|
|
xfree (fullname);
|
2002-05-16 23:15:53 +02:00
|
|
|
|
|
|
|
|
|
while (file->included_by)
|
|
|
|
|
{
|
2013-02-03 17:25:56 +01:00
|
|
|
|
fullname = macro_source_fullname (file->included_by);
|
|
|
|
|
fprintf_filtered (gdb_stdout, " included at %s:%d\n", fullname,
|
2002-05-16 23:15:53 +02:00
|
|
|
|
file->included_at_line);
|
2013-02-03 17:25:56 +01:00
|
|
|
|
xfree (fullname);
|
2002-05-16 23:15:53 +02:00
|
|
|
|
file = file->included_by;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2011-07-21 17:13:30 +02:00
|
|
|
|
/* Outputs a macro for human consumption, detailing the include path
|
|
|
|
|
and macro definition. NAME is the name of the macro.
|
|
|
|
|
D the definition. FILE the start of the include path, and LINE the
|
|
|
|
|
line number in FILE.
|
2002-05-16 23:15:53 +02:00
|
|
|
|
|
2011-07-21 17:13:30 +02:00
|
|
|
|
Care should be taken that this function does not cause any lookups into
|
|
|
|
|
the splay tree so that it can be safely used while iterating. */
|
2002-05-16 23:15:53 +02:00
|
|
|
|
static void
|
2011-07-21 17:13:30 +02:00
|
|
|
|
print_macro_definition (const char *name,
|
|
|
|
|
const struct macro_definition *d,
|
|
|
|
|
struct macro_source_file *file,
|
|
|
|
|
int line)
|
2002-05-16 23:15:53 +02:00
|
|
|
|
{
|
2014-05-14 21:31:10 +02:00
|
|
|
|
fprintf_filtered (gdb_stdout, "Defined at ");
|
|
|
|
|
show_pp_source_pos (gdb_stdout, file, line);
|
|
|
|
|
|
|
|
|
|
if (line != 0)
|
|
|
|
|
fprintf_filtered (gdb_stdout, "#define %s", name);
|
|
|
|
|
else
|
|
|
|
|
fprintf_filtered (gdb_stdout, "-D%s", name);
|
|
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (line != 0)
|
|
|
|
|
fprintf_filtered (gdb_stdout, " %s\n", d->replacement);
|
|
|
|
|
else
|
|
|
|
|
fprintf_filtered (gdb_stdout, "=%s\n", d->replacement);
|
2011-07-21 17:13:30 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* A callback function for usage with macro_for_each and friends.
|
|
|
|
|
If USER_DATA is null all macros will be printed.
|
|
|
|
|
Otherwise USER_DATA is considered to be a string, printing
|
|
|
|
|
only macros who's NAME matches USER_DATA. Other arguments are
|
|
|
|
|
routed to print_macro_definition. */
|
|
|
|
|
static void
|
|
|
|
|
print_macro_callback (const char *name, const struct macro_definition *macro,
|
|
|
|
|
struct macro_source_file *source, int line,
|
|
|
|
|
void *user_data)
|
|
|
|
|
{
|
|
|
|
|
if (! user_data || strcmp (user_data, name) == 0)
|
|
|
|
|
print_macro_definition (name, macro, source, line);
|
|
|
|
|
}
|
|
|
|
|
|
2011-11-12 18:01:12 +01:00
|
|
|
|
/* The implementation of the `info macro' command. */
|
2011-07-21 17:13:30 +02:00
|
|
|
|
static void
|
2011-11-12 18:01:12 +01:00
|
|
|
|
info_macro_command (char *args, int from_tty)
|
2011-07-21 17:13:30 +02:00
|
|
|
|
{
|
|
|
|
|
struct macro_scope *ms = NULL;
|
2011-11-12 18:01:12 +01:00
|
|
|
|
struct cleanup *cleanup_chain;
|
|
|
|
|
char *name;
|
|
|
|
|
int show_all_macros_named = 0;
|
|
|
|
|
char *arg_start = args;
|
|
|
|
|
int processing_args = 1;
|
|
|
|
|
|
|
|
|
|
while (processing_args
|
|
|
|
|
&& arg_start && *arg_start == '-' && *arg_start != '\0')
|
|
|
|
|
{
|
|
|
|
|
char *p = skip_to_space (arg_start);
|
|
|
|
|
|
|
|
|
|
if (strncmp (arg_start, "-a", p - arg_start) == 0
|
|
|
|
|
|| strncmp (arg_start, "-all", p - arg_start) == 0)
|
|
|
|
|
show_all_macros_named = 1;
|
|
|
|
|
else if (strncmp (arg_start, "--", p - arg_start) == 0)
|
|
|
|
|
/* Our macro support seems rather C specific but this would
|
|
|
|
|
seem necessary for languages allowing - in macro names.
|
|
|
|
|
e.g. Scheme's (defmacro ->foo () "bar\n") */
|
|
|
|
|
processing_args = 0;
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
/* Relies on modified 'args' not making it in to history */
|
|
|
|
|
*p = '\0';
|
|
|
|
|
error (_("Unrecognized option '%s' to info macro command. "
|
|
|
|
|
"Try \"help info macro\"."), arg_start);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
arg_start = skip_spaces (p);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
name = arg_start;
|
2011-07-21 17:13:30 +02:00
|
|
|
|
|
|
|
|
|
if (! name || ! *name)
|
2011-11-12 18:01:12 +01:00
|
|
|
|
error (_("You must follow the `info macro' command with the name"
|
|
|
|
|
" of the macro\n"
|
|
|
|
|
"whose definition you want to see."));
|
2011-07-21 17:13:30 +02:00
|
|
|
|
|
|
|
|
|
ms = default_macro_scope ();
|
2011-11-12 18:01:12 +01:00
|
|
|
|
cleanup_chain = make_cleanup (free_current_contents, &ms);
|
2011-07-21 17:13:30 +02:00
|
|
|
|
|
2011-11-12 18:01:12 +01:00
|
|
|
|
if (! ms)
|
|
|
|
|
macro_inform_no_debuginfo ();
|
|
|
|
|
else if (show_all_macros_named)
|
|
|
|
|
macro_for_each (ms->file->table, print_macro_callback, name);
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
struct macro_definition *d;
|
|
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
|
|
print_macro_definition (name, d, file, line);
|
|
|
|
|
}
|
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
}
|
2011-07-21 17:13:30 +02:00
|
|
|
|
|
|
|
|
|
do_cleanups (cleanup_chain);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Implementation of the "info macros" command. */
|
|
|
|
|
static void
|
|
|
|
|
info_macros_command (char *args, int from_tty)
|
|
|
|
|
{
|
|
|
|
|
struct macro_scope *ms = NULL;
|
|
|
|
|
struct cleanup *cleanup_chain = make_cleanup (free_current_contents, &ms);
|
|
|
|
|
|
|
|
|
|
if (args == NULL)
|
|
|
|
|
ms = default_macro_scope ();
|
|
|
|
|
else
|
|
|
|
|
{
|
2012-06-30 00:46:46 +02:00
|
|
|
|
struct symtabs_and_lines sals =
|
|
|
|
|
decode_line_with_current_source (args, 0);
|
2011-07-21 17:13:30 +02:00
|
|
|
|
|
|
|
|
|
if (sals.nelts)
|
|
|
|
|
ms = sal_macro_scope (sals.sals[0]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (! ms || ! ms->file || ! ms->file->table)
|
2011-11-12 18:01:12 +01:00
|
|
|
|
macro_inform_no_debuginfo ();
|
|
|
|
|
else
|
|
|
|
|
macro_for_each_in_scope (ms->file, ms->line, print_macro_callback, NULL);
|
2011-07-21 17:13:30 +02:00
|
|
|
|
|
|
|
|
|
do_cleanups (cleanup_chain);
|
|
|
|
|
}
|
2002-05-16 23:15:53 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* 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
|
|
|
|
|
2015-03-06 10:42:06 +01:00
|
|
|
|
if (is_parameter && startswith (p, "..."))
|
2008-09-27 23:40:49 +02:00
|
|
|
|
{
|
|
|
|
|
/* Ok. */
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (! *p || ! macro_is_identifier_nondigit (*p))
|
|
|
|
|
return NULL;
|
|
|
|
|
for (++p;
|
|
|
|
|
*p && (macro_is_identifier_nondigit (*p) || macro_is_digit (*p));
|
|
|
|
|
++p)
|
|
|
|
|
;
|
|
|
|
|
}
|
|
|
|
|
|
2015-03-06 10:42:06 +01:00
|
|
|
|
if (is_parameter && startswith (p, "..."))
|
2008-09-27 23:40:49 +02:00
|
|
|
|
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 *));
|
2011-01-09 04:20:33 +01:00
|
|
|
|
/* Must update new_macro as well... */
|
2008-07-18 22:55:33 +02:00
|
|
|
|
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,
|
2011-07-21 17:13:30 +02:00
|
|
|
|
struct macro_source_file *source, int line,
|
2008-09-30 19:21:28 +02:00
|
|
|
|
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,
|
2011-11-12 18:01:12 +01:00
|
|
|
|
_("Show the definition of MACRO, and it's source location.\n\
|
|
|
|
|
Usage: info macro [-a|-all] [--] MACRO\n\
|
|
|
|
|
Options: \n\
|
|
|
|
|
-a, --all Output all definitions of MACRO in the current compilation\
|
|
|
|
|
unit.\n\
|
|
|
|
|
-- Specify the end of arguments and the beginning of the MACRO."),
|
|
|
|
|
|
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
|
|
|
|
&infolist);
|
|
|
|
|
|
2011-07-21 17:13:30 +02:00
|
|
|
|
add_cmd ("macros", no_class, info_macros_command,
|
|
|
|
|
_("Show the definitions of all macros at LINESPEC, or the current \
|
|
|
|
|
source location.\n\
|
|
|
|
|
Usage: info macros [LINESPEC]"),
|
|
|
|
|
&infolist);
|
|
|
|
|
|
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 ("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
|
|
|
|
}
|