Commit Graph

474 Commits

Author SHA1 Message Date
Joel Brobecker ecd75fc8ee Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
Joel Brobecker 8a48ac9579 wrong dimension found in ada-lang.c:ada_array_bound_from_type
This function has the following code:

  elt_type = type;
  for (i = n; i > 1; i--)
    elt_type = TYPE_TARGET_TYPE (type);

For multi-dimension arrays, the code above tries to find the array
type corresponding to the dimension we're trying to inspect.
The problem is that, past the second dimension, the loop does
nothing other than repeat the first iteration. There is a little
thinko where it got the TYPE_TARGET_TYPE of TYPE instead of ELT_TYPE!

To my surprise, I was unable to produce an Ada exemple that demonstrated
the problem.  That's because the examples I created all trigger a parallel
___XA type which we then use in place of the ELT_TYPE in order to
determine the bounds - see the code that immediately follows our
loop above:

    index_type_desc = ada_find_parallel_type (type, "___XA");
    ada_fixup_array_indexes_type (index_type_desc);
    if (index_type_desc != NULL)
    [...]

So, in order to avoid depending on an Ada example where the compiler
can potentially decide one way or the other, I decided to use an
artificial example, written in C. With ...

  int multi[1][2][3];

... forcing the language to Ada, and trying to print the 'last,
we get:

    (gdb) p multi'last(1)
    $1 = 0
    (gdb) p multi'last(2)
    $2 = 1
    (gdb) p multi'last(3)
    $3 = 1   <<<---  This should be 2!

Additionally, I noticed that a couple of check_typedef's were missing.
This patch adds them. And since the variable in question only gets
used within an "else" block, I moved the variable declaration and
use inside that block - making it clear what the scope of the variable
is.

gdb/ChangeLog:

        * ada-lang.c (ada_array_bound_from_type): Move the declaration
        and assignment of variable "elt_type" inside the else block
        where it is used.  Add two missing check_typedef calls.
        Fix bug where we got TYPE's TYPE_TARGET_TYPE, where in fact
        we really wanted to get ELT_TYPE's TYPE_TARGET_TYPE.

gdb/testsuite/ChangeLog:

        * gdb.ada/arraydim: New testcase.
2013-12-13 09:55:24 +01:00
Joel Brobecker fb5e3d5c69 Small style violation fix in ada_array_bound_from_type
gdb/ChangeLog:

        * ada-lang.c (ada_array_bound_from_type): Remove unwanted space
        between 'struct type *' and 'arr_type'.
