Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Jan Kratochvil <jan.kratochvil@redhat.com>
To: Joel Brobecker <brobecker@adacore.com>
Cc: Philippe Waroquiers <philippe.waroquiers@skynet.be>,
	       gdb-patches@sourceware.org,
	Pedro Alves <palves@redhat.com>
Subject: Re: [patch] [i386] Put hlt at the ON_STACK breakpoint  [Re: GDB 7.4.91 available for testing]
Date: Mon, 23 Jul 2012 16:36:00 -0000	[thread overview]
Message-ID: <20120723163513.GA1222@host2.jankratochvil.net> (raw)
In-Reply-To: <20120723155951.GA24718@adacore.com>

On Mon, 23 Jul 2012 17:59:51 +0200, Joel Brobecker wrote:
> It even seems to me that this should be done on all platforms, no?

Yes; just looking at the other archs it was not trivial to me so I wanted to
be sure it at least really helps valgrind.


> And instead of writing an instruction of the
> arch's choosing, why not write the breakpoint trap instruction?

It depends on the opinion.  I wanted to make clear there is a real GDB
breakpoint on top of it and in normal GDB control flow the 'hlt' instruction
is never executed by CPU.  There are other reasons why to put int3 there,
maybe it would be more clear to the users that way when I think about it now.

It also does not matter much, users do not probably disassemble
the <function called from gdb> frame.


> > +  /* 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)?

It is a nitpick but 'static const' is more effective than just 'const'.
In the latter case compiler has to create the storage for variable on stack
(probably to at least ensure its unique address), in the former case it just
takes an address of .rodata variable, which is generally cheaper.

const
   4:	48 8d 7c 24 08       	lea    0x8(%rsp),%rdi
   9:	c7 44 24 08 2a 00 00 	movl   $0x2a,0x8(%rsp)
  10:	00 
  [Nr] Name              Type            Address          Off    Size   ES Flg Lk Inf Al
  ---- no .rodata
vs.
static const
   4:	bf 00 00 00 00       	mov    $0x0,%edi
			5: R_X86_64_32	.rodata
  [Nr] Name              Type            Address          Off    Size   ES Flg Lk Inf Al
  [ 5] .rodata           PROGBITS        0000000000000000 00005c 000004 00   A  0   0  4


> 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.  */

OK, I will update the patch later for check-in.


Thanks,
Jan


  reply	other threads:[~2012-07-23 16:36 UTC|newest]

Thread overview: 56+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20120718163413.GA17548@adacore.com>
     [not found] ` <1342739016.2220.32.camel@soleil>
     [not found]   ` <20120720071158.GA7053@host2.jankratochvil.net>
     [not found]     ` <1342817409.2149.41.camel@soleil>
     [not found]       ` <20120722173053.GA22036@host2.jankratochvil.net>
     [not found]         ` <1342983655.2301.55.camel@soleil>
2012-07-23  7:22           ` Jan Kratochvil
2012-07-23 16:00             ` Joel Brobecker
2012-07-23 16:36               ` Jan Kratochvil [this message]
2012-07-23 20:07                 ` Philippe Waroquiers
2012-07-23 20:16                   ` Jan Kratochvil
2012-07-23 20:37                     ` Philippe Waroquiers
2012-07-25 14:49                       ` Joel Brobecker
2012-07-25 20:04                         ` Philippe Waroquiers
2012-07-25 20:11                           ` Jan Kratochvil
2012-07-25 20:39                             ` Philippe Waroquiers
2012-07-25 14:59                       ` Pedro Alves
2012-07-25 20:24                         ` Philippe Waroquiers
2012-07-25 21:27                           ` Joel Brobecker
2012-07-25 21:46                             ` Philippe Waroquiers
2012-07-25 22:39                               ` Joel Brobecker
2012-07-26 21:24                                 ` [patchv2] Write bpt at the ON_STACK bpt address Jan Kratochvil
2012-07-26 21:50                                   ` Philippe Waroquiers
2012-07-27 18:47                                     ` Jan Kratochvil
2012-07-28  7:28                                       ` Eli Zaretskii
2012-07-28  7:42                                         ` Jan Kratochvil
2012-07-31  7:37                                       ` [commit+7.5] " Jan Kratochvil
2012-08-01  9:08                                         ` [commit#2+7.5] testsuite: valgrind-infcall.exp UNSUPPORTED update [Re: [commit+7.5] [patchv2] Write bpt at the ON_STACK bpt address] Jan Kratochvil
2012-08-02 22:49                                         ` [commit+7.5] [patchv2] Write bpt at the ON_STACK bpt address Edjunior Barbosa Machado
2012-08-02 23:09                                           ` Sergio Durigan Junior
2012-08-03  0:15                                             ` Edjunior Barbosa Machado
2012-08-03 11:23                                               ` Jan Kratochvil
2012-08-03 12:09                                                 ` Edjunior Barbosa Machado
2012-08-03  1:00                                             ` Pedro Alves
2012-08-03  1:48                                               ` Sergio Durigan Junior
2012-08-03  2:30                                                 ` Edjunior Barbosa Machado
2012-08-03 21:45                                                   ` Philippe Waroquiers
2012-08-03 14:23                                               ` Tom Tromey
2012-08-03 14:31                                                 ` Jan Kratochvil
2012-08-03 15:02                                                   ` Edjunior Barbosa Machado
2012-08-03 15:08                                                     ` Jan Kratochvil
2012-08-03 16:43                                                       ` Edjunior Barbosa Machado
2012-08-03 16:46                                                         ` Jan Kratochvil
2012-08-03 18:00                                                           ` Edjunior Barbosa Machado
2012-08-03 20:23                                           ` Jan Kratochvil
2012-08-03 21:46                                             ` Edjunior Barbosa Machado
2012-08-06 18:40                                               ` Tom Tromey
2012-07-31  7:40                                       ` [commit] valgrind-db-attach.exp: Do not run in remote mode [Re: [patchv2] Write bpt at the ON_STACK bpt address] Jan Kratochvil
2012-07-26 23:14                                   ` [patchv2] Write bpt at the ON_STACK bpt address Maciej W. Rozycki
2012-07-27 16:02                                     ` Jan Kratochvil
2012-07-28  0:10                                       ` Maciej W. Rozycki
2012-07-28  6:06                                         ` Jan Kratochvil
2012-07-30 18:09                                           ` Maciej W. Rozycki
2012-07-26 23:15                                   ` Philippe Waroquiers
2012-07-27 16:03                                     ` Jan Kratochvil
2012-07-27 15:21                                   ` Pedro Alves
2012-07-26 21:56                                 ` [patch] [i386] Put hlt at the ON_STACK breakpoint [Re: GDB 7.4.91 available for testing] Philippe Waroquiers
2012-07-26 22:41                                   ` Philippe Waroquiers
2012-07-26  5:13                               ` Jan Kratochvil
2012-07-26 12:48                           ` Pedro Alves
2012-07-26 22:21                             ` Philippe Waroquiers
2012-07-27 14:59                               ` Pedro Alves

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20120723163513.GA1222@host2.jankratochvil.net \
    --to=jan.kratochvil@redhat.com \
    --cc=brobecker@adacore.com \
    --cc=gdb-patches@sourceware.org \
    --cc=palves@redhat.com \
    --cc=philippe.waroquiers@skynet.be \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox