Commit Graph

30091 Commits

Author SHA1 Message Date
Tom Tromey c4aeac856a * gnu-v3-abi.c (struct value_and_voffset): New.
(hash_value_and_voffset, eq_value_and_voffset)
	(compare_value_and_voffset, compute_vtable_size)
	(print_one_vtable, gnuv3_print_vtable): New functions.
	(init_gnuv3_ops): Initialize 'print_vtable' field.
	* cp-support.c (info_vtbl_command): New function.
	(_initialize_cp_support): Add "info vtbl".
	* cp-abi.h (cplus_print_vtable): Declare.
	(struct cp_abi_ops) <print_vtable>: New field.
	* cp-abi.c (cplus_print_vtable): New function.
	* NEWS: Update.
gdb/testsuite
	* gdb.cp/virtfunc.exp (make_one_vtable_result): New proc.
	(test_info_vtbl): Likewise.
	(do_tests): Call test_info_vtbl.
	* gdb.cp/virtfunc.cc (va): New global.
gdb/doc
	* gdb.texinfo (Debugging C Plus Plus): Document "info vtbl".
2012-03-15 15:43:18 +00:00
Tom Tromey 95cbceff99 * d-lang.c (d_language_defn) <la_iterate_over_symbols>: Set to
iterate_over_symbols.
2012-03-15 14:06:20 +00:00
Yao Qi fc3e51758a gdb/gdbserver/
* tracepoint.c (install_tracepoint): Move duplicated tracepoint
	handling to ...
	(cmd_qtdp): ... here.
2012-03-15 12:57:13 +00:00
Yao Qi 8d0d92cd22 gdb/gdbserver/
* tracepoint.c (struct tracepoint_action_ops): New.
	(struct tracepoint_action) [!IN_PROCESS_AGENT] <ops>: New field.
	(m_tracepoint_action_download): New.
	(r_tracepoint_action_download): New.
	(x_tracepoint_action_download): New.
	(l_tracepoint_action_download): New.
	(add_tracepoint_action): Install `action->ops' according type.
	(download_tracepoint_1): Move code `download' function pointer
	of various tracepoint_action_ops.
2012-03-15 10:42:38 +00:00
Thomas Schwinge 856d06f972 gdb/testsuite/
* gdb.dwarf2/dw2-ada-ffffffff.S: Use .4byte instead of .long for
	describing DWARF data structures.
	* gdb.dwarf2/dw2-bad-parameter-type.S: Likewise.
	* gdb.dwarf2/dw2-double-set-die-type.S: Likewise.
	* gdb.dwarf2/dw2-empty-pc-range.S: Likewise.
	* gdb.dwarf2/dw2-entry-value.S: Likewise.
	* gdb.dwarf2/dw2-modula2-self-type.S: Likewise.
	* gdb.dwarf2/dw2-param-error.S: Likewise.
	* gdb.dwarf2/dw2-skip-prologue.S: Likewise.
	* gdb.dwarf2/dw2-stack-boundary.S: Likewise.
	* gdb.dwarf2/dw4-sig-type-unused.S: Likewise.
	* gdb.dwarf2/implptr-optimized-out.S: Likewise.
	* gdb.dwarf2/member-ptr-forwardref.S: Likewise.
	* gdb.dwarf2/pr11465.S: Likewise.
2012-03-15 09:08:10 +00:00
Doug Evans 589b4a3225 * dwarf2read.c (dwarf_stack_op_name): Add DW_OP_GNU_encoded_addr,
DW_OP_GNU_parameter_ref.
2012-03-15 02:34:49 +00:00
gdbadmin 0a8af9c64c *** empty log message *** 2012-03-15 00:00:32 +00:00
Jan Kratochvil e837f12a8d gdb/
Fix double prompt of 'interpreter-exec mi'.
	* mi/mi-interp.c (mi_execute_command_input_handler): New prototype.
	(mi_interpreter_resume): use it.
	(mi_execute_command_input_handler): New function.
	* mi/mi-main.c (mi_execute_command): Move prompt printing to
	mi_execute_command_input_handler.