2013-12-13 09:48:35 +01:00
Joel Brobecker 849f2b52ec crash evaluating bogus exception condition expression (sparc-solaris)
With a program raising an exception, trying to debug that program
in GDB/MI mode can yield a crash:

    % gdb -i=mi foo
    (gdb)
    -catch-exception -e "Program_Error"
    ^done,bkptno="2",bkpt={number="2",type="breakpoint",[...]
    (gdb)
    -exec-continue
    ^running
    *running,thread-id="all"
    (gdb)
    =library-loaded,id=[...]
    &"warning: failed to reevaluate internal exception condition for catchpoint 2: Error in expression, near `'.\n"
    zsh: 22956 bus error (core dumped)  gdb -q -i=mi foo

The problem is triggered by a problem in the compiler which causes
EXP in the following TRY_CATCH block to change unexpectedly when
parse_exp_1 throws an error :

   |      TRY_CATCH (e, RETURN_MASK_ERROR)
   |        {
   |          exp = parse_exp_1 (&s, bl->address,
   |                             block_for_pc (bl->address), 0);
   |        }

In ada-lang.c:create_excep_cond_exprs, EXP is initialized to NULL,
and is expected to remain NULL if parse_exp_1 throws.  Instead,
its value gets changed to something invalid.  This later crashes
the debugger, when trying to evaluate the bogus expression.

This patch works around the issue by simply forcing EXP back to NULL
when an exception was thrown. A comment explaining why, and the sort
of timeline we're looking at for a fix, is also added.

gdb/ChangeLog:

        * ada-lang.c (create_excep_cond_exprs): Force EXP to NULL
        when parse_exp_1 threw an error.  Add comment.
2013-12-03 15:42:48 +04:00
Tom Tromey 53ce3c3929 remove gdb_stat.h
This patch is purely mechanical.  It removes gdb_stat.h and changes
the code to use sys/stat.h.

2013-11-18  Tom Tromey  <tromey@redhat.com>

	* common/gdb_stat.h: Remove.
	* ada-lang.c: Use sys/stat.h, not gdb_stat.h.
	* common/filestuff.c: Use sys/stat.h, not gdb_stat.h.
	* common/linux-osdata.c: Use sys/stat.h, not gdb_stat.h.
	* corefile.c: Use sys/stat.h, not gdb_stat.h.
	* ctf.c: Use sys/stat.h, not gdb_stat.h.
	* darwin-nat.c: Use sys/stat.h, not gdb_stat.h.
	* dbxread.c: Use sys/stat.h, not gdb_stat.h.
	* dwarf2read.c: Use sys/stat.h, not gdb_stat.h.
	* exec.c: Use sys/stat.h, not gdb_stat.h.
	* gdbserver/linux-low.c: Use sys/stat.h, not gdb_stat.h.
	* gdbserver/remote-utils.c: Use sys/stat.h, not gdb_stat.h.
	* inf-child.c: Use sys/stat.h, not gdb_stat.h.
	* jit.c: Use sys/stat.h, not gdb_stat.h.
	* linux-nat.c: Use sys/stat.h, not gdb_stat.h.
	* m68klinux-nat.c: Use sys/stat.h, not gdb_stat.h.
	* main.c: Use sys/stat.h, not gdb_stat.h.
	* mdebugread.c: Use sys/stat.h, not gdb_stat.h.
	* mi/mi-cmd-env.c: Use sys/stat.h, not gdb_stat.h.
	* nto-tdep.c: Use sys/stat.h, not gdb_stat.h.
	* objfiles.c: Use sys/stat.h, not gdb_stat.h.
	* procfs.c: Use sys/stat.h, not gdb_stat.h.
	* remote-fileio.c: Use sys/stat.h, not gdb_stat.h.
	* remote-mips.c: Use sys/stat.h, not gdb_stat.h.
	* remote.c: Use sys/stat.h, not gdb_stat.h.
	* rs6000-nat.c: Use sys/stat.h, not gdb_stat.h.
	* sol-thread.c: Use sys/stat.h, not gdb_stat.h.
	* solib-spu.c: Use sys/stat.h, not gdb_stat.h.
	* source.c: Use sys/stat.h, not gdb_stat.h.
	* symfile.c: Use sys/stat.h, not gdb_stat.h.
	* symmisc.c: Use sys/stat.h, not gdb_stat.h.
	* symtab.c: Use sys/stat.h, not gdb_stat.h.
	* top.c: Use sys/stat.h, not gdb_stat.h.
	* xcoffread.c: Use sys/stat.h, not gdb_stat.h.
2013-11-18 13:29:02 -07:00
Tom Tromey 0e9f083f4c remove gdb_string.h
This removes gdb_string.h.  This patch is purely mechanical.  I
created it by running the two commands:

    git rm common/gdb_string.h
    perl -pi -e's/"gdb_string.h"/<string.h>/;'  *.[chyl] */*.[chyl]

2013-11-18  Tom Tromey  <tromey@redhat.com>

	* common/gdb_string.h: Remove.
	* aarch64-tdep.c: Use string.h, not gdb_string.h.
	* ada-exp.y: Use string.h, not gdb_string.h.
	* ada-lang.c: Use string.h, not gdb_string.h.
	* ada-lex.l: Use string.h, not gdb_string.h.
	* ada-typeprint.c: Use string.h, not gdb_string.h.
	* ada-valprint.c: Use string.h, not gdb_string.h.
	* aix-thread.c: Use string.h, not gdb_string.h.
	* alpha-linux-tdep.c: Use string.h, not gdb_string.h.
	* alpha-mdebug-tdep.c: Use string.h, not gdb_string.h.
	* alpha-nat.c: Use string.h, not gdb_string.h.
	* alpha-osf1-tdep.c: Use string.h, not gdb_string.h.
	* alpha-tdep.c: Use string.h, not gdb_string.h.
	* alphanbsd-tdep.c: Use string.h, not gdb_string.h.
	* amd64-dicos-tdep.c: Use string.h, not gdb_string.h.
	* amd64-linux-nat.c: Use string.h, not gdb_string.h.
	* amd64-linux-tdep.c: Use string.h, not gdb_string.h.
	* amd64-nat.c: Use string.h, not gdb_string.h.
	* amd64-sol2-tdep.c: Use string.h, not gdb_string.h.
	* amd64fbsd-tdep.c: Use string.h, not gdb_string.h.
	* amd64obsd-tdep.c: Use string.h, not gdb_string.h.
	* arch-utils.c: Use string.h, not gdb_string.h.
	* arm-linux-nat.c: Use string.h, not gdb_string.h.
	* arm-linux-tdep.c: Use string.h, not gdb_string.h.
	* arm-tdep.c: Use string.h, not gdb_string.h.
	* arm-wince-tdep.c: Use string.h, not gdb_string.h.
	* armbsd-tdep.c: Use string.h, not gdb_string.h.
	* armnbsd-nat.c: Use string.h, not gdb_string.h.
	* armnbsd-tdep.c: Use string.h, not gdb_string.h.
	* armobsd-tdep.c: Use string.h, not gdb_string.h.
	* avr-tdep.c: Use string.h, not gdb_string.h.
	* ax-gdb.c: Use string.h, not gdb_string.h.
	* ax-general.c: Use string.h, not gdb_string.h.
	* bcache.c: Use string.h, not gdb_string.h.
	* bfin-tdep.c: Use string.h, not gdb_string.h.
	* breakpoint.c: Use string.h, not gdb_string.h.
	* build-id.c: Use string.h, not gdb_string.h.
	* buildsym.c: Use string.h, not gdb_string.h.
	* c-exp.y: Use string.h, not gdb_string.h.
	* c-lang.c: Use string.h, not gdb_string.h.
	* c-typeprint.c: Use string.h, not gdb_string.h.
	* c-valprint.c: Use string.h, not gdb_string.h.
	* charset.c: Use string.h, not gdb_string.h.
	* cli-out.c: Use string.h, not gdb_string.h.
	* cli/cli-cmds.c: Use string.h, not gdb_string.h.
	* cli/cli-decode.c: Use string.h, not gdb_string.h.
	* cli/cli-dump.c: Use string.h, not gdb_string.h.
	* cli/cli-interp.c: Use string.h, not gdb_string.h.
	* cli/cli-logging.c: Use string.h, not gdb_string.h.
	* cli/cli-script.c: Use string.h, not gdb_string.h.
	* cli/cli-setshow.c: Use string.h, not gdb_string.h.
	* cli/cli-utils.c: Use string.h, not gdb_string.h.
	* coffread.c: Use string.h, not gdb_string.h.
	* common/common-utils.c: Use string.h, not gdb_string.h.
	* common/filestuff.c: Use string.h, not gdb_string.h.
	* common/linux-procfs.c: Use string.h, not gdb_string.h.
	* common/linux-ptrace.c: Use string.h, not gdb_string.h.
	* common/signals.c: Use string.h, not gdb_string.h.
	* common/vec.h: Use string.h, not gdb_string.h.
	* core-regset.c: Use string.h, not gdb_string.h.
	* corefile.c: Use string.h, not gdb_string.h.
	* corelow.c: Use string.h, not gdb_string.h.
	* cp-abi.c: Use string.h, not gdb_string.h.
	* cp-support.c: Use string.h, not gdb_string.h.
	* cp-valprint.c: Use string.h, not gdb_string.h.
	* cris-tdep.c: Use string.h, not gdb_string.h.
	* d-lang.c: Use string.h, not gdb_string.h.
	* dbxread.c: Use string.h, not gdb_string.h.
	* dcache.c: Use string.h, not gdb_string.h.
	* demangle.c: Use string.h, not gdb_string.h.
	* dicos-tdep.c: Use string.h, not gdb_string.h.
	* disasm.c: Use string.h, not gdb_string.h.
	* doublest.c: Use string.h, not gdb_string.h.
	* dsrec.c: Use string.h, not gdb_string.h.
	* dummy-frame.c: Use string.h, not gdb_string.h.
	* dwarf2-frame.c: Use string.h, not gdb_string.h.
	* dwarf2loc.c: Use string.h, not gdb_string.h.
	* dwarf2read.c: Use string.h, not gdb_string.h.
	* elfread.c: Use string.h, not gdb_string.h.
	* environ.c: Use string.h, not gdb_string.h.
	* eval.c: Use string.h, not gdb_string.h.
	* event-loop.c: Use string.h, not gdb_string.h.
	* exceptions.c: Use string.h, not gdb_string.h.
	* exec.c: Use string.h, not gdb_string.h.
	* expprint.c: Use string.h, not gdb_string.h.
	* f-exp.y: Use string.h, not gdb_string.h.
	* f-lang.c: Use string.h, not gdb_string.h.
	* f-typeprint.c: Use string.h, not gdb_string.h.
	* f-valprint.c: Use string.h, not gdb_string.h.
	* fbsd-nat.c: Use string.h, not gdb_string.h.
	* findcmd.c: Use string.h, not gdb_string.h.
	* findvar.c: Use string.h, not gdb_string.h.
	* fork-child.c: Use string.h, not gdb_string.h.
	* frame.c: Use string.h, not gdb_string.h.
	* frv-linux-tdep.c: Use string.h, not gdb_string.h.
	* frv-tdep.c: Use string.h, not gdb_string.h.
	* gdb.c: Use string.h, not gdb_string.h.
	* gdb_bfd.c: Use string.h, not gdb_string.h.
	* gdbarch.c: Use string.h, not gdb_string.h.
	* gdbtypes.c: Use string.h, not gdb_string.h.
	* gnu-nat.c: Use string.h, not gdb_string.h.
	* gnu-v2-abi.c: Use string.h, not gdb_string.h.
	* gnu-v3-abi.c: Use string.h, not gdb_string.h.
	* go-exp.y: Use string.h, not gdb_string.h.
	* go-lang.c: Use string.h, not gdb_string.h.
	* go32-nat.c: Use string.h, not gdb_string.h.
	* hppa-hpux-tdep.c: Use string.h, not gdb_string.h.
	* hppa-linux-nat.c: Use string.h, not gdb_string.h.
	* hppanbsd-tdep.c: Use string.h, not gdb_string.h.
	* hppaobsd-tdep.c: Use string.h, not gdb_string.h.
	* i386-cygwin-tdep.c: Use string.h, not gdb_string.h.
	* i386-dicos-tdep.c: Use string.h, not gdb_string.h.
	* i386-linux-nat.c: Use string.h, not gdb_string.h.
	* i386-linux-tdep.c: Use string.h, not gdb_string.h.
	* i386-nto-tdep.c: Use string.h, not gdb_string.h.
	* i386-sol2-tdep.c: Use string.h, not gdb_string.h.
	* i386-tdep.c: Use string.h, not gdb_string.h.
	* i386bsd-tdep.c: Use string.h, not gdb_string.h.
	* i386gnu-nat.c: Use string.h, not gdb_string.h.
	* i386nbsd-tdep.c: Use string.h, not gdb_string.h.
	* i386obsd-tdep.c: Use string.h, not gdb_string.h.
	* i387-tdep.c: Use string.h, not gdb_string.h.
	* ia64-libunwind-tdep.c: Use string.h, not gdb_string.h.
	* ia64-linux-nat.c: Use string.h, not gdb_string.h.
	* inf-child.c: Use string.h, not gdb_string.h.
	* inf-ptrace.c: Use string.h, not gdb_string.h.
	* inf-ttrace.c: Use string.h, not gdb_string.h.
	* infcall.c: Use string.h, not gdb_string.h.
	* infcmd.c: Use string.h, not gdb_string.h.
	* inflow.c: Use string.h, not gdb_string.h.
	* infrun.c: Use string.h, not gdb_string.h.
	* interps.c: Use string.h, not gdb_string.h.
	* iq2000-tdep.c: Use string.h, not gdb_string.h.
	* irix5-nat.c: Use string.h, not gdb_string.h.
	* jv-exp.y: Use string.h, not gdb_string.h.
	* jv-lang.c: Use string.h, not gdb_string.h.
	* jv-typeprint.c: Use string.h, not gdb_string.h.
	* jv-valprint.c: Use string.h, not gdb_string.h.
	* language.c: Use string.h, not gdb_string.h.
	* linux-fork.c: Use string.h, not gdb_string.h.
	* linux-nat.c: Use string.h, not gdb_string.h.
	* lm32-tdep.c: Use string.h, not gdb_string.h.
	* m2-exp.y: Use string.h, not gdb_string.h.
	* m2-typeprint.c: Use string.h, not gdb_string.h.
	* m32c-tdep.c: Use string.h, not gdb_string.h.
	* m32r-linux-nat.c: Use string.h, not gdb_string.h.
	* m32r-linux-tdep.c: Use string.h, not gdb_string.h.
	* m32r-rom.c: Use string.h, not gdb_string.h.
	* m32r-tdep.c: Use string.h, not gdb_string.h.
	* m68hc11-tdep.c: Use string.h, not gdb_string.h.
	* m68k-tdep.c: Use string.h, not gdb_string.h.
	* m68kbsd-tdep.c: Use string.h, not gdb_string.h.
	* m68klinux-nat.c: Use string.h, not gdb_string.h.
	* m68klinux-tdep.c: Use string.h, not gdb_string.h.
	* m88k-tdep.c: Use string.h, not gdb_string.h.
	* macrocmd.c: Use string.h, not gdb_string.h.
	* main.c: Use string.h, not gdb_string.h.
	* mdebugread.c: Use string.h, not gdb_string.h.
	* mem-break.c: Use string.h, not gdb_string.h.
	* memattr.c: Use string.h, not gdb_string.h.
	* memory-map.c: Use string.h, not gdb_string.h.
	* mep-tdep.c: Use string.h, not gdb_string.h.
	* mi/mi-cmd-break.c: Use string.h, not gdb_string.h.
	* mi/mi-cmd-disas.c: Use string.h, not gdb_string.h.
	* mi/mi-cmd-env.c: Use string.h, not gdb_string.h.
	* mi/mi-cmd-stack.c: Use string.h, not gdb_string.h.
	* mi/mi-cmd-var.c: Use string.h, not gdb_string.h.
	* mi/mi-cmds.c: Use string.h, not gdb_string.h.
	* mi/mi-console.c: Use string.h, not gdb_string.h.
	* mi/mi-getopt.c: Use string.h, not gdb_string.h.
	* mi/mi-interp.c: Use string.h, not gdb_string.h.
	* mi/mi-main.c: Use string.h, not gdb_string.h.
	* mi/mi-parse.c: Use string.h, not gdb_string.h.
	* microblaze-rom.c: Use string.h, not gdb_string.h.
	* microblaze-tdep.c: Use string.h, not gdb_string.h.
	* mingw-hdep.c: Use string.h, not gdb_string.h.
	* minidebug.c: Use string.h, not gdb_string.h.
	* minsyms.c: Use string.h, not gdb_string.h.
	* mips-irix-tdep.c: Use string.h, not gdb_string.h.
	* mips-linux-tdep.c: Use string.h, not gdb_string.h.
	* mips-tdep.c: Use string.h, not gdb_string.h.
	* mips64obsd-tdep.c: Use string.h, not gdb_string.h.
	* mipsnbsd-tdep.c: Use string.h, not gdb_string.h.
	* mipsread.c: Use string.h, not gdb_string.h.
	* mn10300-linux-tdep.c: Use string.h, not gdb_string.h.
	* mn10300-tdep.c: Use string.h, not gdb_string.h.
	* monitor.c: Use string.h, not gdb_string.h.
	* moxie-tdep.c: Use string.h, not gdb_string.h.
	* mt-tdep.c: Use string.h, not gdb_string.h.
	* nbsd-tdep.c: Use string.h, not gdb_string.h.
	* nios2-linux-tdep.c: Use string.h, not gdb_string.h.
	* nto-procfs.c: Use string.h, not gdb_string.h.
	* nto-tdep.c: Use string.h, not gdb_string.h.
	* objc-lang.c: Use string.h, not gdb_string.h.
	* objfiles.c: Use string.h, not gdb_string.h.
	* opencl-lang.c: Use string.h, not gdb_string.h.
	* osabi.c: Use string.h, not gdb_string.h.
	* osdata.c: Use string.h, not gdb_string.h.
	* p-exp.y: Use string.h, not gdb_string.h.
	* p-lang.c: Use string.h, not gdb_string.h.
	* p-typeprint.c: Use string.h, not gdb_string.h.
	* parse.c: Use string.h, not gdb_string.h.
	* posix-hdep.c: Use string.h, not gdb_string.h.
	* ppc-linux-nat.c: Use string.h, not gdb_string.h.
	* ppc-sysv-tdep.c: Use string.h, not gdb_string.h.
	* ppcfbsd-tdep.c: Use string.h, not gdb_string.h.
	* ppcnbsd-tdep.c: Use string.h, not gdb_string.h.
	* ppcobsd-tdep.c: Use string.h, not gdb_string.h.
	* printcmd.c: Use string.h, not gdb_string.h.
	* procfs.c: Use string.h, not gdb_string.h.
	* prologue-value.c: Use string.h, not gdb_string.h.
	* python/py-auto-load.c: Use string.h, not gdb_string.h.
	* python/py-gdb-readline.c: Use string.h, not gdb_string.h.
	* ravenscar-thread.c: Use string.h, not gdb_string.h.
	* regcache.c: Use string.h, not gdb_string.h.
	* registry.c: Use string.h, not gdb_string.h.
	* remote-fileio.c: Use string.h, not gdb_string.h.
	* remote-m32r-sdi.c: Use string.h, not gdb_string.h.
	* remote-mips.c: Use string.h, not gdb_string.h.
	* remote-sim.c: Use string.h, not gdb_string.h.
	* remote.c: Use string.h, not gdb_string.h.
	* reverse.c: Use string.h, not gdb_string.h.
	* rs6000-aix-tdep.c: Use string.h, not gdb_string.h.
	* ser-base.c: Use string.h, not gdb_string.h.
	* ser-go32.c: Use string.h, not gdb_string.h.
	* ser-mingw.c: Use string.h, not gdb_string.h.
	* ser-pipe.c: Use string.h, not gdb_string.h.
	* ser-tcp.c: Use string.h, not gdb_string.h.
	* ser-unix.c: Use string.h, not gdb_string.h.
	* serial.c: Use string.h, not gdb_string.h.
	* sh-tdep.c: Use string.h, not gdb_string.h.
	* sh64-tdep.c: Use string.h, not gdb_string.h.
	* shnbsd-tdep.c: Use string.h, not gdb_string.h.
	* skip.c: Use string.h, not gdb_string.h.
	* sol-thread.c: Use string.h, not gdb_string.h.
	* solib-dsbt.c: Use string.h, not gdb_string.h.
	* solib-frv.c: Use string.h, not gdb_string.h.
	* solib-osf.c: Use string.h, not gdb_string.h.
	* solib-spu.c: Use string.h, not gdb_string.h.
	* solib-target.c: Use string.h, not gdb_string.h.
	* solib.c: Use string.h, not gdb_string.h.
	* somread.c: Use string.h, not gdb_string.h.
	* source.c: Use string.h, not gdb_string.h.
	* sparc-nat.c: Use string.h, not gdb_string.h.
	* sparc-sol2-tdep.c: Use string.h, not gdb_string.h.
	* sparc-tdep.c: Use string.h, not gdb_string.h.
	* sparc64-tdep.c: Use string.h, not gdb_string.h.
	* sparc64fbsd-tdep.c: Use string.h, not gdb_string.h.
	* sparc64nbsd-tdep.c: Use string.h, not gdb_string.h.
	* sparcnbsd-tdep.c: Use string.h, not gdb_string.h.
	* spu-linux-nat.c: Use string.h, not gdb_string.h.
	* spu-multiarch.c: Use string.h, not gdb_string.h.
	* spu-tdep.c: Use string.h, not gdb_string.h.
	* stabsread.c: Use string.h, not gdb_string.h.
	* stack.c: Use string.h, not gdb_string.h.
	* std-regs.c: Use string.h, not gdb_string.h.
	* symfile.c: Use string.h, not gdb_string.h.
	* symmisc.c: Use string.h, not gdb_string.h.
	* symtab.c: Use string.h, not gdb_string.h.
	* target.c: Use string.h, not gdb_string.h.
	* thread.c: Use string.h, not gdb_string.h.
	* tilegx-linux-nat.c: Use string.h, not gdb_string.h.
	* tilegx-tdep.c: Use string.h, not gdb_string.h.
	* top.c: Use string.h, not gdb_string.h.
	* tracepoint.c: Use string.h, not gdb_string.h.
	* tui/tui-command.c: Use string.h, not gdb_string.h.
	* tui/tui-data.c: Use string.h, not gdb_string.h.
	* tui/tui-disasm.c: Use string.h, not gdb_string.h.
	* tui/tui-file.c: Use string.h, not gdb_string.h.
	* tui/tui-layout.c: Use string.h, not gdb_string.h.
	* tui/tui-out.c: Use string.h, not gdb_string.h.
	* tui/tui-regs.c: Use string.h, not gdb_string.h.
	* tui/tui-source.c: Use string.h, not gdb_string.h.
	* tui/tui-stack.c: Use string.h, not gdb_string.h.
	* tui/tui-win.c: Use string.h, not gdb_string.h.
	* tui/tui-windata.c: Use string.h, not gdb_string.h.
	* tui/tui-winsource.c: Use string.h, not gdb_string.h.
	* typeprint.c: Use string.h, not gdb_string.h.
	* ui-file.c: Use string.h, not gdb_string.h.
	* ui-out.c: Use string.h, not gdb_string.h.
	* user-regs.c: Use string.h, not gdb_string.h.
	* utils.c: Use string.h, not gdb_string.h.
	* v850-tdep.c: Use string.h, not gdb_string.h.
	* valarith.c: Use string.h, not gdb_string.h.
	* valops.c: Use string.h, not gdb_string.h.
	* valprint.c: Use string.h, not gdb_string.h.
	* value.c: Use string.h, not gdb_string.h.
	* varobj.c: Use string.h, not gdb_string.h.
	* vax-tdep.c: Use string.h, not gdb_string.h.
	* vaxnbsd-tdep.c: Use string.h, not gdb_string.h.
	* vaxobsd-tdep.c: Use string.h, not gdb_string.h.
	* windows-nat.c: Use string.h, not gdb_string.h.
	* xcoffread.c: Use string.h, not gdb_string.h.
	* xml-support.c: Use string.h, not gdb_string.h.
	* xstormy16-tdep.c: Use string.h, not gdb_string.h.
	* xtensa-linux-nat.c: Use string.h, not gdb_string.h.
2013-11-18 13:29:00 -07:00
Joel Brobecker 778865d3e2 Add command to list Ada exceptions
This patch adds a new command "info exceptions" whose purpose is to
provide the list of exceptions currently defined in the inferior.
The usage is:

    (gdb) info exceptions [REGEXP]

Without argument, the command lists all exceptions.  Otherwise,
only those whose name match REGEXP are listed.

For instance:

    (gdb) info exceptions
    All defined Ada exceptions:
    constraint_error: 0x613dc0
    program_error: 0x613d40
    storage_error: 0x613d00
    tasking_error: 0x613cc0
    global_exceptions.a_global_exception: 0x613a80
    global_exceptions.a_private_exception: 0x613ac0

The name of the command, as well as its output is part of a legacy
I inherited long ago. It's output being parsed by frontends such as
GPS, I cannot easily change it. Same for the command name.

The implementation is mostly self-contained, and is written in a way
that should make it easy to implement the GDB/MI equivalent. The
careful reviewer will notice that the code added in ada-lang.h could
normally be made private inside ada-lang.c.  But these will be used
by the GDB/MI implementation.  Rather than making those private now,
only to move them later, I've made them public right away.

gdb/ChangeLog:

        * ada-lang.h: #include "vec.h".
        (struct ada_exc_info): New.
        (ada_exc_info): New typedef.
        (DEF_VEC_O(ada_exc_info)): New vector.
        (ada_exceptions_list): Add declaration.
        * ada-lang.c (ada_is_exception_sym)
        (ada_is_non_standard_exception_sym, compare_ada_exception_info)
        (sort_remove_dups_ada_exceptions_list)
        (ada_exc_search_name_matches, ada_add_standard_exceptions)
        (ada_add_exceptions_from_frame, ada_add_global_exceptions)
        (ada_exceptions_list_1, ada_exceptions_list)
        (info_exceptions_command): New function.
        (_initialize_ada_language): Add "info exception" command.

gdb/testsuite/ChangeLog:

        * gdb.ada/info_exc: New testcase.
2013-11-12 06:45:29 +04:00
Joel Brobecker 2df4d1d5c4 Dandling memory pointers in Ada catchpoints with GDB/MI.
When using the GDB/MI commands to insert a catchpoint on a specific
Ada exception, any re-evaluation of that catchpoint (for instance
a re-evaluation performed after a shared library got mapped by the
inferior) fails. For instance, with any Ada program:

    (gdb)
    -catch-exception -e program_error
    ^done,bkptno="1",bkpt={[...]}
    (gdb)
    -exec-run
    =thread-group-started,id="i1",pid="28315"
    =thread-created,id="1",group-id="i1"
    ^running
    *running,thread-id="all"
    (gdb)
    =library-loaded,[...]
    &"warning: failed to reevaluate internal exception condition for catchpoint 1: No definition of \"exec\" in current context.\n"
    &"warning: failed to reevaluate internal exception condition for catchpoint 1: No definition of \"exec\" in current context.\n"
    [...]

The same is true if using an Ada exception catchpoint.

The problem comes from the fact that that we deallocate the strings
given as arguments to create_ada_exception_catchpoint, while the latter
just makes shallow copies of those strings, thus creating dandling
pointers.

This patch fixes the issue by passing freshly allocated strings to
create_ada_exception_catchpoint, while at the same time updating
create_ada_exception_catchpoint's documentation to make it clear
that deallocating the strings is no longer the responsibility of
the caller.

gdb/ChangeLog:

        * ada-lang.c (create_ada_exception_catchpoint): Enhance
        the documentation of fields "except_string" and "condition".
        * mi/mi-cmd-catch.c (mi_cmd_catch_assert): Reallocate
        CONDITION on the heap before passing it to
        create_ada_exception_catchpoint.
        (mi_cmd_catch_exception): Likewise for EXCEPTION_NAME and
        CONDITION.

gdb/testsuite/ChangeLog:

        * gdb.ada/mi_ex_cond: New testcase.

Tested on x86_64-linux.  The "-break-list" test FAILs without
this patch.
2013-11-11 19:19:07 +04:00
Yao Qi 6abde28fa9 New field 'la_natural_name' in struct language_defn
This patch adds "natural name" of each supported languages, which will
be used by the next patch.

gdb:

2013-11-07  Yao Qi  <yao@codesourcery.com>

	* language.h (struct language_defn) <la_natural_name>: New field.
	* ada-lang.c (ada_language_defn): Initialize field 'la_natural_name'.
	* c-lang.c (c_language_defn): Likewise.
	(cplus_language_defn, asm_language_defn): Likewise.
	* d-lang.c (d_language_defn): Likewise.
	* f-lang.c (f_language_defn): Likewise.
	* go-lang.c (go_language_defn): Likewise.
	* jv-lang.c (java_language_defn): Likewise.
	* language.c (unknown_language_defn ): Likewise.
	(auto_language_defn): Likewise.
	* m2-lang.c (m2_language_defn): Likewise.
	* objc-lang.c (objc_language_defn): Likewise.
	* opencl-lang.c (opencl_language_defn): Likewise.
	* p-lang.c (pascal_language_defn): Likewise.
2013-11-07 15:08:09 +08:00
Yao Qi a53b64eaa0 New field la_varobj_ops in struct language_defn
This is a follow-up series to move language stuff out of varobj.c.

This patch adds a new field la_varobj_ops in struct language_defn so
that each language has varobj-related options.  Not every language
supports varobj, and the operations are identical to operations of c
languages.

'struct language_defn' is the ideal place to save all language-related
operations.  After this patch, some cleanups can be done in patch 2/2,
which removes language-related stuff completely from varobj.c.

Regression tested on x86_64-linux.

gdb:

2013-10-25  Yao Qi  <yao@codesourcery.com>

	* language.h (struct lang_varobj_ops): Declare.
	(struct language_defn) <la_varobj_ops>: New field.
	* ada-lang.c: Include "varobj.h"
	(defn ada_language_defn): Initialize field 'la_varobj_ops' by
	ada_varobj_ops.
	* c-lang.c: Include "varobj.h"
	(c_language_defn): Initialize field 'la_varobj_ops' by
	c_varobj_ops.
	(cplus_language_defn): Initialize field 'la_varobj_ops' by
	cplus_varobj_ops.
	(asm_language_defn): Initialize field 'la_varobj_ops' by
	default_varobj_ops.
	(minimal_language_defn): Likewise.
	* d-lang.c (d_language_defn): Likewise.
	* f-lang.c (f_language_defn): Likewise.
	* go-lang.c (go_language_defn): Likewise.
	* m2-lang.c (m2_language_defn): Likewise.
	* objc-lang.c (objc_language_defn): Likewise.
	* opencl-lang.c (opencl_language_defn): Likewise.
	* p-lang.c (pascal_language_defn): Likewise.
	* language.c (unknown_language_defn): Likewise.
	(auto_language_defn): Likewise.
	(local_language_defn): Likewise.
	* jv-lang.c (java_language_defn): Initialize field
	'la_varobj_ops' by java_varobj_ops.
	* varobj.c (varobj_create): Update.
	* varobj.h (default_varobj_ops): Define macro.
2013-10-25 14:03:02 +00:00
Joel Brobecker 349774efe2 New GDB/MI commands to catch Ada exceptions
This patch introduces two new GDB/MI commands implementing the equivalent
of the "catch exception" and  "catch assert" GDB/CLI commands.

gdb/ChangeLog:

        * breakpoint.h (init_ada_exception_breakpoint): Add parameter
        "enabled".
        * breakpoint.c (init_ada_exception_breakpoint): Add parameter
        "enabled".  Set B->ENABLE_STATE accordingly.
        * ada-lang.h (ada_exception_catchpoint_kind): Move here from
        ada-lang.c.
        (create_ada_exception_catchpoint): Add declaration.
        * ada-lang.c (ada_exception_catchpoint_kind): Move to ada-lang.h.
        (create_ada_exception_catchpoint): Make non-static. Add new
        parameter "disabled". Use it in call to
        init_ada_exception_breakpoint.
        (catch_ada_exception_command): Add parameter "enabled" in call
        to create_ada_exception_catchpoint.
        (catch_assert_command): Likewise.

        * mi/mi-cmds.h (mi_cmd_catch_assert, mi_cmd_catch_exception):
        Add declarations.
        * mi/mi-cmds.c (mi_cmds): Add the "catch-assert" and
        "catch-exception" commands.
        * mi/mi-cmd-catch.c: Add #include "ada-lang.h".
        (mi_cmd_catch_assert, mi_cmd_catch_exception): New functions.
2013-10-11 13:48:19 +00:00
Joel Brobecker 761269c849 Add "ada_" prefix to enum ada_exception_catchpoint_kind
This is in preparation for making that type public, in order to be
able to use make create_ada_exception_catchpoint public as well,
making it usable from the GDB/MI implementation.

gdb/ChangeLog:

        * ada-lang.c (enum ada_exception_catchpoint_kind): Renames
        "enum exception_catchpoint_kind".  Replace the "ex_" prefix
        of all its enumerates with "ada_".  Update the rest of this
        file throughout.
2013-10-11 13:45:27 +00:00
Joel Brobecker b4a5b78b78 Rework a bit Ada exception catchpoint support (in prep for GDB/MI)
This patch reworks a bit how the different steps required to insert
an Ada exception catchpoints are organized. They used to be:

  1. Call a "decode" function which does:
        1.a.  Parse the command and its arguments
        1.b.  Create a SAL & OPS from some of those arguments

  2. Call create_ada_exception_catchpoint using SAL as well
     as some of the arguments extracted above.

The bulk of the change consists in integrating step (1.b) into
step (2) in order to turn create_ada_exception_catchpoint into
a function whose arguments are all user-level concepts. This
paves the way from a straightforward implementation of the equivalent
commands in the GDB/MI interpreter.

gdb/ChangeLog:

        * ada-lang.c (ada_decode_exception_location): Delete.
        (create_ada_exception_catchpoint): Remove arguments "sal",
        "addr_string" and "ops".  Add argument "ex_kind" instead.
        Adjust implementation accordingly, calling ada_exception_sal
        to get the entities it no longer gets passed as arguments.
        Document the function's arguments.
        (catch_ada_exception_command): Use catch_ada_exception_command_split
        instead of ada_decode_exception_location, and update call to
        create_ada_exception_catchpoint.
        (catch_ada_assert_command_split): Renames
        ada_decode_assert_location.  Remove parameters "addr_string" and
        "ops", and now returns void.  Adjust implementation accordingly.
        Update the function documentation.
        (catch_assert_command): Use catch_ada_assert_command_split
        instead of ada_decode_assert_location.  Update call to
        create_ada_exception_catchpoint.
2013-10-11 13:44:11 +00:00
Joel Brobecker db230ce3ff [Ada] psymbol search failure due to comparison function discrepancy
Upon trying to print the value of a variant record, a user noticed
the following problem:

        (gdb) print rt
        warning: Unknown upper bound, using 1.
        warning: Unknown upper bound, using 1.
        $1 = (a => ((a1 => (4), a2 => (4)), (a1 => (8), a2 => (8))))

The expected output is:

        (gdb) print rt
        $1 = (a => ((a1 => (4, 4), a2 => (8, 8)), (a1 => (4, 4),
              a2 => (8, 8))))

The problems comes from the fact that components "a1" and "a2" are
defined as arrays whose upper bound is dynamic.  To determine the value
of that upper bound, GDB relies on the GNAT encoding and searches
for the parallel ___U variable.  Unfortunately, the search fails
while doing a binary search inside the partial symtab of the unit
where the array and its bound (and therefore the parallel ___U variable)
are defined.

It fails because partial symbols are sorted using strcmp_iw_ordered,
while Ada symbol lookups are performed using a different comparison
function (ada-lang.c:compare_names). The two functions are supposed
to be compatible, but a change performed in April 2011 modified
strcmp_iw_ordered, introducing case-sensitivity issues. As a result,
the two functions would now disagree when passed the following
two arguments:

  string1="common__inner_arr___SIZE_A_UNIT"
  string2="common__inner_arr__T4s___U"

The difference starts at "_SIZE_A_UNIT" vs "T4s___U". So, it's mostly
a matter of comparing '_' with 'T'.

On the one hand, strcmp_iw_ordered would return -1, while compare_names
returned 11. The change that made all the difference is that
strcmp_iw_ordered now performs a case-insensitive comparison,
and only resorts to case-sentitive comparison if the first comparison
finds an equality. This changes everything, because while 'T' (84)
and 't' (116) are on opposite sides of '_' (95).

This patch aims at restoring the compatibility between the two
functions, by adding case-sensitivity handling in the Ada comparison
function.

gdb/ChangeLog:

        * ada-lang.c (compare_names_with_case): Renamed from
        compare_names, adding a new parameter "casing" and its handling.
        New function documentation.
        (compare_names): New function, implemented using
        compare_names_with_case.
2013-10-08 11:18:58 +00:00
Joel Brobecker 82fbe37759 [Ada] Remove unnecessary ada_exception_sal advance declaration.
gdb/ChangeLog:

        * ada-lang.c (ada_exception_sal): Remove advance declaration.
2013-10-08 10:52:18 +00:00
Joel Brobecker 1c8e84b082 wrong "catch exception" error message when finding trampoline msym.
When building the program with the shared GNAT runtime, the debugger
is unable to insert Ada exception catchpoints until that runtime
has been mapped to memory. In other words, we expect the user to start
the program first, before attempting to insert that catchpoint.

The detection mechanism that tries to provide some useful tips to
the user fails when the program itself contains a trampoline symbol
matching the symbol that the catchpoint is trying to use. This
results in the following error message:

    (gdb) catch exception
    Your Ada runtime appears to be missing some debugging information.
    Cannot insert Ada exception catchpoint in this configuration.

Instead, we expected the following error message:

    (gdb) catch exception
    Unable to insert catchpoint. Try to start the program first.

gdb/ChangeLog:

        * ada-lang.c (ada_has_this_exception_support): Ignore
        mst_solib_trampoline minimal symbols.
2013-10-01 09:21:41 +00:00
Doug Evans ade7ed9e33 * symfile.h (struct quick_symbol_functions): Reorg arg list of
map_matching_symbols so objfile is first.  All uses updated.
	* dwarf2read.c (dw2_map_matching_symbols): Update signature.
	* psymtab.c (map_matching_symbols_psymtab): Update signature.
2013-09-25 21:44:11 +00:00
Jan Kratochvil 4262abfb98 Code cleanup: Add objfile_name accessor
gdb/
2013-09-24  Jan Kratochvil  <jan.kratochvil@redhat.com>

	Code cleanup: Add objfile_name accessor function.
	* ada-lang.c (is_known_support_routine): Use objfile_name.
	* auto-load.c (source_gdb_script_for_objfile)
	(auto_load_objfile_script): Likewise.
	* coffread.c (coff_symtab_read, read_one_sym): Likewise.
	* dbxread.c (dbx_symfile_read): Likewise.
	* dwarf2-frame.c (dwarf2_build_frame_info): Likewise.
	* dwarf2loc.c (locexpr_describe_location_piece): Likewise.
	* dwarf2read.c (dwarf2_get_dwz_file, dwarf2_read_index)
	(dw2_symtab_iter_next, dw2_expand_symtabs_matching)
	(lookup_dwp_signatured_type, lookup_dwo_unit)
	(dwarf2_build_psymtabs_hard, scan_partial_symbols, process_queue)
	(fixup_go_packaging, process_imported_unit_die, dwarf2_physname)
	(read_import_statement, create_dwo_cu, open_and_init_dwp_file)
	(lookup_dwo_cutu, read_call_site_scope, dwarf2_ranges_read)
	(dwarf2_record_block_ranges, read_common_block, read_typedef)
	(read_subrange_type, load_partial_dies, read_partial_die)
	(read_addr_index_1, read_str_index, dwarf_decode_lines_1)
	(die_containing_type, build_error_marker_type, lookup_die_type)
	(follow_die_ref_or_sig, follow_die_ref, dwarf2_fetch_die_loc_sect_off)
	(dwarf2_fetch_constant_bytes, follow_die_sig, get_signatured_type)
	(get_DW_AT_signature_type, write_psymtabs_to_index)
	(save_gdb_index_command): Likewise.
	* elfread.c (find_separate_debug_file_by_buildid, elf_symfile_read):
	Likewise.
	* expprint.c (dump_subexp_body_standard): Likewise.
	* gdbtypes.c (type_name_no_tag_or_error): Likewise.
	* jit.c (jit_object_close_impl): Use the objfile field name renamed to
	original_name.
	* linux-thread-db.c (try_thread_db_load_from_pdir_1): New variable
	obj_name, use objfile_name for it, use the variable.
	(try_thread_db_load_from_pdir, has_libpthread, thread_db_new_objfile):
	Use objfile_name.
	* machoread.c (macho_symtab_read, macho_check_dsym)
	(macho_symfile_relocate): Likewise.
	* maint.c (maintenance_translate_address): Likewise.
	* minidebug.c (find_separate_debug_file_in_section): Likewise.
	* minsyms.c (install_minimal_symbols): Likewise.
	* objfiles.c (allocate_objfile): Use the objfile field name renamed to
	original_name.
	(filter_overlapping_sections): Use objfile_name.
	(objfile_name): New function.
	* objfiles.h (struct objfile): Rename field name to original_name.
	(objfile_name): New prototype.
	* printcmd.c (sym_info, address_info): Use objfile_name.
	* probe.c (parse_probes, collect_probes, compare_probes)
	(info_probes_for_ops): Likewise.
	* progspace.c (clone_program_space): Likewise.
	* psymtab.c (require_partial_symbols, dump_psymtab, allocate_psymtab)
	(maintenance_info_psymtabs): Likewise.
	* python/py-auto-load.c (gdbpy_load_auto_script_for_objfile)
	(source_section_scripts): Likewise.
	* python/py-objfile.c (objfpy_get_filename): Likewise.
	* python/py-progspace.c (pspy_get_filename): Likewise.
	* solib-aix.c (solib_aix_get_toc_value): Likewise.
	* solib-som.c (match_main, som_solib_section_offsets): Likewise.
	* solib.c (solib_read_symbols): Likewise.
	* stabsread.c (scan_file_globals): Likewise.
	* stap-probe.c (handle_stap_probe): Likewise.
	* symfile.c (symbol_file_clear, separate_debug_file_exists)
	(find_separate_debug_file_by_debuglink): Likewise.
	(reread_symbols): Likewise.  Use the objfile field name renamed to
	original_name.
	(allocate_symtab): Use objfile_name.
	* symmisc.c (print_symbol_bcache_statistics, print_objfile_statistics)
	(dump_objfile, dump_msymbols, dump_symtab_1)
	(maintenance_print_msymbols, maintenance_print_objfiles)
	(maintenance_info_symtabs, maintenance_check_symtabs): Likewise.
	* target.c (target_translate_tls_address, target_info): Likewise.
	* xcoffread.c (xcoff_initial_scan): Make variable name const.  Use
	objfile_name.
2013-09-24 13:57:38 +00:00
Tom Tromey 7c7b66552d remove msymbol_objfile
This is another patch in my ongoing series to "split" objfile to share
more read-only data across inferiors.  See

    http://sourceware.org/gdb/wiki/ObjfileSplitting

When symbols are finally shared, there will be no back-link from the
symbol to its containing objfile, because there may be more than one
such objfile.  So, all such back-links must be removed.

One hidden back-link is the msymbol_objfile function.  Since
(eventually) a symbol may appear in more than one objfile, trying to
look up the objfile given just a symbol cannot work.

This patch removes msymbol_objfile in favor of using a bound minimal
symbol.  It introduces a new function to make this conversion simpler
in some spots.

The bonus of this patch is that using msymbol_objfile is slower than
simply looking up the owning objfile in the first place.

Built and regtested on x86-64 Fedora 18.

	* ada-exp.y (write_var_or_type): Use bound_minimal_symbol.
	* ada-lang.c (ada_lookup_simple_minsym): Return
	bound_minimal_symbol.
	* ada-lang.h (ada_lookup_simple_minsym): Update.
	* c-exp.y (variable): Use lookup_bound_minimal_symbol.
	* f-exp.y (variable): Use lookup_bound_minimal_symbol.
	* go-exp.y (variable): Use lookup_bound_minimal_symbol.
	* jv-exp.y (push_expression_name): Use lookup_bound_minimal_symbol.
	* m2-exp.y (variable): Use lookup_bound_minimal_symbol.
	* minsyms.c (msymbol_objfile): Remove.
	(lookup_minimal_symbol_internal): New function, from
	lookup_minimal_symbol.
	(lookup_minimal_symbol): Rewrite using
	lookup_minimal_symbol_internal.
	(lookup_bound_minimal_symbol): New function.
	* minsyms.h (msymbol_objfile): Remove.
	(lookup_bound_minimal_symbol): Declare.
	* p-exp.y (variable): Use lookup_bound_minimal_symbol.
	* parse.c (write_exp_msymbol): Change parameter to a
	bound_minimal_symbol.
	(write_dollar_variable): Use lookup_bound_minimal_symbol.
	* parser-defs.h (write_exp_msymbol): Update.
	* printcmd.c (address_info): Use lookup_bound_minimal_symbol.
	* symfile.c (simple_read_overlay_table): Use
	lookup_bound_minimal_symbol.
	* symtab.c (skip_prologue_sal): Don't use msymbol_objfile.
	(search_symbols): Likewise.
	(print_msymbol_info): Take a bound_minimal_symbol argument.
	(symtab_symbol_info, rbreak_command): Update.
	* symtab.h (struct symbol_search) <msymbol>: Change type
	to bound_minimal_symbol.
	* valops.c (find_function_in_inferior): Use
	lookup_bound_minimal_symbol.
	* value.c (value_fn_field): Use lookup_bound_minimal_symbol.
2013-08-05 15:51:02 +00:00
Joel Brobecker eca07816f8 ada-lang.c:coerce_unspec_val_to_type: Preserve laziness.
ada-lang.c:coerce_unspec_val_to_type does:

      if (value_lazy (val)
	  || TYPE_LENGTH (type) > TYPE_LENGTH (value_type (val)))
	result = allocate_value_lazy (type);
      else
	{
	  result = allocate_value (type);
	  memcpy (value_contents_raw (result), value_contents (val),
		  TYPE_LENGTH (type));
	}
      set_value_component_location (result, val);
      set_value_bitsize (result, value_bitsize (val));
      set_value_bitpos (result, value_bitpos (val));
      set_value_address (result, value_address (val));
      set_value_optimized_out (result, value_optimized_out (val));

Notice that before value_optimized_out was made to auto-fetch lazy
values, VAL would end up still lazy if it was lazy on entry.  It's not
really a problem here if VAL is lazy, and VAL->optimized_out is 0,
because RESULT is also left lazy.  IOW, this just wants to copy the
VAL->optimized_out flag to RESULT->optimized_out, nothing else.

As a side-effect of the change in value_optimized_out, the following
testcase now regresses. Consider:

       type Small is range -64 .. 63;
       for Small'Size use 7;
       type Arr is array (1..10) of Small;
       pragma Pack (Arr);

       type Arr_Ptr is access Arr;
       An_Arr_Ptr : Arr_Ptr := new Arr'(10, 20, 30, 40, 50, 60, 62, 63,
                                        -23, 42);

    Trying to print one element of An_Arr_Ptr yields:

        (gdb) p an_arr_ptr(3)
        Cannot access memory at address 0x0

The patch adds the value_optimized_out_const function for that,
allowing us to avoid trying to fetch a value at a dummy address.

(I found this out by grepping for set_value_optimized_out and trying
to convert the uses I found to instead allocate the value with
allocate_optimized_out_value.)

Tested on x86_64 Fedora 17.

gdb/
2013-07-09  Pedro Alves  <palves@redhat.com>

	* ada-lang.c (coerce_unspec_val_to_type): Use
	value_optimized_out_const.
	* value.c (value_optimized_out_const): New function.
	* value.h (value_optimized_out_const): New declaration.
2013-07-10 00:34:38 +00:00
Keith Seitz 55b87a526f * ada-lang.c (is_known_support_routine): Add explicit free of
'func_name' from find_frame_funname.
	(ada_unhandled_exception_name_addr_from_raise): Add cleanups
	for func_name from find_frame_funname.
	* python/py-frame.c (frapy_name): Add explicit free of
	'name' from find_frame_funname.
	* stack.c (find_frame_funname): Add comment explaining that
	funcp must be freed by the caller.
	Return copy of symbol names instead of pointers.
	(print_frame): Add a cleanup for 'funname' from
	find_frame_funname.
	* stack.h (find_frame_funname): Remove "const" from
	'funname' parameter.
2013-05-22 21:16:18 +00:00
Joel Brobecker 1509e5737f [Ada] Fix cleanup leak in ada-lang.c:old_renaming_is_invisible
gdb/ChangeLog:

	* ada-lang.c (old_renaming_is_invisible): Fix cleanup leak.
2013-05-21 05:41:31 +00:00
Joel Brobecker b8fea896fe Missing do_cleanups in ada_make_symbol_completion_list.
This results in an internal-warning when trying the completion
when in Ada mode:

    (gdb) b simple<TAB>
    /[...]/cleanups.c:265: internal-warning: restore_my_cleanups has found a stale cleanup
    A problem internal to GDB has been detected,
    further debugging may prove unreliable.
    Quit this debugging session? (y or n)

gdb/ChangeLog:

        * ada-lang.c (ada_make_symbol_completion_list): Make sure
        all cleanups are done before returning from this function.

gdb/testsuite/ChangeLog:

        * gdb.ada/complete.exp: Add test verifying completion using
        the "tab" key.
2013-05-16 07:02:43 +00:00
Tom Tromey 40501e00a1 * ada-lang.c (ada_value_primitive_packed_val): Don't
call value_incref.
	* value.c (set_value_parent): Incref the new parent and decref
	the old parent.
	(value_copy, value_primitive_field): Use set_value_parent.
2013-05-06 19:46:15 +00:00
Pedro Alves c714b42695 -Wpointer-sign: ada-lang.c, ada-tasks.c.
We're reading strings using the target memory access routines, which
work with raw bytes, so we need a couple casts.

gdb/
2013-04-19  Pedro Alves  <palves@redhat.com>

	* ada-lang.c (print_it_exception): Add cast to gdb_byte *.
	* ada-tasks.c (read_fat_string_value): Likewise.
2013-04-19 15:35:58 +00:00
Pedro Alves 948f8e3d72 -Wpointer-sign: char -> gdb_byte.
-Wpointer-sign catches all these cases across the codebase that should
be using gdb_byte for raw target bytes.  I think these are all
obvious, hence I've collapsed into a single patch.

gdb/
2013-04-19  Pedro Alves  <palves@redhat.com>

	* aarch64-tdep.c (aarch64_default_breakpoint): Change type to
	gdb_byte[].
	(aarch64_breakpoint_from_pc): Change return type to gdb_byte *.
	* ada-lang.c (ada_value_assign): Use gdb_byte.
	* alphanbsd-tdep.c (sigtramp_retcode): Change type to gdb_byte[].
	(alphanbsd_sigtramp_offset): Use gdb_byte.
	* arm-linux-tdep.c (arm_linux_arm_le_breakpoint)
	(arm_linux_arm_be_breakpoint, eabi_linux_arm_le_breakpoint)
	(eabi_linux_arm_be_breakpoint, arm_linux_thumb_be_breakpoint)
	(arm_linux_thumb_le_breakpoint, arm_linux_thumb2_be_breakpoint)
	(arm_linux_thumb2_le_breakpoint): Change type to gdb_byte[].
	* arm-tdep.c (arm_stub_unwind_sniffer)
	(arm_displaced_init_closure): Use gdb_byte.
	(arm_default_arm_le_breakpoint, arm_default_arm_be_breakpoint)
	(arm_default_thumb_le_breakpoint)
	(arm_default_thumb_be_breakpoint): Change type to gdb_byte[].
	* arm-tdep.h (struct gdbarch_tdep) <arm_breakpoint,
	thumb_breakpoint, thumb2_breakpoint>: Change type to gdb_byte *.
	* arm-wince-tdep.c (arm_wince_le_breakpoint)
	(arm_wince_thumb_le_breakpoint): Change type to gdb_byte[].
	* armnbsd-tdep.c (arm_nbsd_arm_le_breakpoint)
	(arm_nbsd_arm_be_breakpoint, arm_nbsd_thumb_le_breakpoint)
	(arm_nbsd_thumb_be_breakpoint): Change type to gdb_byte[].
	* armobsd-tdep.c (arm_obsd_thumb_le_breakpoint)
	(arm_obsd_thumb_be_breakpoint): Change type to gdb_byte[].
	* cris-tdep.c (push_stack_item, cris_push_dummy_call)
	(cris_store_return_value, cris_extract_return_value): Use
	gdb_byte.
	(constraint): Change type of parameter to char * from signed
	char*.  Use gdb_byte.
	* dwarf2loc.c (read_pieced_value, write_pieced_value): Change type
	of local buffer to gdb_byte *.
	* dwarf2read.c (read_index_from_section): Use gdb_byte.
	(create_dwp_hash_table): Change type of locals to gdb_byte *.
	(add_address_entry): Change type of local buffer to gdb_byte[].
	* frv-tdep.c (frv_adjust_breakpoint_address, find_func_descr)
	(frv_push_dummy_call): Use gdb_byte.
	* hppa-hpux-tdep.c (hppa_hpux_push_dummy_code)
	(hppa_hpux_supply_ss_fpblock, hppa_hpux_supply_ss_wide)
	(hppa_hpux_supply_save_state): Use gdb_byte.
	* hppa-tdep.c (hppa32_push_dummy_call)
	(hppa64_convert_code_addr_to_fptr): Use gdb_byte.
	* ia64-tdep.c (extract_bit_field, replace_bit_field)
	(slotN_contents, replace_slotN_contents): Change type of parameter
	to gdb_byte *.
	(fetch_instruction, ia64_pseudo_register_write)
	(ia64_register_to_value, ia64_value_to_register)
	(ia64_extract_return_value, ia64_store_return_value)
	(ia64_push_dummy_call): Use gdb_byte.
	* m32c-tdep.c (m32c_return_value): Remove cast.
	* m68hc11-tdep.c (m68hc11_pseudo_register_write)
	(m68hc11_push_dummy_call, m68hc11_store_return_value): Use
	gdb_byte.
	* mipsnbsd-tdep.c (mipsnbsd_get_longjmp_target): Use gdb_byte.
	* mn10300-tdep.c (mn10300_store_return_value)
	(mn10300_breakpoint_from_pc, mn10300_push_dummy_call): Use
	gdb_byte.
	* moxie-tdep.c (moxie_process_readu): Use gdb_byte.
	(moxie_process_record): Remove casts.
	* ppc-ravenscar-thread.c (supply_register_at_address)
	(ppc_ravenscar_generic_store_registers): Use gdb_byte.
	* ravenscar-thread.c (get_running_thread_id): Use gdb_byte.
	* remote-m32r-sdi.c (m32r_fetch_register): Use gdb_byte.
	* remote-mips.c (mips_xfer_memory): Use gdb_byte.
	* remote.c (compare_sections_command): Use gdb_byte.
	* score-tdep.c (score7_free_memblock): Change type of parameter to
	gdb_byte *.
	* sh-tdep.c (sh_justify_value_in_reg): Change return type to
	gdb_byte *.  Use gdb_byte.
	(sh_push_dummy_call_fpu): Use gdb_byte.
	(sh_extract_return_value_nofpu, sh_extract_return_value_fpu)
	(sh_store_return_value_nofpu, sh_store_return_value_fpu)
	(sh_register_convert_to_virtual, sh_register_convert_to_raw):
	Change parameter type to 'gdb_byte *'.  Use gdb_byte.
	(sh_pseudo_register_read, sh_pseudo_register_write): Use gdb_byte.
	* sh64-tdep.c (sh64_push_dummy_call): Use gdb_byte.
	(sh64_store_return_value, sh64_register_convert_to_virtual):
	Change parameter type to 'gdb_byte *'.  Use gdb_byte.
	(sh64_pseudo_register_write): Use gdb_byte.
	* solib-darwin.c (darwin_current_sos): Add casts to 'gdb_byte *'.
	* solib-irix.c (fetch_lm_info): Likewise.  Use gdb_byte for byte
	buffer.
	(irix_current_sos): Use gdb_byte.
	* solib-som.c (som_current_sos): Use gdb_byte.
	* sparc-ravenscar-thread.c (supply_register_at_address)
	(sparc_ravenscar_generic_store_registers): Use gdb_byte.
	* spu-multiarch.c (spu_xfer_partial): Add cast to 'char *'.
	* spu-tdep.c (spu_get_overlay_table): Use gdb_byte.
	* tic6x-tdep.c (tic6x_breakpoint_from_pc): Change return type to
	'gdb_byte *'.
	* tic6x-tdep.h (struct gdbarch_tdep) <breakpoint>: Change type to
	'gdb_byte *'.
	* tracepoint.c (tfile_fetch_registers): Use gdb_byte.
	* xstormy16-tdep.c (xstormy16_extract_return_value)
	(xstormy16_store_return_value): Change parameter type to
	'gdb_byte *'.  Adjust.
	(xstormy16_push_dummy_call): Use gdb_byte.
	* xtensa-tdep.c (xtensa_scan_prologue, call0_ret)
	(call0_analyze_prologue, execute_code): Use gdb_byte.
2013-04-19 15:09:46 +00:00
Tom Tromey f85f34ede8 * ada-lang.c (ada_decode_symbol): Check and set 'ada_mangled'.
Use symbol's obstack, not an objfile.
	* coffread.c (process_coff_symbol): Update.
	* dwarf2read.c (fixup_go_packaging, new_symbol_full): Update.
	* jv-lang.c (add_class_symbol): Update.
	* mdebugread.c (new_symbol): Update.
	* minsyms.c (prim_record_minimal_symbol_full)
	(terminate_minimal_symbol_table): Update.
	* psymtab.c (add_psymbol_to_bcache): Clear entire symbol.  Update.
	* stabsread.c (define_symbol, read_enum_type): Update.
	* symtab.c (symbol_set_demangled_name, symbol_get_demangled_name):
	Handle Ada specially.
	(symbol_set_language): Add 'obstack' argument.
	(symbol_set_names): Update.
	(symbol_natural_name, symbol_demangled_name): Always use
	ada_decode_symbol.
	* symtab.h (struct general_symbol_info)
	<language_specific::obstack>: New field.
	<ada_mangled>: New field.
	(SYMBOL_SET_LANGUAGE): Add 'obstack' argument.
	(symbol_set_language): Update.
2013-04-08 19:56:03 +00:00
Pedro Alves 6f937416b9 Constify strings in tracepoint.c, lookup_cmd and the completers.
This is sort of a continuation of Keith's parse_exp_1 constification
patch.  It started out by undoing these bits:

  @@ -754,9 +754,12 @@ validate_actionline (char **line, struct
   	  tmp_p = p;
   	  for (loc = t->base.loc; loc; loc = loc->next)
   	    {
  -	      p = tmp_p;
  -	      exp = parse_exp_1 (&p, loc->address,
  +	      const char *q;
  +
  +	      q = tmp_p;
  +	      exp = parse_exp_1 (&q, loc->address,
   				 block_for_pc (loc->address), 1);
  +	      p = (char *) q;

and progressively making more things const upwards, fixing fallout,
rinse repeat, until GDB built again (--enable-targets=all).

That ended up constifying lookup_cmd/add_cmd and (lots of) friends,
and the completers.

I didn't try to constify the command hooks themselves, because I know
upfront there are commands that write to the command string argument,
and I think I managed to stop at a nice non-hacky split point already.

I think the only non-really-super-obvious changes are
tracepoint.c:validate_actionline, and tracepoint.c:trace_dump_actions.

The rest is just mostly about 'char *' => 'const char *', 'char **'=>
'const char **', and the occasional (e.g., deprecated_cmd_warning)
case of 'char **'=> 'const char *', where/when I noticed that nothing
actually cares about the pointer to pointer output.

Tested on x86_64 Fedora 17, native and gdbserver.

gdb/
2013-03-13  Pedro Alves  <palves@redhat.com>

	* ada-lang.c (struct add_partial_datum) <text, text0, word>: Make
	fields const.
	(ada_make_symbol_completion_list): Make "text0" parameter const.
	* ax-gdb.c (agent_eval_command_one): Make "exp" parameter const.
	* breakpoint.c (condition_completer): Make "text" and "word"
	parameters const.  Adjust.
	(check_tracepoint_command): Adjust to validate_actionline
	prototype change.
	(catch_syscall_completer): Make "text" and "word" parameters
	const.
	* cli/cli-cmds.c (show_user): Make "comname" local const.
	(valid_command_p): Make "command" parameter const.
	(alias_command): Make "alias_prefix" and "command_prefix" locals
	const.
	* cli/cli-decode.c (add_cmd): Make "name" parameter const.
	(add_alias_cmd): Make "name" and "oldname" parameters const.
	Adjust.  No longer make copy of OLDNAME.
	(add_prefix_cmd, add_abbrev_prefix_cmd, add_set_or_show_cmd)
	(add_setshow_cmd_full, add_setshow_enum_cmd)
	(add_setshow_auto_boolean_cmd, add_setshow_boolean_cmd)
	(add_setshow_filename_cmd, add_setshow_string_cmd)
	(add_setshow_string_noescape_cmd)
	(add_setshow_optional_filename_cmd, add_setshow_integer_cmd)
	(add_setshow_uinteger_cmd, add_setshow_zinteger_cmd)
	(add_setshow_zuinteger_unlimited_cmd, add_setshow_zuinteger_cmd)
	(delete_cmd, add_info, add_info_alias, add_com, add_com_alias):
	Make "name" parameter const.
	(help_cmd): Rename "command" parameter to "arg".  New const local
	"command".
	(find_cmd): Make "command" parameter const.
	(lookup_cmd_1): Make "text" parameter pointer to const.  Adjust to
	deprecated_cmd_warning prototype change.
	(undef_cmd_error): Make "cmdtype" parameter const.
	(lookup_cmd): Make "line" parameter const.
	(deprecated_cmd_warning): Change type of "text" parameter to
	pointer to const char, from pointer to pointer to char.  Adjust.
	(lookup_cmd_composition): Make "text" parameter const.
	(complete_on_cmdlist, complete_on_enum): Make "text" and "word"
	parameters const.
	* cli/cli-decode.h (struct cmd_list_element) <name>: Make field
	const.
	* cli/cli-script.c (validate_comname): Make "tem" local const.
	(define_command): New const local "tem_c".  Use it in calls to
	lookup_cmd.
	(document_command): Make "tem" and "comfull" locals const.
	(show_user_1): Make "prefix" and "name" parameters const.
	* cli-script.h (show_user_1): Make "prefix" and "name" parameters
	const.
	* command.h (add_cmd, add_alias_cmd, add_prefix_cmd)
	(add_abbrev_prefix_cmd, completer_ftype, lookup_cmd, lookup_cmd_1)
	(deprecated_cmd_warning, lookup_cmd_composition, add_com)
	(add_com_alias, add_info, add_info_alias, complete_on_cmdlist)
	(complete_on_enum, add_setshow_enum_cmd)
	(add_setshow_auto_boolean_cmd, add_setshow_boolean_cmd)
	(add_setshow_filename_cmd, add_setshow_string_cmd)
	(add_setshow_string_noescape_cmd)
	(add_setshow_optional_filename_cmd, add_setshow_integer_cmd)
	(add_setshow_uinteger_cmd, add_setshow_zinteger_cmd)
	(add_setshow_zuinteger_cmd, add_setshow_zuinteger_unlimited_cmd):
	Change prototypes, constifying strings.
	* completer.c (noop_completer, filename_completer): Make "text"
	and "prefix" parameters const.
	(location_completer, expression_completer)
	(complete_line_internal): Make "text" and "prefix" parameters
	const and adjust.
	(command_completer, signal_completer): Make "text" and "prefix"
	parameters const.
	* completer.h (noop_completer, filename_completer)
	(expression_completer, location_completer, command_completer)
	(signal_completer): Change prototypes.
	* corefile.c (complete_set_gnutarget): Make "text" and "word"
	parameters const.
	* cp-abi.c (cp_abi_completer): Likewise.
	* expression.h (parse_expression_for_completion): Change
	prototype.
	* f-lang.c (f_make_symbol_completion_list): Make "text" and "word"
	parameters const.
	* infcmd.c (_initialize_infcmd): Make "cmd_name" local const.
	* infrun.c (handle_completer): Make "text" and "word" parameters
	const.
	* interps.c (interpreter_completer): Make "text" and "word"
	parameters const.
	* language.h (struct language_defn)
	<la_make_symbol_completion_list>: Make "text" and "word"
	parameters const.
	* parse.c (parse_exp_1): Move const hack to parse_exp_in_context.
	(parse_exp_in_context): Rename to ...
	(parse_exp_in_context_1): ... this.
	(parse_exp_in_context): Reimplement, with const hack from
	parse_exp_1.
	(parse_expression_for_completion): Make "string" parameter const.
	* printcmd.c (decode_format): Make "string_ptr" parameter pointer
	to pointer to const char.  Adjust.
	(print_command_1): Make "exp" parameter const.
	(output_command): Rename to ...
	(output_command_const): ... this.  Make "exp" parameter const.
	(output_command): Reimplement.
	(x_command): Adjust.
	(display_command): Rename "exp" parameter to "arg".  New "exp"
	local, const version of "arg".
	* python/py-auto-load.c (gdbpy_initialize_auto_load): Make
	"cmd_name" local const.
	* python/py-cmd.c (cmdpy_destroyer): Cast const away in xfree
	call.
	(cmdpy_completer): Make "text" and "word" parameters const.
	(gdbpy_parse_command_name): Make "prefix_text2" local const.
	* python/py-param.c (add_setshow_generic): Make "tmp_name" local
	const.
	* remote.c (_initialize_remote): Make "cmd_name" local const.
	* symtab.c (language_search_unquoted_string): Make "text" and "p"
	parameters const.  Adjust.
	(completion_list_add_fields): Make "sym_text", "text" and "word"
	parameters const.
	(struct add_name_data) <sym_text, text, word>: Make fields const.
	(default_make_symbol_completion_list_break_on): Make "text" and
	"word" parameters const.  Adjust locals.
	(default_make_symbol_completion_list)
	(make_symbol_completion_list, make_symbol_completion_type)
	(make_symbol_completion_list_fn): Make "text" and "word"
	parameters const.
	(make_file_symbol_completion_list): Make "text", "word" and
	"srcfile" parameters const.  Adjust locals.
	(add_filename_to_list): Make "text" and "word" parameters const.
	(struct add_partial_filename_data) <text, word>: Make fields
	const.
	(make_source_files_completion_list): Make "text" and "word"
	parameters const.
	* symtab.h (default_make_symbol_completion_list_break_on)
	(default_make_symbol_completion_list, make_symbol_completion_list)
	(make_symbol_completion_type enum type_code)
	(make_symbol_completion_list_fn make_file_symbol_completion_list)
	(make_source_files_completion_list): Change prototype.
	* top.c (execute_command): Adjust to pass pointer to pointer to
	const char to lookup_cmd, and to deprecated_cmd_warning prototype
	change.
	(set_verbose): Make "cmdname" local const.
	* tracepoint.c (decode_agent_options): Make "exp" parameter const,
	and adjust.
	(validate_actionline): Make "line" parameter a pointer to const
	char, and adjust.
	(encode_actions_1): Make "action_exp" local const, and adjust.
	(encode_actions): Adjust.
	(replace_comma): Delete.
	(trace_dump_actions): Make "action_exp" and "next_comma" locals
	const, and adjust.  Don't frob the action string while splitting
	it at commas.  Instead, make a copy of each split substring in
	turn.
	(trace_dump_command): Adjust to validate_actionline prototype
	change.
	* tracepoint.h (decode_agent_options, decode_agent_options)
	(encode_actions, validate_actionline): Change prototypes.
	* valprint.h (output_command): Delete declaration.
	(output_command_const): Declare.
	* value.c (function_destroyer): Cast const away in xfree call.
2013-03-13 18:34:55 +00:00
Pedro Alves a0bcdaa75e More invalid pointer to pointer conversions.
As a follow up to:

  http://sourceware.org/ml/gdb-patches/2013-03/msg00449.html

In a nutshell, casts between 'char **' <-> 'unsigned char **' and
'char **' <-> 'const char **' are invalid.

I grepped for "\*\*) &" and found these.  There's another one in
demangle.c, but I've split fixing that one to a separate patch.

I think the ada_decode_symbol change is perhaps the one that could be
surprising.  The function's description has this comment, which makes
things much clearer:

   The GSYMBOL parameter is "mutable" in the C++ sense: logically
   const, but nevertheless modified to a semantically equivalent form
   when a decoded name is cached in it.  */

 const char *
 ada_decode_symbol (const struct general_symbol_info *gsymbol)

With that out of the way, I think the patch ends up being pretty
obvious.

Tested on x86_64 Fedora 17.

gdb/
2013-03-13  Pedro Alves  <palves@redhat.com>

	* ada-lang.c (ada_decode_symbol): Cast away constness of GSYMBOL
	rather than casting 'const char * const *' to 'const char **'.
	* ada-lex.l (processInt): Make "trailer" local const.  Remove
	'const char **' cast.
	* arm-linux-tdep.c (arm_stap_parse_special_token): Add 'char *'
	locals, and use those as strtol output pointer, instead than doing
	invalid casts to from 'const char **' to 'char **'.
	(_initialize_demangle): Remove cast.
	* i386-tdep.c (i386_stap_parse_special_token): : Add 'char *'
	locals, and use those as strtol output pointer, instead than doing
	invalid casts to from 'const char **' to 'char **'.
	* solib-dsbt.c (dsbt_get_initial_loadmaps): Remove 'gdb_byte**'
	casts.
	* stap-probe.c (stap_parse_register_operand)
	(stap_parse_single_operand): Likewise.
2013-03-13 16:45:11 +00:00
Keith Seitz bbc13ae3db * ada-lang.c (ada_read_renaming_var_value): Pass const
pointer to expression string to parse_exp_1.
	(create_excep_cond_exprs): Likewise.
	* ax-gdb.c (agent_eval_command_one): Likewise.
	(maint_agent_printf_command): Likewise.
	Constify much of the string handling/parsing.
	* breakpoint.c (set_breakpoint_condition): Pass const
	pointer to expression string to parse_exp_1.
	(update_watchpoint): Likewise.
	(parse_cmd_to_aexpr): Constify string handling.
	Pass const pointer to parse_exp_1.
	(init_breakpoint_sal): Pass const pointer to parse_exp_1.
	(find_condition_and_thread): Likewise.
	Make TOK const.
	(watch_command_1): Make "arg" const.
	Constify string handling.
	Copy the expression string instead of changing the input
	string.
	(update_breakpoint_location): Pass const pointer to
	parse_exp_1.
	* eval.c (parse_and_eval_address): Make "exp" const.
	(parse_to_comma_and_eval): Make "expp" const.
	(parse_and_eval): Make "exp" const.
	* expression.h (parse_expression): Make argument const.
	(parse_exp_1): Make first argument const.
	* findcmd.c (parse_find_args): Treat "args" as const.
	* linespec.c (parse_linespec): Pass const pointer to
	linespec_expression_to_pc.
	(linespec_expression_to_pc): Make "exp_ptr" const.
	* parse.c (parse_exp_1): Make "stringptr" const.
	Make a copy of the expression to pass to parse_exp_in_context until
	this whole interface can be constified.
	(parse_expression): Make "string" const.
	* printcmd.c (ui_printf): Treat "arg" as const.
	Handle const strings.
	* tracepoint.c (validate_actionline): Pass const pointer to
	all calls to parse_exp_1.
	(encode_actions_1): Likewise.
	* value.h (parse_to_comma_and_eval): Make argument const.
	(parse_and_eval_address): Likewise.
	(parse_and_eval): Likewise.
	* varobj.c (varobj_create): Pass const pointer to parse_exp_1.
	(varobj_set_value): Likewise.
	* cli/cli-cmds.c (disassemble_command): Treat "arg" as const and
	constify string handling.
	Pass const pointers to parse_and_eval_address and
	parse_to_comman_and_eval.
	* cli/cli-utils.c (skip_to_space): Rename to ...
	(skip_to_space_const): ... this. Handle const strings.
	* cli/cli-utils.h (skip_to_space): Turn into macro which invokes
	skip_to_space_const.
	(skip_to_space_const): Declare.
	* common/format.c (parse_format_string): Make "arg" const.
	Handle const strings.
	* common/format.h (parse_format_string): Make "arg" const.
	* gdbserver/ax.c (ax_printf): Make "format" const.
	* python/python.c (gdbpy_parse_and_eval): Do not make a copy
	of the expression string.
2013-03-12 17:39:45 +00:00
Doug Evans 4eeaa230f4 * ada-lang.c (ada_lookup_symbol_list_worker): New function, contents
of old ada_lookup_symbol_list.  In !full_search case, don't
	search superblocks.
	(ada_lookup_symbol_list): Delete arg full_search, all callers
	updated.  Call ada_lookup_symbol_list_worker.
	(ada_iterate_over_symbols): Call ada_lookup_symbol_list_worker.
	* ada-lang.h (ada_lookup_symbol_list): Update.
	* language.h (language_defn): Update comment for
	la_iterate_over_symbols.
	* linespec.c (iterate_over_file_blocks): New function.
	(iterate_over_all_matching_symtabs): Call it.
	(lookup_prefix_sym): Ditto.
	(get_current_search_block): New function.
	(get_search_block): Delete.
	(find_label_symbols): Call get_current_search_block.
	(add_matching_symbols_to_info): Call iterate_over_file_blocks.
	* symtab.c (iterate_over_symbols): Don't search superblocks.
2013-03-05 21:15:34 +00:00
Jan Kratochvil 05cba821ad gdb/
* ada-lang.c (user_select_syms): Replace symtab->filename refererences
	by symtab_to_filename_for_display calls.
	* breakpoint.c (print_breakpoint_location, resolve_sal_pc): Likewise.
	(clear_command): New variable sal_fullname, initialize it.  Replace
	compare_filenames_for_search by filename_cmp with sal_fullname.
	(say_where, update_static_tracepoint): Replace symtab->filename
	refererences by symtab_to_filename_for_display calls.
	* cli/cli-cmds.c (edit_command, list_command, ambiguous_line_spec):
	Likewise.
	* dwarf2read.c: Include source.h.
	(fixup_go_packaging): Replace symtab->filename refererences by
	symtab_to_filename_for_display calls.
	* linespec.c (add_sal_to_sals): Rename variable filename to fullname.
	Replace symtab->filename refererences by symtab_to_filename_for_display
	calls.
	(create_sals_line_offset, convert_linespec_to_sals): New variable
	fullname, initialize it, replace symtab->filename reference by the
	variable.
	* linux-fork.c: Include source.h.
	(info_checkpoints_command): Replace symtab->filename refererences by
	symtab_to_filename_for_display calls.
	* macroscope.c (sal_macro_scope): Replace symtab->filename refererences
	by symtab_to_filename_for_display calls.
	* mdebugread.c: Include source.h.
	(psymtab_to_symtab_1): Replace symtab->filename refererences by
	symtab_to_filename_for_display calls.
	* mi/mi-cmd-file.c (mi_cmd_file_list_exec_source_file)
	(mi_cmd_file_list_exec_source_files): Likewise.
	* printcmd.c: Include source.h.
	(build_address_symbolic): Replace symtab->filename refererences by
	symtab_to_filename_for_display calls.
	* psymtab.c (partial_map_symtabs_matching_filename)
	(read_psymtabs_with_fullname): Call compare_filenames_for_search also
	with psymtab_to_fullname.
	* python/py-symtab.c (stpy_str): Replace symtab->filename refererences
	by symtab_to_filename_for_display calls.
	(stpy_get_filename): New variable filename, initialize it, use instead
	of symtab->filename refererences.
	(salpy_str): Make variable filename const char *.  Replace
	symtab->filename refererences by symtab_to_filename_for_display calls.
	* skip.c: Include source.h and filenames.h.
	(skip_file_command): Remove const from the symtab variable.  Replace
	symtab->filename refererences by symtab_to_fullname call.
	(function_name_is_marked_for_skip): New variables searched_for_fullname
	and fullname.  Use them to search also with symtab's fullname.
	* source.c (find_source_lines): Replace symtab->filename refererences
	by symtab_to_filename_for_display calls.
	(print_source_lines_base): New variable filename, use it instead of
	symtab->filename.  Replace symtab->filename refererences by
	symtab_to_filename_for_display calls.
	(line_info, forward_search_command): Replace symtab->filename
	refererences by symtab_to_filename_for_display calls.
	(reverse_search_command): Replace symtab->filename refererences by
	symtab_to_filename_for_display calls.  New variable filename for it.
	* stack.c (frame_info): Likewise.
	* symmisc.c: Include source.h.
	(dump_objfile, dump_symtab_1, maintenance_print_symbols)
	(maintenance_info_symtabs): Replace symtab->filename refererences by
	symtab_to_filename_for_display calls.
	* symtab.c (iterate_over_some_symtabs): Call
	compare_filenames_for_search also with symtab_to_fullname.
	(lookup_symbol_aux_quick, basic_lookup_transparent_type_quick): Replace
	symtab->filename refererences by symtab_to_filename_for_display calls.
	(find_line_symtab): Replace symtab->filename refererences by
	symtab_to_filename_for_display calls.
	(file_matches): Replace filename_cmp by compare_filenames_for_search.
	(print_symbol_info): Make the last parameter const char *.  New
	variable s_filename.  Use it in the function.
	(symtab_symbol_info): Make the last_filename variable const char *.
	Replace symtab->filename refererences by symtab_to_filename_for_display
	calls.
	(rbreak_command): New variable fullname.  Use it.  Replace
	symtab->filename refererence by symtab_to_filename_for_display call.
	* tracepoint.c (set_traceframe_context, trace_find_line_command)
	(print_one_static_tracepoint_marker): Replace symtab->filename
	refererences by symtab_to_filename_for_display calls.
	* tui/tui-source.c (tui_set_source_content): New variables filename and
	s_filename.  Replace symtab->filename refererences by this variable.
	Replace other symtab->filename refererences by
	symtab_to_filename_for_display calls.
2013-02-03 16:13:31 +00:00
Aleksandar Ristovski f2e5f4cedf 2013-02-01 Aleksandar Ristovski <aristovski@qnx.com>
* ada-lang.c (assign_aggregate): Remove unused 'is_array_aggregate'.

Reference: http://sourceware.org/ml/gdb-patches/2013-01/msg00732.html
2013-02-01 20:06:35 +00:00
Tom Tromey 45e6c716a9 * ada-lang.h (ada_decode_symbol): Make return type const.
* ada-lang.c (ada_decode_symbol): Likewise.
2013-01-24 18:04:34 +00:00
Tom Tromey 10f0c4bbfa * symfile.h (obsavestring): Don't declare.
* symfile.c (obsavestring): Remove.
	* ada-exp.y: Use obstack_copy0, not obsavestring.
	* ada-lang.c: Use obstack_copy0, not obsavestring.
	* coffread.c: Use obstack_copy0, not obsavestring.
	* cp-namespace.c: Use obstack_copy0, not obsavestring.
	* dbxread.c: Use obstack_copy0, not obsavestring.
	* dwarf2read.c: Use obstack_copy0, not obsavestring.
	* jit.c: Use obstack_copy0, not obsavestring.
	* mdebugread.c: Use obstack_copy0, not obsavestring.
	* psymtab.c: Use obstack_copy0, not obsavestring.
	* stabsread.c: Use obstack_copy0, not obsavestring.
	* xcoffread.c: Use obstack_copy0, not obsavestring.
2013-01-21 18:13:14 +00:00
Anthony Green 843e694d6a Fixes for solaris compiler 2013-01-09 21:51:18 +00:00
Joel Brobecker 28e7fd6234 Update years in copyright notice for the GDB files.
Two modifications:
  1. The addition of 2013 to the copyright year range for every file;
  2. The use of a single year range, instead of potentially multiple
     year ranges, as approved by the FSF.
2013-01-01 06:33:28 +00:00
Jan Kratochvil f35a17b542 gdb/
* ada-lang.c (is_known_support_routine): New variable fullname.  Use
	access call to verify the symtab_to_fullname result.
	* breakpoint.c (print_breakpoint_location, update_static_tracepoint):
	Remove NULL check of symtab_to_fullname result.
	* cli/cli-cmds.c (edit_command): Likewise.
	* mi/mi-cmd-file.c (mi_cmd_file_list_exec_source_file)
	(mi_cmd_file_list_exec_source_files): Likewise.
	* python/py-symtab.c (stpy_fullname): Likewise.
	* source.c (symtab_to_fullname): Update function comment.  Rename
	variable r to fd, move it to inner block.  Always provide non-NULL
	result.
	(print_source_lines_base): Remove NULL check of symtab_to_fullname
	result.
	* stack.c (print_frame): Likewise.
	* symtab.c (iterate_over_some_symtabs, find_line_symtab, sources_info):
	Likewise.
	* tracepoint.c (print_one_static_tracepoint_marker): Likewise.

gdb/doc/
	* gdb.texinfo (GDB/MI Data Manipulation) (fullname): Make it always
	present.
	(GDB/MI File Commands) (-file-list-exec-source-files): Make the
	fullname output always present.

gdb/testsuite/
	* gdb.mi/mi-fullname-deleted.exp: New file.
2012-12-25 08:03:33 +00:00
Tom Tromey 2f68a89553 * ada-lang.c (ada_make_symbol_completion_list): Add 'code'
argument, assertion.
	* c-exp.y (typebase): Add completion productions.
	* completer.c (expression_completer): Handle tag completion.
	* expression.h (parse_expression_for_completion): Add argument.
	* f-lang.c (f_make_symbol_completion_list): Add 'code'
	argument.
	* language.h (struct language_defn)
	<la_make_symbol_completion_list>: Add 'code' argument.
	* parse.c (expout_tag_completion_type, expout_completion_name):
	New globals.
	(mark_struct_expression): Add assertion.
	(mark_completion_tag): New function.
	(parse_exp_in_context): Initialize new globals.
	(parse_expression_for_completion): Add 'code' argument.  Handle
	tag completion.
	* parser-defs.h (mark_completion_tag): Declare.
	* symtab.c (default_make_symbol_completion_list_break_on): Add
	'code' argument.  Update.
	(default_make_symbol_completion_list): Add 'code' argument.
	(make_symbol_completion_list): Update.
	(make_symbol_completion_type): New function.
	* symtab.h (default_make_symbol_completion_list_break_on)
	(default_make_symbol_completion_list): Update.
	(make_symbol_completion_type): Declare.
testsuite
	* gdb.base/break1.c (enum some_enum, union some_union): New.
	(some_enum_global, some_union_global, some_value): New globals.
	* gdb.base/completion.exp: Add tag completion tests.
2012-12-07 20:09:11 +00:00
Tom Tromey 270140bd25 * ada-exp.y (write_object_renaming, write_var_or_type)
(write_ambiguous_var, write_var_from_sym): Make blocks const.
	* ada-lang.c (replace_operator_with_call)
	(find_old_style_renaming_symbol): Make blocks const.
	* ada-lang.h (ada_find_renaming_symbol): Update.
	(struct ada_symbol_info) <block>: Now const.
	* breakpoint.c (watch_command_1): Update.
	* breakpoint.h (struct watchpoint) <exp_valid_block,
	cond_exp_valid_block>: Now const.
	* c-exp.y (classify_inner_name, classify_name): Make block
	argument const.
	* expprint.c (print_subexp_standard) <OP_VAR_VALUE>: Make 'b'
	const.
	* expression.h (innermost_block, parse_exp_1): Update.
	(union exp_element) <block>: Now const.
	* gdbtypes.c (lookup_template_type, lookup_enum, lookup_union)
	(lookup_struct): Make block argument const.
	* gdbtypes.h (lookup_template_type): Update.
	* go-exp.y (classify_name, classify_packaged_name)
	(package_name_p): Make block argument const.
	* objc-lang.c (lookup_struct_typedef): Make block argument const.
	* objc-lang.h (lookup_struct_typedef): Update.
	* parse.c (parse_exp_in_context, parse_exp_1)
	(write_exp_elt_block): Make block arguments const.
	(expression_context_block, innermost_block): Now const.
	* parser-defs.h (write_exp_elt_block): Update.
	(expression_context_block, innermost_block, block_found): Now
	const.
	* printcmd.c (struct display) <block>: Now const.
	* symtab.h (lookup_struct, lookup_union, lookup_enum): Update.
	* valops.c (address_of_variable): Make block argument const.
	* value.h (value_of_variable): Update.
	* varobj.c (struct varobj_root) <valid_block>: Now const.
2012-12-03 19:59:14 +00:00
Jerome Guitton ac4a2da45d Strip interface tags from visible fields
The following Ada type:

   type Circle is new Shape and Drawable with record
        Center : Point;
        Radius : Natural;
   end record;

...is displayed as follow in GDB:

 (gdb) ptype circle
 type = new classes.shape with record
     V51s: ada.tags.interface_tag;
     center: classes.point;
     radius: natural;
 end record

V51s is an internal field that is of no interest for the user. It should
not be displayed.

gdb/ChangeLog:

	* ada-lang.c (ada_is_interface_tag): New function.
	(ada_is_ignored_field): Add interface tags to the list
	of ignored fields.
2012-11-29 16:29:54 +00:00
Jerome Guitton b50d69b5aa Full view of interface-wide types
For displaying the full view of a class-wide object, GDB relies on
the assumption that this view will have the same address as the
address of the object. In the case of simple inheritance, this
assumption is correct; the proper type is deduced by decoding
the tag of the object and converting the result to this full-view
type.

Consider for example an abstract class Shape, a child Circle
which implements an interface Drawable, and the corresponding
following objects:

   My_Circle   : Circle := ((1, 2), 3);
   My_Shape    : Shape'Class := Shape'Class (My_Circle);
   My_Drawable : Drawable'Class := Drawable'Class (My_Circle);

To display My_Shape, the debugger first extracts the tag (an internal
field, usually the first one of the record):

 (gdb) p my_shape'address
 $2 = (system.address) 0x8063e28
 (gdb) x/x my_shape'address
 0x8063e28 <classes__my_shape>: 0x08059ec4

Then the type specific data and the expanded name of the tag is read
from there:

 (gdb) p my_shape'tag
 $3 = (access ada.tags.dispatch_table) 0x8059ec4 (classes.circle)

To get the full view, the debugger converts to the corresponding type:

 (gdb) p {classes.circle}0x8063e28
 $4 = (center => (x => 1, y => 2), radius => 3)

Now, in the case of multiple inheritance, the assumption does not hold
anymore. The address that we have usually points to some
place lower. The offset to the original address is saved in the field
Offset_To_Top of the metadata that are above the tag, at address
obj'tag - 8. In the case of my_shape, this offset is 0:

 (gdb) x/x my_shape'tag - 8
 0x8059ebc <classes__circleT+12>:        0x00000000

...but in the case of an interface-wide object, it is not null:

 (gdb) x/x my_drawable'tag - 8
 0x8063b28 <classes__classes__circle_classes__drawable1T56s+12>: 0x00000004
 (gdb) p {classes.circle}(my_drawable'address - 4)
 $7 = (center => (x => 1, y => 2), radius => 3)

The following change handles this relocation in the most common cases.
Remaining cases that are still to be investigated are signaled by
comments.

gdb/ChangeLog:

	* ada-lang.h (ada_tag_value_at_base_address): New function
	declaration.
	* ada-lang.c (is_ada95_tag, ada_tag_value_at_base_address):
	New functions.
	(ada_to_fixed_type_1, ada_evaluate_subexp): Let ada_tag_base_address
	relocate the class-wide value if need be.
	(ada_value_struct_elt, ada_value_ind, ada_coerce_ref):
	Let ada_tag_value_at_base_address relocate the class-wide access/ref
	before dereferencing it.
	* ada-valprint.c (ada_val_print_1): Relocate to base address
	before displaying the content of an interface-wide ref.

gdb/testsuite/ChangeLog:

        * gdb.ada/ptype_tagged_param.exp: Adjust expected output in
        ptype test.
2012-11-29 16:28:10 +00:00
Jerome Guitton ca1f964d4b Handle other cases than EVAL_NORMAL in the default case
In the evaluation of an expression in Ada mode, the default case
unwraps the argument unconditionally. For an object of a variant
record type, this unwrapping builds a fixed type from the
specification of the variant type and the actual values of the
object's discriminants.  It means that unwrapping needs the "proper"
value for the object, not just a zero value with the proper type.

When not in EVAL_NORMAL, we cannot assume that the evaluation returns
such a proper value; it may well return a zero value of the
appropriate type e.g in EVAL_AVOID_SIDE_EFFECTS. It is wrong to try to
unwrap in that case.

In particular, a problem shows up when using expression of the form
{VARIANT_TYPE}OBJ. GDB first evaluates this expression in
EVAL_AVOID_SIDE_EFFECTS to compute the type, the evaluation of OBJ
in most cases returns a zero value of its type, and as UNOP_MEMVAL
is mapped to the default case its evaluation ends up trying to
read memory around address 0.

gdb/ChangeLog:

	* ada-lang.c (ada_evaluate_subexp): Unwrap only in EVAL_NORMAL.
2012-11-29 16:26:12 +00:00
Tom Tromey 210bbc17ac * ada-lang.c (user_select_syms): Use SYMBOL_SYMTAB.
* dwarf2read.c (dw2_find_symbol_file, fixup_go_packaging): Use
	SYMBOL_SYMTAB.
	* skip.c (skip_info): Use SYMBOL_SYMTAB.
2012-11-26 15:54:29 +00:00
Tom Tromey 79d43c6168 * ada-lang.c (user_select_syms, ada_print_subexp): Pass flags
to type-printing functions.
	* ada-lang.h (ada_print_type): Add argument.
	* ada-typeprint.c (print_array_type, print_variant_clauses,
	print_variant_part, print_selected_record_field_types,
	print_record_field_types, print_unchecked_union_type,
	print_func_type, ada_print_type): Add flags argument.
	(ada_print_typedef): Update.
	* c-exp.y (OPERATOR conversion_type_id): Update.
	* c-lang.h (c_print_type, c_type_print_base): Update.
	* c-typeprint.c (c_print_type, c_type_print_varspec_prefix,
	c_type_print_modifier, c_type_print_args,
	c_type_print_varspec_suffix, c_type_print_base): Add flags
	argument.
	* cp-valprint.c (cp_print_class_member): Update.
	* dwarf2read.c (dwarf2_compute_name): Update.
	* f-lang.h (f_print_type): Add argument.
	* f-typeprint.c (f_print_type): Add flags argument.
	* gnu-v3-abi.c (gnuv3_print_method_ptr): Update.
	* go-lang.h (go_print_type): Add argument.
	* go-typeprint.c (go_print_type): Add flags argument.
	* jv-lang.h (java_print_type): Add argument.
	* jv-typeprint.c (java_type_print_base, java_print_type): Add
	flags argument.
	* language.c (unk_lang_print_type): Add flags argument.
	* language.h (struct language_defn) <la_print_type>: Add flags
	argument.
	(LA_PRINT_TYPE): Likewise.
	* m2-lang.h (m2_print_type): Add argument.
	* m2-typeprint.c (m2_print_type, m2_range, m2_typedef,
	m2_array, m2_pointer, m2_ref, m2_procedure, m2_long_set,
	m2_unbounded_array, m2_record_fields): Add flags argument.
	* p-lang.h (pascal_print_type, pascal_type_print_base,
	pascal_type_print_varspec_prefix): Add argument.
	* p-typeprint.c (pascal_print_type,
	pascal_type_print_varspec_prefix, pascal_print_func_args,
	pascal_type_print_varspec_suffix, pascal_type_print_base): Add
	flags argument.
	* symmisc.c (print_symbol): Update.
	* typeprint.c (type_print_raw_options, default_ptype_flags):
	New globals.
	(type_print): Update.
	* typeprint.h (struct type_print_options): New.
	(type_print_raw_options): Declare.
	(c_type_print_varspec_suffix, c_type_print_args): Add argument.
2012-11-12 17:14:55 +00:00
Joel Brobecker f69c91ad24 [Ada] use lbasename when testing if file is part of Ada runtime.
We use a list of regular expressions to match a symtab filenames
against the names of the files in the Ada runtime.  These regular
expressions do assume that the filename is a basename, however.
So make sure to evaluate these regular expressions against
the symtab's filename.

Without this patch, we run into problems when the Ada runtime was built
using a project file (through gprbuild).

gdb/ChangeLog:

        * ada-lang.c (is_known_support_routine): Use lbasename when
        matching the symtab's filename against
        known_runtime_file_name_patterns.
2012-10-24 18:17:22 +00:00
Joel Brobecker d99dcf51e1 [Ada] Allow assignment to wide string.
Given the following variable declaration...

   Www : Wide_String := "12345";

... this patch allows the following assignment to work:

   (gdb) set variable www := "qwert"

Without this patch, the debugger rejects the assignment because
the size of the array elements are different:

   (gdb) set www := "asdfg"
   Incompatible types in assignment

(on the lhs, we have an array of 2-bytes elements, and on the rhs,
we have a standard 1-byte string).

gdb/ChangeLog:

        * ada-lang.c (ada_same_array_size_p): New function.
        (ada_promote_array_of_integrals): New function.
        (coerce_for_assign): Add handling of arrays where the elements
        are integrals of a smaller size than the size of the target
        array element type.

gdb/testsuite/ChangeLog:

        * gdb.ada/set_wstr: New testcase.
2012-10-24 18:14:23 +00:00
Joel Brobecker 5ded533171 [Ada] Pointers to unconstrained arrays inside variant record.
gdb/ChangeLog:

        * ada-lang.c (ada_template_to_fixed_record_type_1): Do not
        strip typedef layer when computing the fixed type's field type,
        only when computing its size.

gdb/testsuite/ChangeLog:

        * gdb.ada/unc_arr_ptr_in_var_rec: New testcase.
2012-10-24 18:06:10 +00:00
Joel Brobecker 2fa15f237d crash printing optimized out variant type
Assuming the following declarations:

   type Discriminants_Record (A : Integer; B : Boolean) is record
      C : Float;
   end record;
   Z : Discriminants_Record := (A => 1, B => False, C => 2.0);

If variable Z is not used, and the compiler optimizes it out,
GDB would crash as follow:

    (gdb) print Z
    /[...]/gdb/valops.c:1121: internal-error: Unexpected lazy value type.

This is because the ada-lang module forgot to set the optimized_out
flag in the value returned by ada_evaluate_subexp during the value's
"fixing" process.  Later on, when trying to print the resulting value,
GDB finds that the value is still lazily allocated, and thus tries to
fetch it. But this is not allowed for not_lval values, hence the internal
error.

gdb/ChangeLog:

        * ada-lang.c (coerce_unspec_val_to_type): Make sure that
        the optimized_out flag is preserved.

gdb/testsuite/ChangeLog:

        * gdb.ada/optim_drec: New testcase.
2012-09-10 22:18:24 +00:00
Tom Tromey 8e260fc026 * auto-load.c (_initialize_auto_load): Update.
* solib-svr4.c (_initialize_svr4_solib): Update
	* solib-dsbt.c (_initialize_dsbt_solib): Update.
	* solib-darwin.c (_initialize_darwin_solib): Update.
	* registry.h: New file.
	* python/py-progspace.c (gdbpy_initialize_pspace): Update.
	* python/py-inferior.c (gdbpy_initialize_inferior): Update.
	* progspace.h: Include registry.h.  Use DECLARE_REGISTRY.
	(register_program_space_data_with_cleanup)
	(register_program_space_data, program_space_alloc_data)
	(clear_program_space_data, set_program_space_data)
	(program_space_data): Don't declare.
	* progspace.c: Use DEFINE_REGISTRY.
	(struct program_space_data, struct
	program_space_data_registration, struct
	program_space_data_registry, program_space_data_registry)
	(register_program_space_data_with_cleanup)
	(register_program_space_data, program_space_alloc_data)
	(program_space_free_data, clear_program_space_data)
	(set_program_space_data, program_space_data): Remove.
	* objfiles.h: Include registry.h.  Use DECLARE_REGISTRY.
	(struct objfile) <data, num_data>: Replace with REGISTRY_FIELDS.
	(register_objfile_data_with_cleanup, register_objfile_data)
	(clear_objfile_data, set_objfile_data, objfile_data): Don't
	declare.
	* objfiles.c: Use DEFINE_REGISTRY.
	(struct objfile_data, struct objfile_data_registration, struct
	objfile_data_registry, objfile_data_registry)
	(register_objfile_data_with_cleanup, register_objfile_data)
	(objfile_alloc_data, objfile_free_data, clear_objfile_data)
	(set_objfile_data, objfile_data): Remove.
	(_initialize_objfiles): Update.
	* jit.c (_initialize_jit): Update.
	* inflow.c (_initialize_inflow): Update.
	* inferior.h: Include registry.h.  Use DECLARE_REGISTRY.
	(struct inferior) <data, num_data>: Replace with REGISTRY_FIELDS.
	(register_inferior_data_with_cleanup, register_inferior_data)
	(clear_inferior_data, set_inferior_data, inferior_data): Don't
	declare.
	* inferior.c: Use DEFINE_REGISTRY.
	(struct inferior_data, struct inferior_data_registration, struct
	inferior_data_registry, inferior_data_registry)
	(register_inferior_data_with_cleanup, register_inferior_data)
	(inferior_alloc_data, inferior_free_data  clear_inferior_data)
	(set_inferior_data, inferior_data): Remove.
	* auxv.c (_initialize_auxv): Update.
	* ada-lang.c (_initialize_ada_language): Update.
	* breakpoint.c (_initialize_breakpoint): Update.
	* i386-nat.c (i386_use_watchpoints): Update.
2012-08-22 15:17:21 +00:00
Keith Seitz a451cb65e3 PR c++/13356
* gdbtypes.c (strict_type_checking): New variable.
	(show_strict_type_checking): New function.
	(rank_one_type): Return NS_POINTER_INTEGER_CONVERSION_BADNESS
	if strict type checking is disabled.
	(_initialize_gdbtypes): Add "check type" subcommand.
	* gdbtypes.h (NS_INTEGER_POINTER_CONVERSION_BADNESS): New struct.

	PR c++/13356
	* gdb.base/default.exp: Update all "check type" tests.
	* gdb.base/help.exp: Likewise.
	* gdb.base/setshow.exp: Likewise.
	* gdb.cp/converts.cc (foo1_type_check): New function.
	(foo2_type_check): New function.
	(foo3_type_check): New function.
	(main): Call new functions.
	* converts.exp: Add tests for integer-to-pointer conversions
	with/without strict type-checking.

	PR c++/13356
	* gdb.texinfo (Type and Range Checking): Remove warning.
	Remove spurious commas.
	Update text and examples for re-implementation of set/show
	check type.
	(C and C++ Type and Range Checks): Likewise.

	* language.h (type_mode): Remove.
	(type_check): Remove.
	(struct language_defn): Remove la_type_check.
	(STRICT_TYPE): Remove unused macro.
	(type_error): Remove.
	* language.c (set_type_range_case): Renamed to ...
	(set_range_case): ... this.  Update all callers.
	Remove type_mode/type_check.
	(type_mode): Remove.
	(type_check): Remove.
	(show_type_command): Remove.
	(set_type_command): Remove.
	(language_info): Remove type checking output.
	(type_error): Remove unused function.
	(range_error): Update comment.
	(unknown_language_defn): Remove la_type_check.
	(auto_language_defn): Likewise.
	(local_language_defn): Likewise.
	(_initialize_language): Remove "check type" subcommand.
	* ada-lang.c (ada_language_defn): Remove la_type_check.
	* c-lang.c (c_language_defn): Likewise.
	(cplus_language_defn): Likewise.
	(asm_language_defn): Likewise.
	(minimal_language_defn): Likewise.
	* d-lang.c (d_language_defn): Likewise.
	* f-lang.c (f_language_defn): Likewise.
	* go-lang.c (go_language_defn): Likewise.
	* jv-lang.c (java_language_defn): Likewise.
	* m2-lang.c (m2_language_defn): Likewise.
	* objc-lang.c (objc_language_defn): Likewise.
	* opencl-lang.c (opencl_language_defn): Likewise.
	* p-lang.c (pascal_language_defn): Likewise.
2012-08-17 17:37:03 +00:00
Tom Tromey 1bb9788dbb PR macros/7961:
* varobj.c (varobj_create): Update.
	(varobj_set_value): Update.
	* tracepoint.c (validate_actionline): Update.
	(encode_actions_1): Update.
	* parse.c (parse_exp_1): Add 'pc' argument.
	(parse_exp_in_context): Add 'pc' argument.  Change how
	expression_context_pc is set.
	(parse_expression): Update.
	(parse_field_expression): Update.
	* expression.h (parse_exp_1): Update.
	* eval.c (parse_to_comma_and_eval): Update.
	* breakpoint.c (set_breakpoint_condition): Update.
	(update_watchpoint): Update.
	(init_breakpoint_sal): Update
	(find_condition_and_thread): Update.
	(watch_command_1): Update.
	(update_breakpoint_locations): Update.
	* ada-lang.c (ada_read_renaming_var_value): Update.
	(create_excep_cond_exprs): Update.
testsuite
	* gdb.base/macscp1.c (macscp_expr): Add breakpoint comment.
	* gdb.base/macscp.exp (maybe_kfail): Add test for macro scope.
2012-06-27 18:08:41 +00:00
Yao Qi 972daa01e2 gdb:
* corefile.c (write_memory_with_notification): New.
	* gdbcore.h: Declare write_memory_with_notification.
	* ada-lang.c (ada_value_assign): Replace 'write_memory' and
	'observer_notify_memory_changed' with 'write_memory_with_notification'.
	* valops.c (value_assign): Likewise.
	* python/py-inferior.c (infpy_write_memory): Call
	'write_memory_with_notification'.
2012-06-24 07:28:10 +00:00
Tom Tromey 49c4e619f8 * ada-lang.c (ada_make_symbol_completion_list): Return a VEC.
* breakpoint.c (catch_syscall_completer): Return a VEC.
	* cli/cli-cmds.c (complete_command): Update.
	* cli/cli-decode.c (complete_on_cmdlist): Return a VEC.
	(complete_on_enum): Likewise.
	* command.h: Include gdb_vecs.h.
	(completer_ftype): Change return type.
	(complete_on_cmdlist, complete_on_enum): Likewise.
	* completer.c (noop_completer, filename_completer)
	(location_completer): Return a VEC.
	(add_struct_fields): Remove 'nextp' argument.  Change 'output'
	to a VEC.
	(expression_completer, complete_line_internal, complete_line)
	(command_completer): Return a VEC.
	(gdb_completion_word_break_characters, line_completion_function):
	Update.
	* completer.h: Include gdb_vecs.h.
	(complete_line, noop_completer, filename_completer)
	(expression_completer, location_completer, command_completer):
	Update.
	* f-lang.c (f_word_break_characters): Return a VEC.
	* interps.c (interpreter_completer): Return a VEC.
	* language.h (struct language_defn)
	<la_make_symbol_completion_list>: Return a VEC.
	* python/py-cmd.c (cmdpy_completer): Return a VEC.
	* symtab.c (free_completion_list): Take a VEC.
	(return_val_size, return_val_index): Remove.
	(return_val): Now a VEC.
	(completion_list_add_name): Update.
	(default_make_symbol_completion_list_break_on)
	(default_make_symbol_completion_list, make_symbol_completion_list)
	(make_symbol_completion_list_fn, make_file_symbol_completion_list):
	Return a VEC.
	(add_filename_to_list): Update.
	(struct add_partial_filename_data) <list_used, list_alloced>: Remove.
	<list>: Now a VEC.
	(maybe_add_partial_symtab_filename): Update.
	(make_source_files_completion_list): Return a VEC.
	* symtab.h (default_make_symbol_completion_list_break_on)
	(default_make_symbol_completion_list, make_symbol_completion_list)
	(make_symbol_completion_list_fn, make_file_symbol_completion_list)
	(make_source_files_completion_list): Update.
2012-06-13 15:47:16 +00:00
Matthew Gretton-Dann acbd605ddd * gdb/ada-lang.c (standard_lookup): Prevent uninitialized variable
warning.
2012-05-31 09:34:40 +00:00
Tom Tromey b1af9e9750 PR c++/7173:
* gnu-v3-abi.c (gnuv3_baseclass_offset): Return early for Java
	types.
	* value.h (value_cast_pointers): Update.
	* valops.c (value_cast_pointers): Add 'subclass_check' argument.
	(value_cast): Update.
	(update_search_result): New function.
	(do_search_struct_field): New, from search_struct_field.  Check
	for ambiguous results.
	(search_struct_field): Rewrite.
	* infcall.c (value_arg_coerce): Update.
	* eval.c (evaluate_subexp_standard) <STRUCTOP_MEMBER>: Use
	value_cast_pointers.
	* ada-lang.c (ada_convert_actual): Update.
testsuite
	* gdb.cp/inherit.exp (test_print_mi_members): Expect errors.
	Remove kfails.
	(test_print_mi_member_types): Likewise.
2012-05-21 19:47:54 +00:00
Sergio Durigan Junior 22e048c9dd 2012-05-18 Sergio Durigan Junior <sergiodj@redhat.com>
* ada-lang.c:
	* ada-tasks.c:
	* ada-varobj.c:
	* amd64-darwin-tdep.c:
	* arm-symbian-tdep.c:
	* arm-tdep.c:
	* avr-tdep.c:
	* ax-gdb.c:
	* bfin-linux-tdep.c:
	* breakpoint.c:
	* c-valprint.c:
	* cli/cli-cmds.c:
	* coffread.c:
	* cp-support.c:
	* cris-tdep.c:
	* dwarf2-frame-tailcall.c:
	* dwarf2-frame.c:
	* dwarf2expr.c:
	* dwarf2loc.c:
	* dwarf2read.c:
	* elfread.c:
	* eval.c:
	* expprint.c:
	* f-valprint.c:
	* frv-tdep.c:
	* h8300-tdep.c:
	* hppa-hpux-tdep.c:
	* hppa-tdep.c:
	* hppanbsd-tdep.c:
	* i386-nto-tdep.c:
	* i386-tdep.c:
	* i387-tdep.c:
	* ia64-tdep.c:
	* jit.c:
	* linespec.c:
	* linux-tdep.c:
	* lm32-tdep.c:
	* m2-valprint.c:
	* m32c-tdep.c:
	* m32r-rom.c:
	* m32r-tdep.c:
	* m68k-tdep.c:
	* m68klinux-tdep.c:
	* mi/mi-main.c:
	* microblaze-tdep.c:
	* mips-linux-tdep.c:
	* mips-tdep.c:
	* mn10300-tdep.c:
	* p-valprint.c:
	* parse.c:
	* ppc-linux-tdep.c:
	* ppc-sysv-tdep.c:
	* printcmd.c:
	* python/py-finishbreakpoint.c:
	* python/py-inferior.c:
	* python/py-infthread.c:
	* python/py-type.c:
	* python/python.c:
	* remote-fileio.c:
	* remote-m32r-sdi.c:
	* remote-mips.c:
	* reverse.c:
	* rl78-tdep.c:
	* rs6000-aix-tdep.c:
	* rs6000-tdep.c:
	* s390-tdep.c:
	* score-tdep.c:
	* sh64-tdep.c:
	* skip.c:
	* solib-darwin.c:
	* solib-dsbt.c:
	* solib-frv.c:
	* sparc-tdep.c:
	* spu-multiarch.c:
	* spu-tdep.c:
	* stack.c:
	* symfile.c:
	* symtab.c:
	* tic6x-tdep.c:
	* tracepoint.c:
	* v850-tdep.c:
	* valarith.c:
	* valprint.c:
	* value.c:
	* xcoffread.c:
	* xtensa-tdep.c:
	* ada-lang.c:
	* ada-tasks.c:
	* ada-varobj.c:
	* amd64-darwin-tdep.c:
	* arm-symbian-tdep.c:
	* arm-tdep.c: Delete unused variables.
2012-05-18 21:02:52 +00:00
Tom Tromey 8157b174fd * tracepoint.c (scope_info): Update.
* symtab.c (lookup_block_symbol, iterate_over_symbols)
	(find_pc_sect_symtab, search_symbols)
	(default_make_symbol_completion_list_break_on)
	(make_file_symbol_completion_list): Update.
	* symmisc.c (dump_symtab_1): Update.
	* stack.c (print_frame_args, iterate_over_block_locals)
	(print_frame_labels, iterate_over_block_arg_vars): Update.
	* python/py-block.c (block_object) <dict>: Remove.
	<block>: New field.
	<iter>: Change type.
	(blpy_iter): Update.
	(blpy_block_syms_iternext): Update.
	* psymtab.c (map_block): Use block iterators.
	* objfiles.c (objfile_relocate1): Use ALL_DICT_SYMBOLS.
	* mi/mi-cmd-stack.c (list_args_or_locals): Update.
	* mdebugread.c (parse_symbol, mylookup_symbol): Update.
	* infrun.c (check_exception_resume): Update.
	* cp-support.c (make_symbol_overload_list_block): Update.
	* coffread.c (patch_opaque_types): Update.
	* buildsym.c (finish_block, end_symtab): Use ALL_DICT_SYMBOLS.
	* block.h (struct block_iterator): New.
	(block_iterator_first, block_iterator_next, block_iter_name_first)
	(block_iter_name_next, block_iter_match_first)
	(block_iter_match_next): Declare.
	(ALL_BLOCK_SYMBOLS): Redefine.
	* block.c (block_iterator_first, block_iterator_next)
	(block_iter_name_first, block_iter_name_next)
	(block_iter_match_first, block_iter_match_next): New functions.
	* ada-lang.c (ada_add_block_symbols)
	(ada_make_symbol_completion_list): Use block iterator.
2012-05-10 19:50:09 +00:00
Paul N. Hilfinger c8ea197278 Add proper handling for internal functions and STT_GNU_IFUNC symbols in Ada mode.
The code for handling calls to internal functions (esp., Python
functions) and for handling STT_GNU_IFUNC had not been added to the Ada
expression evaluator.  This change adapts them from eval.c.

gdb/Changelog:

        * ada-lang.c (ada_evaluate_subexp): Add cases for
          TYPE_CODE_INTERNAL_FUNCTION and for TYPE_GNU_IFUNC, following
          their treatment in eval.c.
2012-04-21 22:12:59 +00:00
Jan Kratochvil 14e75d8ea4 gdb/
PR symtab/7259:
	* ada-exp.y (convert_char_literal): Use TYPE_FIELD_ENUMVAL.
	* ada-lang.c (ada_discrete_type_high_bound)
	(ada_discrete_type_low_bound): Use TYPE_FIELD_ENUMVAL for
	TYPE_CODE_ENUM.
	(ada_identical_enum_types_p): Use TYPE_FIELD_ENUMVAL.
	(pos_atr, value_val_atr): Use TYPE_FIELD_ENUMVAL for TYPE_CODE_ENUM.
	* ada-typeprint.c (print_enum_type): Change variable lastval to LONGEST.
	Use TYPE_FIELD_ENUMVAL.
	* ada-valprint.c (print_optional_low_bound, ada_print_scalar)
	(ada_val_print_1): Use TYPE_FIELD_ENUMVAL for TYPE_CODE_ENUM.
	* c-typeprint.c (c_type_print_base): Move variable lastval to inner
	block, change it to LONGEST.  Use TYPE_FIELD_ENUMVAL for
	TYPE_CODE_ENUM.
	* coffread.c (coff_read_enum_type): Use SET_FIELD_ENUMVAL.
	* dwarf2read.c (process_enumeration_scope): Likewise.
	* gdb-gdb.py (TypeFlagsPrinter): Use field.enumval instead of
	field.bitpos.
	(class StructMainTypePrettyPrinter): Support also
	FIELD_LOC_KIND_ENUMVAL.
	* gdbtypes.c (get_discrete_bounds): Use TYPE_FIELD_ENUMVAL for
	TYPE_CODE_ENUM.
	(recursive_dump_type): Use TYPE_FIELD_ENUMVAL for TYPE_CODE_ENUM.
	(copy_type_recursive): Support also FIELD_LOC_KIND_ENUMVAL.
	* gdbtypes.h (enum field_loc_kind): New FIELD_LOC_KIND_ENUMVAL.
	(struct main_type.flds_bnds.fields.loc): Adjust bitpos comment.  New
	field enumval.
	(struct main_type.flds_bnds.bields): Adjust loc_kind and bitsize to
	accommodate enumval.
	(struct call_site): Adjust loc_kind to accommodate enumval.
	(FIELD_ENUMVAL, FIELD_ENUMVAL_LVAL, SET_FIELD_ENUMVAL)
	(TYPE_FIELD_ENUMVAL): New macros.
	* m2-typeprint.c (m2_enum): Use TYPE_FIELD_ENUMVAL.
	* mdebugread.c (parse_symbol): Use TYPE_FIELD_ENUMVAL for
	TYPE_CODE_ENUM.
	* p-typeprint.c (pascal_type_print_base): Likewise.
	* python/lib/gdb/printing.py (class FlagEnumerationPrinter): Use
	enumval.
	* python/lib/gdb/types.py (make_enum_dict): Likewise.
	* python/py-type.c (convert_field): New variable addrstring.  Use
	TYPE_FIELD_ENUMVAL for TYPE_CODE_ENUM.
	(check_types_equal): Support also FIELD_LOC_KIND_ENUMVAL.
	* stabsread.c (read_enum_type): Use SET_FIELD_ENUMVAL.
	* typepint.c (print_type_scalar): Use TYPE_FIELD_ENUMVAL for
	TYPE_CODE_ENUM.
	* valprint.c (generic_val_print): Likewise.

gdb/testsuite/
	PR symtab/7259:
	* gdb.base/enumval.c: New test case.
	* gdb.base/enumval.exp: New test case.
	* gdb.python/py-type.exp (test_enums): Use field.enumval instead of
	field.bitpos.
2012-04-18 06:46:47 +00:00
Jan Kratochvil 945b3a3230 gdb/
Do not rely on FIELD_LOC_KIND_BITPOS being zero.
	* ada-lang.c (ada_template_to_fixed_record_type_1): Replace
	TYPE_FIELD_BITPOS used as lvalue by SET_FIELD_BITPOS.
	* gdbtypes.c (append_flags_type_flag): Likewise, twice.
	* jv-lang.c (java_link_class_type): Likewise, once.
	* stabsread.c (read_enum_type): Likewise.
2012-04-17 12:43:20 +00:00
Joel Brobecker b1ed564ad0 Rename variables in ada-lang.c:ada_make_symbol_completion_list.
This renaming allows us to have variable names that are consistent
with the names of the parameters in the functions where these
variables are used.  This also allows us to avoid a -Wshadow warning
in the case of variable "wild_match", which is now renamed to
"wild_match_p".

gdb/ChangeLog:

        -Wshadow warning fix.
        * ada-lang.c (ada_make_symbol_completion_list): Rename parameters
        "wild_match" and "encoded" into "wild_match_p" and "encoded_p".
        Adjust code accordingly.
2012-03-29 23:30:55 +00:00
Joel Brobecker cb8e9b977e Rename "encoded" parameter in ada-lang.c:symbol_completion_add...
... This is mostly to be consistent with the style used for the other
parameter of the same kind ("wild_match_p") in that function.

gdb/ChangeLog:

        * ada-lang.c (symbol_completion_add): Rename parameter
        "encoded" into "encoded_p".  Ajust code and documentation
        accordingly.
2012-03-29 23:30:46 +00:00
Joel Brobecker c0af17067c Rename "wild_match" parameter in ada-lang.c:symbol_completion_add...
... to avoid a -Wshadow warning.

gdb/ChangeLog:

        -Wshadow warning fix.
        * ada-lang.c (symbol_completion_add): Rename parameter
        "wild_match" into wild_match_p.  Update code and documentation
        accordingly.
2012-03-29 23:30:38 +00:00
Joel Brobecker 6ea35997bf Rename "encoded" parameter in ada-lang.c:symbol_completion_match...
... This is mostly to be consistent with the style used for the other
parameter of the same kind ("wild_match_p") in that function.

gdb/ChangeLog:

        * ada-lang.c (symbol_completion_match): Rename parameter
        "encoded" into "encoded_p".  Ajust code and documentation
        accordingly.
2012-03-29 23:30:29 +00:00
Joel Brobecker e701b3c0f9 Rename "wild_match" parameter in ada-lang.c:symbol_completion_match
gdb/ChangeLog:

        -Wshadow warning fix.
        * ada-lang.c (symbol_completion_match): Rename parameter
        "wild_match" into "wild_match_p".  Adjust code and function
        documentation accordingly.
2012-03-29 23:30:21 +00:00
Joel Brobecker 5e2336be92 rename "symbol_info" to "sym_info" in ada-lang.c...
... to avoid a -Wshadow warning with a symbol exported by BFD.

gdb/ChangeLog:

        -Wshadow warning fix.
        * ada-lang.c (ada_lookup_encoded_symbol): Rename parameter
        "symbol_info" into "info".  Adjust code accordingly.
        (ada_lookup_symbol): Likewise.
2012-03-29 23:30:13 +00:00
Joel Brobecker 9f88c95977 Minor reformatting of ada_lookup_symbol_list's documentation.
This patch mostly removes a few trailing spaces.

gdb/ChangeLog:

        * ada-lang.c (ada_lookup_symbol_list): Minor reformatting
        of this function's documentation.
2012-03-29 23:30:04 +00:00
Joel Brobecker 82ccd55ec1 Rename "wild_match" variable in ada-lang.c:ada_lookup_symbol_list
... to avoid -Wshadow warning...

gdb/ChangeLog:

        -Wshadow warning fix.
        * ada-lang.c (ada_lookup_symbol_list): Rename "wild_match"
        variable into "wild_match_p".  Adjust code accordingly.
2012-03-29 23:29:56 +00:00
Joel Brobecker d0a8ab18c7 Rename "wild_match" parameter in ada-lang.c:ada_add_local_symbols
... to avoid -Wshadow warning...

gdb/ChangeLog:

        -Wshadow warning fix.
        * ada-lang.c (ada_add_local_symbols): Rename "wild_match"
        parameter into "wild_match_p".  Adjust code accordingly.
        Document this parameter in the function description.
2012-03-29 23:29:47 +00:00
Joel Brobecker 48b7833268 Rename "wild_match" parameter in add_symbols_from_enclosing_procs
gdb/ChangeLog:

        -Wshadow warning fix.
        * ada-lang.c (add_symbols_from_enclosing_procs): Rename
        "wild_match" parameter to "wild_match_p" (-Wshadow).
2012-03-29 23:29:37 +00:00
Joel Brobecker 2e6e035354 Remove trailing spaces in ada-lang.c:ada_lookup_simple_minsym doc.
gdb/ChangeLog:

        * ada-lang.c (ada_lookup_simple_minsym): Remove trailing spaces
        in function documentation.
2012-03-29 23:29:28 +00:00
Joel Brobecker dc4024cd3f Fix -Wshadow warning in ada-lang.c:ada_lookup_simple_minsym
gdb/ChangeLog:

        -Wshadow warning fix.
        * ada-lang.c (ada_lookup_simple_minsym): Rename wild_match local
        variable into wild_match_p.  Adjust code accordingly.
2012-03-29 23:29:19 +00:00
Joel Brobecker 4e5c77fe1a Make ada_lookup_encoded_symbol "return" a struct ada_symbol_info
This makes ada_lookup_encoded_symbol more consistent with other functions
such as ada_lookup_symbol_list, and also makes it clearer in the code
using that function that symbol and block are related.

gdb/ChangeLog:

        * ada-lang.c (ada_lookup_encoded_symbol): Now returns void.
        Replace block_found argument by symbol_info.  Adjust
        implementation accordingly.  Add function documentation.
        (ada_lookup_symbol): Adjust to new ada_lookup_encoded_symbol.
        Fix documentation.
        * ada-lang.h (ada_lookup_encoded_symbol): Update declaration.
        * ada-exp.y (write_object_renaming): Adjust to new
        ada_lookup_encoded_symbol API.
2012-03-29 18:23:00 +00:00
Joel Brobecker 53ba833325 [Ada] Crash when trying to set value of packed array element
Consider the following declaration:

   type Small is new Integer range 0 .. 2 ** 4 - 1;
   type Simple_Array is array (1 .. 4) of Small;
   pragma Pack (Simple_Array);

   SA : Simple_Array := (1, 2, 3, 4);

Trying to change the value of one of the elements in the packed array
causes the debugger to crash:

    (gdb) set sa(3) := 9
    [1]    4880 segmentation fault  gdb -q foo

The circumstances leading to the crash are as follow:

   . ada_evaluate_subexp creates a value corresponding to "sa(3)".

   . ada_evaluate_subexp then tries to assign 9 to this value, and
     for this calls value_assign (via ada_value_assign).

   . Because the array is packed, the destination value is 3 bits long,
     and as a result, value_assign uses the parent to determine that
     element byte address and offset:

      | if (value_bitsize (toval))
      |   {
      |     struct value *parent = value_parent (toval);
      |
      |     changed_addr = value_address (parent) + value_offset (toval);

The destination value (corresponding to "sa(3)") was incorrectly created
by ada-lang.c:ada_value_primitive_packed_val, because the "parent" was
left as NULL. So, when we try to dereference it to get the parent address,
GDB crashed.

The first part of the fix therefore consists in setting that field.
This required the addition of a new "setter" in value.[hc].  It fixes
the crash, but is still not sufficient for the assignment to actually
work.

The second part of the problem came from the fact that value_assign
seems to expect the "child"'s address to be equal to the parent's address,
with the difference being the offset. Unfortunately, this requirement was
not followed by ada_value_primitive_packed_val, so the second part of
the fix consisted in fixing that.

Still, this was not sufficient, because it caused a regression when
trying to perform an aggregate assignment of a packed array of packed
record.  The key element here is the nesting of packed entities.
Looking at the way ada_value_primitive_packed_val creates the value
of each sub-component, one can see that the value's offset is set
to the offset compared to the start of the parent. This was meant to
match what value_primitive_field does as well.

So, with our array of records, if the record offset was 2, and if
the field we're interested in that record is at offset 1, the record
value's offset would be set to 2, and the field value's offset would
be set to 1. But the address for both values would be left to the
array's address. This is where things start breaking down, because
the value_address function for our field value would return the
address of the array + 1, instead of + 3.

This is what causes the final issue, here, because ada-lang.c's
value_assign_to_component needs to compute the offset of the
subcomponent compared to the top-level aggregate's start address
(the array in our case). And it does so by subtracting the array's
address from the sub-component's address.  When you have two levels
of packed components, and the mid-level component is at an offset of
the top-level component, things didn't work, because the component's
address was miscomputed (the parent's offset is missing).

The fix consists is fixing value_address to match the work done by
value_primitive_field (where we ignore the parent's offset).

gdb/ChangeLog:

        * value.h (set_value_parent): Add declaration.
        * value.c (set_value_parent): New function.
        (value_address): If VALUE->PARENT is not NULL, then use it as
        the base address instead of VALUE->LOCATION.address.
        * ada-lang.c (ada_value_primitive_packed_val): Keep V's address
        the same as OBJ's address.  Adjust V's offset accordingly.
        Set V's parent.

gdb/testsuite/ChangeLog:

        * gdb.ada/set_pckd_arr_elt: New testcase.
2012-03-16 17:55:45 +00:00
Joel Brobecker a5ee536be2 language-specific read_var_value for Ada renamings
The purpose of this patch is to better support renamings in the
"info locals" command. Consider ...

    procedure Foo is
       GV : Integer renames Pck.Global_Variable;
    begin
       Increment (GV); -- STOP
    end Foo;

... Pck.Global_Variable is just an integer. After having stopped at
the "STOP" line, "info locals" yields:

    (gdb) info locals
    gv = <error reading variable gv (Cannot access memory at address 0xffffffffffffffff)>

In reality, two things are happening:

   (1) Variable "GV" does not exist, which is normal, since there is
       "GV" the renaming of another variable;

   (2) But to allow the user access to that renaming the same way
       the code has, the compiler produces an artificial variable
       whose name encodes the renaming:

        gv___XR_pck__global_variable___XE

       For practical reasons, the artificial variable itself is given
       irrelevant types and addresses.

But the "info locals" command does not act as if it was a short-cut
of "foreach VAR in locals, print VAR". Instead it gets the value of
each VAR directly, which does not work in this case, since the variable
is artificial and needs to be decoded first.

This patch makes the "read_var_value" routine language-specific.
The old implementation of "read_var_value" gets renamed to
"default_read_var_value" and all languages now use it (unchanged
behavior), except for Ada. In Ada, the new function ada_read_var_value
checks if we have a renaming, and if so, evaluates its value, or else
defers to default_read_var_value.

gdb/ChangeLog:

        * language.h (struct language_defn): New "method" la_read_var_value.
        * findvar.c: #include "language.h".
        (default_read_var_value): Renames read_var_value.  Rewrite
        function description.
        (read_var_value): New function.
        * value.h (default_read_var_value): Add prototype.
        * ada-lang.c (ada_read_renaming_var_value, ada_read_var_value):
        New functions.
        (ada_language_defn): Add entry for la_read_var_value.
        * c-lang.c, d-lang.c, f-lang.c, jv-lang.c, language.c,
        * m2-lang.c, objc-lang.c, opencl-lang.c, p-lang.c: Update
        language_defn structures to add entry for new la_read_var_value
        field.
2012-03-02 19:29:01 +00:00
Pedro Alves e308454991 2012-03-01 Pedro Alves <palves@redhat.com>
* ada-lang.c (ada_modulus_from_name): Delete.
	* ada-lex.l (lexer_init): Make static.
2012-03-01 21:03:15 +00:00
Joel Brobecker 739593e0ec ada-lang.c:ada_find_renaming_symbol minor improvement.
This is a minor improvement in ada_find_renaming_symbol: What we were
doing was going from a symbol, get its name, and then search for
renamings.  But if the original symbol was already itself a renaming,
then we'd look the symbol up again to return it.  Since we had the
symbol in the first place, we shouldn't need to look it up again.

This is what this patch does: Modify ada_find_renaming_symbol to
take a symbol instead of the symbol's (linkage) name, and then updates
the one caller.

gdb/ChangeLog:

        * ada-lang.h (ada_find_renaming_symbol): Replace parameter
        "name" with "struct symbol *name_sym".
        * ada-exp.y (write_var_or_type): Update call to
        ada_find_renaming_symbol.
        * ada-lang.c (ada_find_renaming_symbol): Replace parameter
        "name" with "struct symbol *name_sym". Adjust Implementation
        accordingly.  Adjust the function documentation.
2012-02-29 19:51:49 +00:00
Joel Brobecker 852dff6c67 Minor cleanup to a couple of functions in ada-lang.c.
gdb/ChangeLog:

        * ada-lang.h (ada_find_any_symbol, ada_find_any_type): Delete.
        * ada-lang.c (ada_find_any_type): Add advance declaration.
        Make static.  Replace ada_find_any_symbol by
        ada_find_any_type_symbol.
        (ada_find_any_type_symbol): Renames ada_find_any_symbol.
        Improve function description.  Make static.
        (ada_find_renaming_symbol, find_old_style_renaming_symbol):
        Replace ada_find_any_symbol by ada_find_any_type_symbol.
2012-02-29 19:50:22 +00:00
Joel Brobecker 1b61134393 [Ada] avoid error message pollution with uninitialized tagged variable
Consider the following function...

  3 procedure Foo is
  4    I : Integer := Ident (10);
  5    Obj : Base;
  6 begin
  7    Obj.X := I;
  8    Do_Nothing (Obj.X'Address);
  9 end Foo;

... where type "Base" is defined as a plain tagged record. If the user
stops execution before "Obj" gets initialized (for example, by inserting
a breakpoint "on" the function - or in other words, by inserting a
breakpoint using the function name as the location), one might get
the following of output if you try printing the value of obj:

    (gdb) p obj
    object size is larger than varsize-limit
    object size is larger than varsize-limit
    object size is larger than varsize-limit
    $1 = object size is larger than varsize-limit
    (x => 4204154)

Same thing with "info locals":

   (gdb) info locals
    i = 0
    obj = object size is larger than varsize-limit
    (x => 4204154)

We have also seen different error messages such as "Cannot read
memory at 0x...".

The error happens because we are trying to read the dispatch table
of a tagged type variable before it gets initialized.  So the errors
might legitimately occur, and are supposed to be be contained.
However, the way things are written in ada-lang.c:ada_tag_name,
although the exception is in fact contained, the error message still
gets to be printed out.

This patch prevents this from happening by eliminating the use of
catch_errors, and using a TRY_CATCH block instead.  Doing this removed
the need to use functions specifically fitted for catch_errors, and
thus some other simplifications could me made.  In the end, the code
got reorganized a bit to better show the logic behind it, as well as
the common patterns.

gdb/ChangeLog:

        * ada-lang.c (struct tag_args): Delete.
        (ada_get_tsd_type): Function body moved up in source file.
        (ada_tag_name_1, ada_tag_name_2): Delete.
        (ada_get_tsd_from_tag): New function.
        (ada_tag_name_from_tsd): New function.
        (ada_tag_name): Use a TRY_CATCH block instead of catch_errors
        to determine the tag name.

gdb/testsuite/ChangeLog:

        * gdb.ada/tagged_not_init: New testcase.
2012-02-29 19:46:48 +00:00
Joel Brobecker 41246937ec [Ada] New functions to decode Ada types and values
This patch introduces two new functions that will be used to support
the implementation of the ada-varobj effort.  The function descriptions
should say it all...

gdb/ChangeLog:

        * ada-lang.h (ada_get_decoded_value, ada_get_decoded_type): Add
        declaration.
        * ada-lang.c (ada_get_decoded_value, ada_get_decoded_type): New
        function.
2012-02-29 19:44:12 +00:00
Joel Brobecker ffde82bff0 [Ada] Fix comment in ada-lang.c:ada_is_ignored_field
Fix a comment that completly mistunderstood the code...

gdb/ChangeLog:

        * ada-lang.c (ada_is_ignored_field): Rewrite wrong comment.
2012-02-29 19:37:07 +00:00
Joel Brobecker 2ad01556c7 [Ada] Do not cache lookup result if not full_search
The ada_lookup_symbol_list function has recently been changed to accept
a "full_search" parameter. When null, this parameter instructs the
function to perform a partial search (global and static symbols are not
searched). When doing a partial search, the result should not be saved
into the lookup cache, as the result might be incomplete.

This manifested itself when trying to perform a function call on AVR
after having inserted a breakpoint inside that function:

    (gdb) b same
    Breakpoint 2 at 0x78: file r.adb, line 5.
    (gdb) call same(42)

    Breakpoint 2, r.same (i=42) at r.adb:5
    5             return I;
    The program being debugged stopped while in a function called from GDB.
    Evaluation of the expression containing the function
    (at 0x0x800068) will be abandoned.
    ^^^^^^^^^^^^^^^
    When the function is done executing, GDB will silently stop.

The expected output for the underlined portion is "(r.same)".

What happens is that the breakpoint command triggers 3 lookups of the
name "same":
  1. full search in LABEL_DOMAIN -> no match, cached;
  2. full search in VAR_DOMAIN -> 1 match, cached;
  3. partial search in VAR_DOMAIN -> no match, cached.

The third lookup therefore causes the results of the partial search
to be cached, thus overriding the result of the full search lookup.

During the following command, the reference to "same" triggers a lookup
of that symbol again. And since GDB CAN find the result of that lookup
in the cache, it returns just that, which is: No match. (wrong!)

As a result, we fallback on the symbol table to resolve the lookup.
And instead of pushing an OP_VAR_VALUE subexpression for symbol "same",
the parser ends up pushing an UNOP_MEMVAL subexpression using the value
of the minimal symbol. This is where being on AVR becomes important:
addresses on AVR are modular types, and if GDB thinks an address is
a data address, it converts it.

This is where one notices the fact that the breakpoint was inserted
at 0x78, and yet GDB says that the function we stopped at is at
0x0x800068...

This patch fixes the problem by making sure we only cache the result
of full searches.

gdb/ChangeLog:

        * ada-lang.c (ada_lookup_symbol_list): Only cache the result of
        full searches.
2012-02-29 19:35:37 +00:00
Joel Brobecker 99b1c762c9 [Ada] print packed arrays indexed by enumerated type
Consider the following declarations (a packed array indexed by an
enumerated type):

    type Color is (Black, Red, Green, Blue, White);
    type Full_Table is array (Color) of Boolean;
    pragma Pack (Full_Table);
    Full : Full_Table := (False, True, False, True, False);

GDB is unable to print the index values correctly. It prints the
enumeration's underlying value instead of the enumeration name:

    (gdb) p full
    $1 = (0 => false, true, false, true, false)
    (gdb) p full'first
    $2 = 0

And yet, it is capable of printing the correct type description:

    (gdb) ptype full
    type = array (black .. white) of boolean <packed: 1-bit elements>

To get to the real index type, one has to follow the parallel XA type.
We already do this for normal arrays. We can do it for this packed
array as well.

gdb/ChangeLog:

        * ada-lang.c (constrained_packed_array_type): If there is a
        parallel XA type, use it to determine the array index type.

gdb/testsuite/ChangeLog:

        * gdb.ada/arrayidx.exp: Adjust expected output for p_one_two_three.
        * gdb.ada/enum_idx_packed: New testcase.
2012-02-29 19:34:40 +00:00
Joel Brobecker c48db5caef Ada: ada_to_fixed_value should also unwrap_value
We should always unwrap a value before trying to "fix" it. It is
therefore logical that ada_to_fixed_value would call unwrap_value
before creating the fixed value.

This simplifies the code in ada-lang.c a bit.

gdb/ChangeLog:

        * ada-lang.c (ada_to_fixed_value): Call unwrap_value before
        creating fixed value.
        (ada_value_ind, ada_coerce_ref, assign_component)
        (ada_evaluate_subexp): Remove call to unwrap_value before
        call to ada_to_fixed_value.
2012-02-29 19:30:53 +00:00
Joel Brobecker 2e6fda7d06 [Ada] whatis not printing array type name for value from history
Consider the following declaration:

   type Full_Table is array (Color) of Integer;
   Full : Full_Table := (144, 233, 377, 610, 987);

The debugger correctly prints the type name of variable "full":

        (gdb) whatis full
        type = pck.full_table

But is unable to do so when using the value history:

        (gdb) print full
        $1 = (144, 233, 377, 610, 987)
        (gdb) whatis $
 !!! -> type = array (black .. white) of integer

This is because the evaluation creates a "fixed" version of
the array type, and that "fixed" version is missing a type name.
As a result, whatis falls back to describing the type (a la ptype)
instead of printing the type name.

gdb/ChangeLog:

        * ada-lang.c (to_fixed_array_type): Set result's type name.

gdb/testsuite/ChangeLog:

        * gdb.ada/whatis_array_val: New testcase.
2012-02-29 19:29:12 +00:00
Joel Brobecker 5845583db6 Add support for condition in Ada exception catchpoint commands
Previously, conditions could be associated to Ada exception catchpoints,
but not while creating the exception catchpoint:

    (gdb) catch exception first_exception if except_counter = 5
    Junk at end of expression

This patch improves the parsing of the command arguments to allow
an "if CONDITION" at the end.  All Ada exception catchpoint commands
have been enhanced to support this.

gdb/ChangeLog:

        * ada-lang.c (catch_ada_exception_command_split): Add new
        argument cond_string.  Add support for condition at end of
        "catch exception" commands.
        (ada_decode_exception_location): Add new argument cond_string.
        Update call to catch_ada_exception_command_split.
        (create_ada_exception_catchpoint): Add new argument cond_string.
        Set the breakpoint condition if needed.
        (catch_ada_exception_command): Update call to
        ada_decode_exception_location.
        (ada_decode_assert_location): Add function documentation.
        Add support for condition at end of "catch assert" command.
        (catch_assert_command): Update calls to ada_decode_assert_location
        and create_ada_exception_catchpoint.
2012-02-29 19:09:47 +00:00
Joel Brobecker 1a119f3613 Rename la_get_symbol_name_match_p into la_get_symbol_name_cmp
The la_get_symbol_name_match_p language hook was poorly named, as
it suggested that the function should return nonzero if the names
match, whereas it is the exact opposite.  This patch therefore
renames the hook and associated typedef, as well some of the code
that uses that hook.

gdb/ChangeLog:

        * language.h (symbol_name_cmp_ftype): Renames
        symbol_name_match_p_ftype.
        (struct language_defn)[la_get_symbol_name_cmp]: Renames
        la_get_symbol_name_match_p.
        * ada-lang.c (ada_get_symbol_name_cmp): Renames
        ada_get_symbol_name_match_p.  Update comment.
        (ada_language_defn)[la_get_symbol_name_cmp]: Update value.
        * linespec.c (struct symbol_matcher_data)[symbol_name_cmp]:
        Renames symbol_name_match_p.  Update field type.
        (iterate_name_matcher, iterate_over_all_matching_symtabs): Adjust.
        * c-lang.c, d-lang.c, f-lang.c, jv-lang.c, m2-lang.c, objc-lang.c,
        opencl-lang.c, p-lang.c: Replace "la_get_symbol_name_match_p" by
        "la_get_symbol_name_cmp" in comments.
        * language.c: Likewise.
2012-02-08 19:54:37 +00:00
Doug Evans 0d5cff5020 * gdbtypes.h (struct main_type): Change type of name,tag_name,
and fields.name members from char * to const char *.  All uses updated.
	(struct cplus_struct_type): Change type of fn_fieldlists.name member
	from char * to const char *.  All uses updated.
	(type_name_no_tag): Update.
	(lookup_unsigned_typename, lookup_signed_typename): Update.
	* gdbtypes.c (type_name_no_tag): Change result type
	from char * to const char *.  All callers updated.
	(lookup_unsigned_typename, lookup_signed_typename): Change type of
	name parameter from char * to const char *.
	* symtab.h (struct cplus_specific): Change type of demangled_name
	member from char * to const char *.  All uses updated.
	(struct general_symbol_info): Change type of name and
	mangled_lang.demangled_name members from char * to const char *.
	All uses updated.
	(symbol_get_demangled_name, symbol_natural_name): Update.
	(symbol_demangled_name, symbol_search_name): Update.
	* symtab.c (symbol_get_demangled_name): Change result type
	from char * to const char *.  All callers updated.
	(symbol_natural_name, symbol_demangled_name): Ditto.
	(symbol_search_name): Ditto.
	(completion_list_add_name): Change type of symname,sym_text,
	text,word parameters from char * to const char *.
	(completion_list_objc_symbol): Change type of sym_text,
	text,word parameters from char * to const char *.
	* ada-lang.c (find_struct_field): Change type of name parameter
	from char * to const char *.
	(encoded_ordered_before): Similarly for N0,N1 parameters.
	(old_renaming_is_invisible): Similarly for function_name parameter.
	(ada_type_name): Change result type from char * to const char *.
	All callers updated.
	* ada-lang.h (ada_type_name): Update.
	* buildsym.c (hashname): Change type of name parameter
	from char * to const char *.
	* buildsym.h (hashname): Update.
	* dbxread.c (end_psymtab): Change type of include_list parameter
	from char ** to const char **.
	* dwarf2read.c (determine_prefix): Change result type
	from char * to const char *.  All callers updated.
	* f-lang.c (find_common_for_function): Change type of name, funcname
	parameters from char * to const char *.
	* f-lang.c (find_common_for_function): Update.
	* f-valprint.c (list_all_visible_commons): Change type of funcname
	parameters from char * to const char *.
	* gdbarch.sh (static_transform_name): Change type of name parameter
	and result from char * to const char *.
	* gdbarch.c: Regenerate.
	* gdbarch.h: Regenerate.
	* i386-sol2-tdep.c (i386_sol2_static_transform_name): Change type
	of name parameter from char * to const char *.
	* jv-lang.c (java_primitive_type_from_name): Ditto.
	(java_demangled_signature_length): Similarly for signature parameter.
	(java_demangled_signature_copy): Ditto.
	(java_demangle_type_signature): Ditto.
	* jv-lang.h (java_primitive_type_from_name): Update.
	(java_demangle_type_signature): Update.
	* objc-lang.c (specialcmp): Change type of a,b parameters
	from char * to const char *.
	* p-lang.c (is_pascal_string_type): Change type of arrayname parameter
	from char * to const char *.  All callers updated.
	* p-lang.h (is_pascal_string_type): Update.
	* solib-frv.c (find_canonical_descriptor_in_load_object): Change type
	of name parameter from char * to const char *.
	* sparc-sol2-tdep.c (sparc_sol2_static_transform_name): Ditto.
	* utils.c (fprintf_symbol_filtered): Ditto.
	* defs.h (fprintf_symbol_filtered): Update.
	* sparc-tdep.h (sparc_sol2_static_transform_name): Update.
	* stabsread.h (end_psymtab): Update.
	* stack.c (find_frame_funname): Change type of funname parameter
	from char ** to const char **.
	* stack.h (find_frame_funname): Update.
	* typeprint.c (type_print): Change type of varstring parameter
	from char * to const char *.
	* value.h (type_print): Update.
	* xcoffread.c (xcoff_start_psymtab): Change type of filename parameter
	from char * to const char *.  All callers updated.
	(xcoff_end_psymtab): Change type of include_list parameter
	from char ** to const char **.  All callers updated.
	(swap_sym): Similarly for name parameter.  All callers updated.
	* coffread.c (patch_type): Add (char*) cast to xfree parameter.
	Use xstrdup.
	(process_coff_symbol): Use xstrdup.
	* stabsread.c (stabs_method_name_from_physname): Renamed from
	update_method_name_from_physname.  Change result type from void
	to char *.  All callers updated.
	(read_member_functions): In has_destructor case, store name in objfile
	obstack instead of malloc space.  In !has_stub case, fix mem leak.
2012-02-07 04:48:23 +00:00
Gary Benson 8e704927af 2012-02-01 Gary Benson <gbenson@redhat.com>
* symtab.h (symbol_name_match_p_ftype): New typedef.
	(iterate_over_symbols): Use the above.
	* symtab.c (iterate_over_symbols): Likewise.
	* language.h (language_defn->la_iterate_over_symbols): Likewise.
	* ada-lang.c (ada_iterate_over_symbols): Likewise.
	* linespec.c (iterate_over_all_matching_symtabs): Likewise.
	(iterate_name_matcher): Document return values.
	(collect_one_symbol): Likewise.
	(collect_function_symbols): Likewise.
	(collect_symbols): Likewise.
2012-02-01 16:10:31 +00:00
Tom Tromey d9680e739f * ada-lang.c (resolve_subexp): Update.
(ada_lookup_symbol_list): Add 'full_search' argument.
	(ada_iterate_over_symbols): Pass 0 as full_search argument to
	ada_lookup_symbol_list.
	(ada_lookup_encoded_symbol): Update.
	(get_var_value): Update.
	* ada-exp.y (block_lookup): Update.
	(write_var_or_type): Update.
	(write_name_assoc): Update.
	* ada-lang.h (ada_lookup_symbol_list): Update.
2012-02-01 15:49:34 +00:00
Joel Brobecker e078317b28 Remove language param from name_matcher in struct quick_symbol_functions
The quick_symbol_functions struct contains a field which is pointer
a function which takes another function, called name_matcher, as
its parameter.  This name_matcher currently has 3 arguments, one
of them being the language. This parameter is no longer used, and
thus deleted.

gdb/ChangeLog:

        * symfile.h (struct quick_symbol_functions) [expand_symtabs_matching]:
        Remove language parameter from name_matcher.  Adjust the comment.
        * symtab.c (search_symbols_name_matches, expand_partial_symbol_name):
        Remove language parameter.
        * ada-lang.c (ada_expand_partial_symbol_name): Likewise.
        * linespec.c (iterate_name_matcher): Likewise.
        * dwarf2read.c (dw2_expand_symtabs_matching): Adjust type of
        name_matcher.  Adjust call accordingly.
        * psymtab.c (expand_symtabs_matching_via_partial): Likewise.
        (maintenance_check_symtabs): Adjust type of parameter "fun".
        * psymtab.h (maintenance_check_symtabs): Likewise.
2012-01-26 04:21:40 +00:00
Joel Brobecker 74ccd7f58b Ada: allow unqualified function names in linespecs
This is the meat, where we replace the old la_symbol_name_compare
language method with the new ada_get_symbol_name_match_p.
It fixes the problem when trying to insert a breakpoint on "+".

gdb/ChangeLog:

        * language.h (symbol_name_match_p_ftype): New typedef.
        (struct language_defn): Replace field la_symbol_name_compare
        by la_get_symbol_name_match_p.
        * ada-lang.c (ada_get_symbol_name_match_p): New function.
        (ada_language_defn): Use it.
        * linespec.c (struct symbol_matcher_data): New type.
        (iterate_name_matcher): Rewrite.
        (iterate_over_all_matching_symtabs): Pass a pointer to
        a symbol_matcher_data struct to expand_symtabs_matching
        instead of just the lookup name.
        * c-lang.c, d-lang.c, jv-lang.c, m2-lang.c, objc-lang.c,
        opencl-lang.c, p-lang.c, language.c: Delete field
        la_symbol_name_compare, and replace by NULL for new field
        la_get_symbol_name_match_p.
        * symfile.h (struct quick_symbol_functions): Update comment.
2012-01-26 04:20:36 +00:00
Tom Tromey fa86499982 * ada-lang.c: Include gdb_vecs.h.
* charset.c: Include gdb_vecs.h.
	* tracepoint.h: Include gdb_vecs.h.
	* gdb_vecs.h: New file.
2012-01-24 21:36:37 +00:00
Sergio Durigan Junior bfd189b164 2012-01-06 Sergio Durigan Junior <sergiodj@redhat.com>
Thiago Jung Bauermann  <bauerman@br.ibm.com>

	* ada-lang.c (ada_exception_name_addr): Add `volatile' keyword
	before `struct gdb_exception'.
	* breakpoint.c (update_global_location_list_nothrow)
	(update_breakpoint_locations, enable_breakpoint_disp): Likewise.
	* cp-abi.c (value_rtti_type): Likewise.
	* cp-support.c (cp_validate_operator): Likewise.
	* infrun.c (insert_exception_resume_breakpoint)
	(check_exception_resume, keep_going): Likewise.
	* mi-interp.c (mi_breakpoint_created)
	(mi_breakpoint_modified): Likewise.
	* rs6000-aix-tdep.c (rs6000_convert_from_func_ptr_addr): Likewise.
	* solib-ia64-hpux.c (ia64_hpux_at_dld_breakpoint_p)
	(ia64_hpux_handle_dld_breakpoint_1): Likewise.
2012-01-06 03:34:46 +00:00
Joel Brobecker 0fcd72ba37 Use skip_spaces and skip_to_space in ada-lang.c
This is just a minor cleanup that reduces a bit the code in ada-lang.c
by using skip_spaces or skip_to_space, instead of doing the skipping
ourselves.

gdb/ChangeLog:

        * ada-lang.c: #include "cli/cli-utils.h".
        (get_selections): Use skip_spaces.
        (ada_get_next_arg): Use skip_spaces and skip_to_space.
        (catch_ada_exception_command_split): Use skip_spaces.
        (ada_decode_assert_location): Likewise.
2012-01-04 14:55:09 +00:00
Joel Brobecker 0b30217134 Copyright year update in most files of the GDB Project.
gdb/ChangeLog:

        Copyright year update in most files of the GDB Project.
2012-01-04 08:17:56 +00:00
Joel Brobecker 6e68186627 more copyright notice reformatting.
gdb/ChangeLog:

        * ada-lang.c: Reformat the copyright notice.

gdb/testsuite/ChangeLog:

        * gdb.base/auxv.exp: Reformat the copyright notice.
2012-01-03 13:31:01 +00:00
Joel Brobecker c04316705c New function ada-lang.c:should_use_wild_match...
... to avoid code duplication.

gdb/ChangeLog:

        * ada-lang.c (should_use_wild_match): New function.
        (ada_lookup_simple_minsym): Use should_use_wild_match.
        Minor simplification.  Add comment.
        (ada_lookup_symbol_list): Use should_use_wild_match.
        Minor simplification.
2011-12-27 04:17:55 +00:00
Joel Brobecker 9ac7f98e7c [Ada] Breakpoints on task bodies
Consider the following declaration:

    package Pck is
       task Dummy_Task is
          entry Start;
       end Dummy_Task;
    end Pck;

Inserting a breakpoint on the body of that task does not currently
work:

    (gdb) b pck.dummy_task
    "pck.dummy_task" is not a function
    Make breakpoint pending on future shared library load? (y or [n]) n

What happens here is that the compiler generates two symbols:

  (a) Symbol `pck__dummy_task' which is a *variable* referencing
      the task;

  (b) Symbol `pck__dummy_taskTKB' which is the subprogram implementing
      the body of the task.

The symbol lookup only finds the variable before of the TKB suffix in
the subprogram name. This patch fixes the problem by adjusting the
ada-lang.c:is_name_suffix routine to recognize "TKB" suffixes.  But
that's not enough, because the search in the symtab is performed via
the block dictionary, using a hashing algorithm. So, for the search
to find `pck__dummy_taskTKB', I had to modify the hashing function
to ignore TKB suffixes as well.

gdb/ChangeLog:

        * ada-lang.c (is_name_suffix): Add handling of "TKB" suffixes.
        Update function documentation.
        * dictionary.c (dict_hash): Ignore "TKB" suffixes in hash
        computation.

gdb/testsuite/ChangeLog:

        * gdb.ada/task_bp: New testcase.
2011-12-21 07:10:59 +00:00