Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Joel Brobecker <brobecker@adacore.com>
To: Pierre Muller <muller@ics.u-strasbg.fr>
Cc: 'Mark Kettenis' <mark.kettenis@xs4all.nl>, gdb-patches@sourceware.org
Subject: Re: [RFA] i386-tdep.c: Add i386_skip_noop function
Date: Fri, 25 Jan 2008 16:38:00 -0000	[thread overview]
Message-ID: <20080125161247.GJ3979@adacore.com> (raw)
In-Reply-To: <004701c85f53$2ef82dc0$8ce88940$@u-strasbg.fr>

Hi Pierre,

This is not a formal review of your code - Mark is our de-facto
maintainer so unless he asks for some help, I prefer to defer to him.
But I thought I'd put a "Patch Champion" hat on, and make some tiny
comments.

> +/* Some Microsoft's system dll functions start with a

I'm not a native English speaker (originally I'm French, as I suspect
you are :), but the above sounds a little funny to me. I suggest either:

  - Some of Microsoft's system dll functions ...
  - Some functions in Microsoft's system dlls ...

Also, you inserted a line-break a bit early IMO. It's not consistent
with the line-length of the rest of the comment. But that's really
very very minor - you might have thought that you wanted `mov %edi,%edi'
and the word "instruction" on the same line, which is also a good
argument.

> +   `mov %edi,%edi' instruction, which is effectively a two byte `nop'.
                                                          ^^^^^^^^
                                            I suggest "2-byte", see below.
> +   This instruction is used for hot patching support, together with 5
> +   bytes of slack before the function.

It would be nicer, IMO, if "5" and "bytes" were on the same line.
It's easier to read.

> Later, when hot-patching, the 2

"2-byte" (no space, a dash).

> +   byte op can be replaced with a relative jump to 5 bytes back.  The 5
                                                   ^^
              Is the "to" correct, here? To me, I think it should be
              "a relative jump 5 bytes back".
> +   A two byte nop is used to be sure that no thread is executing
        ^^^^^^^^
I suggest you remain consistent and use "2-byte" everywhere.

> +   the instruction at byte 1 of the function, so the patching can be
> +   performed atomically.  */
> +
> +/* 0x8b,0xff matches `mov %edi,%edi' */
> +  if (op[0] == 0x8b && op[1] == 0xff)

The practice in that file (and many other tdep files that I have
worked on) is to just specify the instruction. Like so:

  if (op[0] == 0x8b && op[1] == 0xff)  /* mov %edi,%edi */

> +/* Here other patterns can be added if found.  */

I think that this comment in unnecessary, but check with Mark.


> +/* Quoted from Mark Kettenis:
> +   "I've heard of a couple of code generation tools that do something
> similar
> +   as Microsoft and insert nop instructions at the start of a function to
> be
> +   patched up later.  So other targets could benefit from the same code.  
> +   And calling this function unconditionally keeps the code simple."  */

I suggest that this comment be moved up, inside/after the comment explaining
what happens in some DLL functions.  You don't need to quote him, I
think that it's better if you write something that connects better with
what you wrote. For instance:

  Mark Kettenis (or maybe just "we") have heard of a couple of code
  generation tools taht do something similer.

Otherwise, the code itself looks good to me!

-- 
Joel


  reply	other threads:[~2008-01-25 16:13 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-12-10 16:45 [RFC] Enhance backtrace for microsoft system DLL calls Pierre Muller
2007-12-10 17:37 ` Pedro Alves
2007-12-10 18:08   ` Daniel Jacobowitz
2007-12-10 18:41 ` Pedro Alves
2007-12-11 10:44 ` Mark Kettenis
2007-12-11 17:29   ` Pierre Muller
2008-01-14 10:16     ` [RFC-v2] " Pierre Muller
2008-01-24  0:52       ` Pedro Alves
2008-01-24 17:51       ` Mark Kettenis
2008-01-25 14:16         ` [RFA] i386-tdep.c: Add i386_skip_noop function Pierre Muller
2008-01-25 16:38           ` Joel Brobecker [this message]
2008-01-25 16:46             ` [RFA] i386-tdep.c: Add i386_skip_noop function; updated Pierre Muller
2008-01-25 17:05               ` Mark Kettenis
2008-01-25 17:26                 ` Joel Brobecker
2008-01-25 18:50                 ` Pierre Muller

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=20080125161247.GJ3979@adacore.com \
    --to=brobecker@adacore.com \
    --cc=gdb-patches@sourceware.org \
    --cc=mark.kettenis@xs4all.nl \
    --cc=muller@ics.u-strasbg.fr \
    /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