gdb/testsuite/
	* gdb.mi/mi2-prompt.exp: New file.
2012-03-14 07:58:06 +00:00
Joel Brobecker ff1e452654 Mark latest entry in ChangeLog as "tiny change". 2012-03-14 01:47:45 +00:00
Joel Brobecker c381a3f69a Fix -Wmissing-prototypes build warnings on Darwin.
gdb/
2012-03-13  Josh Matthews  <josh@joshmatthews.net>

	* darwin-nat-info.c (_initialize_darwin_info_commands): Add
	prototype.
	(darwin_debug_port_info): Make static.
	* darwin-nat.c (_initialize_darwin_inferior): Add prototype.
	* machoread.c (_initialize_machoread): Add prototype.
	* i386-darwin-nat.c (i386_darwin_dr_set, i386_darwin_dr_get)
	(i386_darwin_set_control, i386_darwin_get_control)
	i386_darwin_dr_set_addr, i386_darwin_get_addr)
	i386_darwin_get_status, i386_darwin_get_control):
	Comment out with HW_WATCHPOINT_NOT_YET_ENABLED macro.
2012-03-14 01:46:59 +00:00
Joel Brobecker ccbb4f28f0 Testcase for: "ax-gdb: Do not treat enums and bools as integers".
gdb/testsuite/ChangeLog:

        * gdb.base/enum_cond.c, gdb.base/enum_cond.exp: New testcase.
2012-03-14 01:39:12 +00:00
Joel Brobecker d8a5d6ee2f ax-gdb: Do not treat enums and bools as integers.
This patch fixes a problem when using gdb + gdbserver, and trying
to break on a function when one of the (enum) parameters is equal
to a certain value, and the size of that enum is 1 byte.

    (gdb) break mixed.adb:15 if light = green
    Breakpoint 2 at 0x402d5a: file mixed.adb, line 15.
    (gdb) cont
    Continuing.
    [Inferior 1 (process 9742) exited normally]

The debugger should have stopped once when our function was call
with light set to green.

Here is what happens: Because we're using a recent GDBserver,
GDB hands off the evaluation of the condition to GDBserver, by
providing it in the Z0 packet. This is what GDB sends:

    $Z0,402d5a,1;X13,26000622100223ff1c16100219162022011327#cf

I decoded the condition as follow:

    260006    reg 6 -> push
    2210      const8 0x10 -> push
    02        add (stack now has 1 element equal to reg6 + 16)
    23ff1c    const16 0xff1c
    1610      ext 16 (sign extend 16 bits)
    02        add (stack now has 1 element equal to reg6 + 16 - 228)
    19        ref32: Pop as addr, push 32bit value at addr.
    1620      ext 32 (sign extend 32 bits)
    2201      const8 0x01
    13        equal
    27        end

The beginning of the agent expression can be explained by the address
of symbol "light":

    (gdb) info addr light
    Symbol "light" is a variable at frame base reg $rbp offset 16+-228.

However, the mistake is the "ext 32" operation (extend 32 bits),
because our variable is *not* 32bits, only 8:

    (gdb) print light'size
    $5 = 8

But the reason why GDB decides to use a 32bit extension is because
it overrides the symbol's type with a plain integer type in
ax-gdb.c:gen_usual_unary...

      /* If the value is an enum or a bool, call it an integer.  */
    case TYPE_CODE_ENUM:
    case TYPE_CODE_BOOL:
      value->type = builtin_type (exp->gdbarch)->builtin_int;
      break;

... before calling require_rvalue. And of course, that causes the
generator to generate a sizeof(int) extension of the result.

One way to fix this would be to use an integer type of the correct
size, but I do not understand why this is necessary. The two routines
that use that information to generate the opcode down the line are
gen_fetch (for a memory value), or gen_extend (for a register value).
And they both have handling of enums and bools.

