This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [patch] [i386] Put hlt at the ON_STACK breakpoint [Re: GDB 7.4.91 available for testing]
- From: Joel Brobecker <brobecker at adacore dot com>
- To: Jan Kratochvil <jan dot kratochvil at redhat dot com>
- Cc: Philippe Waroquiers <philippe dot waroquiers at skynet dot be>, gdb-patches at sourceware dot org, Pedro Alves <palves at redhat dot com>
- Date: Mon, 23 Jul 2012 08:59:51 -0700
- Subject: Re: [patch] [i386] Put hlt at the ON_STACK breakpoint [Re: GDB 7.4.91 available for testing]
- References: <20120718163413.GA17548@adacore.com> <1342739016.2220.32.camel@soleil> <20120720071158.GA7053@host2.jankratochvil.net> <1342817409.2149.41.camel@soleil> <20120722173053.GA22036@host2.jankratochvil.net> <1342983655.2301.55.camel@soleil> <20120723072125.GA12958@host2.jankratochvil.net>
> 2012-07-23 Jan Kratochvil <jan.kratochvil@redhat.com>
>
> * i386-tdep.c (i386_push_dummy_code): New variable hlt. Call
> write_memoryg for it.
Not really a review (not the maintainer), but it looks like a good
idea. It even seems to me that this should be done on all platforms,
no? If agreed, perhaps this should be a gdbarch-specific part of the
infcall sequence. And instead of writing an instruction of the
arch's choosing, why not write the breakpoint trap instruction?
In the meantime, a quick fix like yours seems like a good first step.
> diff --git a/gdb/i386-tdep.c b/gdb/i386-tdep.c
> index 84e9794..712f0ff 100644
> --- a/gdb/i386-tdep.c
> +++ b/gdb/i386-tdep.c
> @@ -2340,10 +2340,17 @@ i386_push_dummy_code (struct gdbarch *gdbarch, CORE_ADDR sp, CORE_ADDR funaddr,
> CORE_ADDR *real_pc, CORE_ADDR *bp_addr,
> struct regcache *regcache)
> {
> + /* This hlt instruction is never executed. */
> + static const bfd_byte hlt = 0xf4;
Why make it static? Isn't that going to force the compiler to make
that variable global (put into RO section)?
> + /* While inferior execution will trap on the 0xcc int3 instruction user
> + investigating the memory from GDB could see uninitialized bytes. */
> + write_memory (*bp_addr, &hlt, sizeof (hlt));
I suggest merging the two comments into one at the point where the
intruction is written.
/* Write an legitimate instruction at the point where the infcall
breakpoint is going to be inserted. While this instruction
is never going to be executed, a user investigating the memory
from GDB would see this instruction instead of random
uninitialized bytes. */
--
Joel