This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [patch] [i386] Put hlt at the ON_STACK breakpoint [Re: GDB 7.4.91 available for testing]


> 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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]