So the fix we elected to implement was simply to remove that code.

gdb/ChangeLog:

        * ax-gdb.c (gen_usual_unary): Remove special handling of
        enum and bool types.
2012-03-14 01:38:58 +00:00
Joel Brobecker 32039130c8 testcase for "gdb-ax.c: Add handling of TYPE_CODE_RANGE types"
gdb/testsuite/ChangeLog:

        * gdb.ada/bp_range_type: New testcase.
2012-03-14 01:38:51 +00:00
Joel Brobecker af381b8cf9 ax-gdb.c: Add handling of TYPE_CODE_RANGE types.
This patch fixes an error that occurs with GDB + GDBserver when
trying to insert a breakpoint with a condition that involves
a range type. For instance:

    type INT_T  is range 0 .. 1000;
    INT_VAR : INT_T := 12;

And then trying to insert the breakpoint:

    (gdb) break foo.adb:18 if int_var > 15
    Breakpoint 1 at 0x4021eb: file foo.adb, line 18.
    (gdb) cont
    Continuing.
    /[...]/ax-gdb.c:560: internal-error: gen_fetch: bad type code
    A problem internal to GDB has been detected,
    further debugging may prove unreliable.
    Quit this debugging session? (y or n)

This patch fixes the problem by adding handling for range types
in gen_fetch.

gdb/ChangeLog:

        * ax-gdb.c (gen_fetch): Add handling for TYPE_CODE_RANGE types.
2012-03-14 01:38:30 +00:00
gdbadmin a776f595bf *** empty log message *** 2012-03-14 00:00:32 +00:00
Joel Brobecker 786c562f1a Minor cleanup in aix-thread.c:supply_fprs.
This is a minor cleanup that makes supply_fprs more consistent with
how fill_fprs was written.

gdb/ChangeLog:

        * aix-thread.c (supply_fprs): Make more consistent with fill_fprs.
2012-03-13 22:29:45 +00:00
Joel Brobecker e3ebf1bb41 Fix buffer overflow in aix-thread.c:fill_fprs
gdb/
2012-03-08  Chris January  <chris.january@allinea.com>

	* aix-thread.c (fill_sprs): Store the floating point registers
	at the correct offsets into vals.
2012-03-13 22:27:12 +00:00
Doug Evans 168997566e * NEWS: Mention symbol-reloading has been deleted.
* symfile.c (symbol_reloading): Delete.
	(show_symbol_reloading): Delete.
	(_initialize_symfile): Delete set/show symbol-reloading.

	doc/
	* gdb.texinfo (Help): Change apropos example to use "alias" instead
	of "reload".
	(Symbols): Delete docs for set/show symbol-reloading.
	* gdbint.texinfo (Defining Other Architecture Features): Delete
	SYMBOL_RELOADING_DEFAULT.
	* refcard.tex: Delete reference to symbol-reloading.

	testsuite/
	* gdb.base/default.exp: Delete tests for symbol-reloading.
	* gdb.base/help.exp: Ditto.
	* gdb.base/setshow.exp: Ditto.
	* gdb.base/gdb_history: Delete references to symbol-reloading.
2012-03-13 21:02:40 +00:00
Doug Evans c5b7e1cbc5 * dwarf2read.c (load_partial_comp_unit): Defer adding cu to
read_in_chain until we have successfully read it in.
	(load_full_comp_unit): Ditto.
	(read_signatured_type): Add comment.
2012-03-13 17:16:18 +00:00
Joel Brobecker 46cb6474c3 [stabs] The address of Fortran common blocks may be > INT_MAX.
gdb/
2012-03-08  Chris January  <chris.january@allinea.com>

        * stabsread.c (fix_common_block): Change type of valu argument
        to CORE_ADDR.
2012-03-13 16:29:16 +00:00
Joel Brobecker 76219d77db [ppc/prologue] Support the "oril r29, r1, 0x0" insn.
gdb/
2012-03-13  Chris January  <chris.january@allinea.com>

	* rs6000-tdep.c (skip_prologue): Support the oril r29, r1, 0x0
	instruction.
2012-03-13 16:15:35 +00:00
Jan Kratochvil 87b0bb13cb gdb/
* common/linux-procfs.c (linux_proc_get_int): New, from
	linux_proc_get_tgid, change its LWPID type to pid_t, add parameter
	field.
	(linux_proc_get_tgid): Only call linux_proc_get_int.
	(linux_proc_get_tracerpid): New.
	(linux_proc_pid_has_state): New, from linux_proc_pid_is_zombie.
	(linux_proc_pid_is_stopped, linux_proc_pid_is_zombie): Only call
	linux_proc_pid_has_state.
	* common/linux-procfs.h (linux_proc_get_tracerpid): New declaration.
	* common/linux-ptrace.c: Include linux-procfs.h and buffer.h.
	(linux_ptrace_attach_warnings): New.
	* common/linux-ptrace.h (struct buffer, linux_ptrace_attach_warnings):
	New declaration.
	* linux-nat.c: Include exceptions.h, linux-ptrace.h and buffer.h.
	(linux_nat_attach): New variables ex, buffer, message and message_s.
	Wrap to_attach by TRY_CATCH and call linux_ptrace_attach_warnings.

gdb/gdbserver/
	* linux-low.c (linux_attach_lwp_1): New variable buffer.  Call
	linux_ptrace_attach_warnings.

gdb/testsuite/
	* gdb.base/attach-twice.c: New files.
	* gdb.base/attach-twice.exp: New files.
2012-03-13 15:02:25 +00:00
Jan Kratochvil 5f572decf9 gdb/
* Makefile.in (linux-ptrace.o): New.
	* common/linux-procfs.c (linux_proc_pid_is_zombie): New,
	from linux-nat.c.
	* common/linux-procfs.h (linux_proc_pid_is_zombie): New declaration.
	* common/linux-ptrace.c: New file.
	* config/alpha/alpha-linux.mh (NATDEPFILES): Add linux-ptrace.o.
	* config/arm/linux.mh: Likewise.
	* config/i386/linux.mh: Likewise.
	* config/i386/linux64.mh: Likewise.
	* config/ia64/linux.mh: Likewise.
	* config/m32r/linux.mh: Likewise.
	* config/m68k/linux.mh: Likewise.
	* config/mips/linux.mh: Likewise.
	* config/pa/linux.mh: Likewise.
	* config/powerpc/linux.mh: Likewise.
	* config/powerpc/ppc64-linux.mh: Likewise.
	* config/powerpc/spu-linux.mh: Likewise.
	* config/s390/s390.mh: Likewise.
	* config/sparc/linux.mh: Likewise.
	* config/sparc/linux64.mh: Likewise.
	* config/xtensa/linux.mh: Likewise.
	* linux-nat.c (linux_lwp_is_zombie): Remove, move it to
	common/linux-procfs.c.
	(wait_lwp): Rename linux_lwp_is_zombie to linux_proc_pid_is_zombie.

gdb/gdbserver/
	* Makefile.in (linux-ptrace.o): New.
	* configure.srv (arm*-*-linux*, bfin-*-*linux*, crisv32-*-linux*)
	(cris-*-linux*, i[34567]86-*-linux*, ia64-*-linux*, m32r*-*-linux*)
	(m68*-*-linux*, m68*-*-uclinux*, mips*-*-linux*, powerpc*-*-linux*)
	(s390*-*-linux*, sh*-*-linux*, sparc*-*-linux*, tic6x-*-uclinux)
	(x86_64-*-linux*, xtensa*-*-linux*): Add linux-ptrace.o to SRV_TGTOBJ
	of these targets.
	* linux-low.c (linux_attach_lwp_1): Remove redundent else clause.
2012-03-13 15:00:37 +00:00
Pedro Alves 44f238bb63 2012-03-13 Hui Zhu <teawater@gmail.com>
Pedro Alves  <palves@redhat.com>

	* breakpoint.c (init_breakpoint_sal): New flags parameter.  Handle
	CREATE_BREAKPOINT_FLAGS_INSERTED.
	(create_breakpoint_sal, create_breakpoints_sal)
	(base_breakpoint_create_breakpoints_sal)
	(tracepoint_create_breakpoints_sal)
	(strace_marker_create_breakpoints_sal): New flags parameter.  Pass
	down.
	(break_command_1, handle_gnu_v3_exceptions, trace_command)
	(ftrace_command, strace_command): Adjust.
	(create_tracepoint_from_upload): Pass
	CREATE_BREAKPOINT_FLAGS_INSERTED.
	* breakpoint.h (enum breakpoint_create_flags): New.
	(create_breakpoint): New flags parameter.
	* mi/mi-cmd-break.c (mi_cmd_break_insert): Adjust.
	* python/py-breakpoint.c (bppy_init): Adjust.
	* python/py-finishbreakpoint.c (bpfinishpy_init): Adjust.
	* spu-tdep.c (spu_catch_start): Adjust.
2012-03-13 13:30:42 +00:00
Pedro Alves 1e51243a97 2012-03-13 Pedro Alves <palves@redhat.com>
Hui Zhu  <teawater@gmail.com>
	    Yao Qi  <yao@codesourcery.com>

	* remote.c (struct remote_state): New field `starting_up'.
	(remote_start_remote): Set and clear it.
	(remote_can_download_tracepoint): If starting up, return false.
2012-03-13 13:25:50 +00:00
Yao Qi fa3064dd8a gdb:
* inferior.h (struct inferior): Remove fields any_syscall_count,
	syscalls_counts and total_syscalls_count.  Move them to new
	struct catch_syscall_inferior_data in breakpoint.c.
	* breakpoint.c: Call DEF_VEC_I(int).
	(struct catch_syscall_inferior_data): New.
	(get_catch_syscall_inferior_data): New.
	(catch_syscall_inferior_data_cleanup): New.
	(insert_catch_syscall): Update to access data in
	struct catch_syscall_inferior_data.
	(insert_catch_syscall): Likewise.
	(remove_catch_syscall): Likewise.
	(remove_catch_syscall): Likewise.
	(is_syscall_catchpoint_enabled): Likewise.
	(add_catch_command): Likewise.
	(_initialize_breakpoint): Register cleanup.
	* breakpoint.h: Removed DEF_VEC_I(int).
	* dwarf2loc.c: Call DEF_VEC_I(int).
	* mi/mi-main.c: Likewise.
2012-03-13 01:16:07 +00:00
gdbadmin 799f5b9672 *** empty log message *** 2012-03-13 00:00:33 +00:00
Mark Kettenis 460fac3cfa * inf-ptrace.c (inf_ptrace_post_attach): Make static. 2012-03-12 21:08:44 +00:00
Joel Brobecker e1aca11ede Add missing prototypes for build in ppx-aix.
gdb/ChangeLog:
2012-03-12  Chris January  <chris.january@allinea.com>

        * aix-thread.c (_initialize_aix_thread): Add prototype.
        * rs6000-nat.c (_initialize_rs6000_nat): Ditto.
        * xcoffsolib.c (_initialize_xcoffsolib): Ditto.
2012-03-12 15:57:19 +00:00
Joel Brobecker 649c7061d4 amd64bsd-nat.c: Move "amd64bsd-nat.h" include...
... after include of "amd64-nat.h".

gdb/ChangeLog:

        * amd64bsd-nat.c: Move #include of "amd64bsd-nat.h" after
        include of "amd64-nat.h".
2012-03-12 15:21:19 +00:00
Tom Tromey 0b49e518cd * buildsym.c (record_pending_block): Now static.
* buildsym.h: (record_pending_block): Remove.
2012-03-12 14:15:22 +00:00
Andreas Tobler fd24fa9434 2012-03-12 Andreas Tobler <andreast@fgznet.ch>
* amd64bsd-nat.c: Include amd64bsd-nat.h.
2012-03-12 05:27:21 +00:00
gdbadmin d4e7cf4522 *** empty log message *** 2012-03-12 00:00:33 +00:00
gdbadmin 25037ec96d *** empty log message *** 2012-03-11 00:00:32 +00:00
gdbadmin 40048c48ff *** empty log message *** 2012-03-10 00:00:33 +00:00
Tom Tromey ba919b5861 * dwarf2read.c (struct dwarf2_cu) <checked_producer,
producer_is_gxx_lt_4_6>: New fields.
	(producer_is_gxx_lt_4_6): Use and update producer cache fields.
2012-03-09 20:17:32 +00:00
Tom Tromey a48e046c37 * dwarf2read.c (dwarf2_attr): Avoid tail-recursive call. 2012-03-09 20:06:18 +00:00
Joel Brobecker 05b8a7895a Fix a couple of ChangeLog entries. 2012-03-09 13:44:51 +00:00
Keith Seitz 0d7941a9be * lib/gdb.exp (gdb_get_line_number): Throw an
error instead of returning -1.
	* gdb.base/break.exp: Remove unused variable
	bp_location5.
	* gdb.base/hbreak2.exp: Likewise.
	* gdb.base/sepdebug.exp: Likewise.
2012-03-09 04:38:53 +00:00
Yao Qi f4647387fe 2012-03-08 Yao Qi <yao@codesourcery.com>
Pedro Alves  <palves@redhat.com>

	Fix PR server/13392.
	* linux-x86-low.c (amd64_install_fast_tracepoint_jump_pad): Check
	offset of JMP insn.
	* tracepoint.c (remove_tracepoint): New.
	(cmd_qtdp): Call remove_tracepoint when failed to install.

2012-03-08  Yao Qi  <yao@codesourcery.com>
	    Pedro Alves  <palves@redhat.com>

	Fix PR server/13392.
	* gdb.trace/change-loc.exp (tracepoint_change_loc_1): Remove kfail.
	(tracepoint_change_loc_2): Remove kfail.  Return if failed to
	download tracepoints.
	* gdb.trace/pending.exp (pending_tracepoint_works): Likewise.
	(pending_tracepoint_resolved_during_trace): Likewise.
	(pending_tracepoint_installed_during_trace): Likewise.
	(pending_tracepoint_with_action_resolved): Likewise.
2012-03-09 03:47:15 +00:00
Joel Brobecker 6f5e936221 Add missing _initialize_ravenscar_sparc prototype.
This is required now that we compile GDB with -Wmissing-prototype.

gdb/ChangeLog:

        * ravenscar-sparc-thread.c (_initialize_ravenscar_sparc): Add
        prototype.
2012-03-09 00:31:15 +00:00
Joel Brobecker 8d037db936 Add missing _initialize_ravenscar prototype.
gdb/ChangeLog:

        * ravenscar-thread.c (_initialize_ravenscar): Add prototype.
2012-03-09 00:31:07 +00:00
gdbadmin 987c5a110d *** empty log message *** 2012-03-09 00:00:02 +00:00
Jan Kratochvil 4e841acf4e gdb/
Fix -Wmissing-prototypes build.
	* arm-linux-nat.c (get_thread_id): Make it static.
	* xtensa-linux-nat.c (get_thread_id): Likewise.
2012-03-08 22:54:30 +00:00
Joel Brobecker c6030312dc Make breakpoint condition detection trace conditional on remote_debug.
gdb/gdbserver/ChangeLog:

        * server.c (process_point_options): If a conditional expression
        is found, only print a message if remote_debug is nonzero.
2012-03-08 22:19:56 +00:00
Keith Seitz 83c532cb59 * gdb.ada/array_bounds.exp: Get breakpoint for line
with "START", not "STOP".
	* gdb.python/py-infthread.exp: Do not continue to
	line marked "Break here.", which is undefined.
2012-03-08 22:19:48 +00:00
Joel Brobecker 735be1a2c1 Revert "ax-gdb: Do not treat enums and bools as integers."
This patch was checked hasn't been reviewed and has been checked in
by mistake (wrong patch applied).
2012-03-08 22:19:09 +00:00
Luis Machado d6b6bbb744 2012-03-08 Luis Machado <lgustavo@codesourcery.com>
Revert:

	2012-03-03  Jan Kratochvil  <jan.kratochvil@redhat.com>

	Implement testsuite workaround for PR breakpoints/13781.
	* gdb.cp/mb-templates.exp: New loop with variable $workaround.
	(set breakpoint condition-evaluation host): New conditional command.
2012-03-08 21:09:17 +00:00
Luis Machado 52323be946 2012-03-08 Luis Machado <lgustavo@codesourcery.com>
* ax-gdb.c (gen_fetch): Fail gracefully and use error instead
	of internal error for unknown/unsupported types.
2012-03-08 21:07:25 +00:00
Joel Brobecker 4bb99ac688 ax-gdb: Do not treat enums and bools as integers.
This patch fixes a problem when using gdb + gdbserver, and trying
to break on a function when one of the (enum) parameters is equal
to a certain value, and the size of that enum is 1 byte.

    (gdb) break mixed.adb:15 if light = green
    Breakpoint 2 at 0x402d5a: file mixed.adb, line 15.
    (gdb) cont
    Continuing.
    [Inferior 1 (process 9742) exited normally]

The debugger should have stopped once when our function was call
with light set to green.

Here is what happens: Because we're using a recent GDBserver,
GDB hands off the evaluation of the condition to GDBserver, by
providing it in the Z0 packet. This is what GDB sends:

    $Z0,402d5a,1;X13,26000622100223ff1c16100219162022011327#cf

I decoded the condition as follow:

    260006    reg 6 -> push
    2210      const8 0x10 -> push
    02        add (stack now has 1 element equal to reg6 + 16)
    23ff1c    const16 0xff1c
    1610      ext 16 (sign extend 16 bits)
    02        add (stack now has 1 element equal to reg6 + 16 - 228)
    19        ref32: Pop as addr, push 32bit value at addr.
    1620      ext 32 (sign extend 32 bits)
    2201      const8 0x01
    13        equal
    27        end

The beginning of the agent expression can be explained by the address
of symbol "light":

    (gdb) info addr light
    Symbol "light" is a variable at frame base reg $rbp offset 16+-228.

However, the mistake is the "ext 32" operation (extend 32 bits),
because our variable is *not* 32bits, only 8:

    (gdb) print light'size
    $5 = 8

But the reason why GDB decides to use a 32bit extension is because
it overrides the symbol's type with a plain integer type in
ax-gdb.c:gen_usual_unary...

      /* If the value is an enum or a bool, call it an integer.  */
    case TYPE_CODE_ENUM:
    case TYPE_CODE_BOOL:
      value->type = builtin_type (exp->gdbarch)->builtin_int;
      break;

... before calling require_rvalue. And of course, that causes the
generator to generate a sizeof(int) extension of the result.

One way to fix this would be to use an integer type of the correct
size, but I do not understand why this is necessary. The two routines
that use that information to generate the opcode down the line are
gen_fetch (for a memory value), or gen_extend (for a register value).
And they both have handling of enums and bools.

So the fix we elected to implement was simply to remove that code.

gdb/ChangeLog:

        * ax-gdb.c (gen_usual_unary): Remove special handling of
        enum and bool types.
2012-03-08 20:54:36 +00:00