From: Joel Brobecker <brobecker@adacore.com>
To: Hui Zhu <teawater@gmail.com>
Cc: Michael Snyder <msnyder@vmware.com>,
gdb-patches ml <gdb-patches@sourceware.org>
Subject: Re: [RFA/i386] Prec x86 MMX 3DNow! SSE SSE2 SSE3 SSSE3 SSE4 support
Date: Sat, 09 Jan 2010 12:28:00 -0000 [thread overview]
Message-ID: <20100109122833.GB2007@adacore.com> (raw)
In-Reply-To: <daef60381001080807i402826d2h43aa14ab242ecf36@mail.gmail.com>
> 2010-01-09 Hui Zhu <teawater@gmail.com>
>
> * i386-tdep.c (OT_DQUAD): New enum.
> (i386_process_record): Add code for MMX, 3DNow!, SSE, SSE2,
> SSE3, SSSE3 and SSE4.
My two cents below. Although I have not seen anything incorrect with this
patch, I am reluctant to approve it outright. MarkK has been maintaining
the x86 target for a while, so it'd be nice if he could take a look
(unless he doesn't want to). Please ping me in a week if no one else
has looked at this patch.
Please also start adding testcases if you can. This is a lot of code,
with lots of hard-coded numbers and very little comments. Perhaps
the code is self-explanatory for an x86 specialist, but I'm not, so...
> @@ -5122,7 +5123,7 @@ i386_process_record (struct gdbarch *gdb
> break;
>
> case 0x62: /* bound */
> - printf_unfiltered (_("Process record doesn't support "
> + printf_unfiltered (_("Process record does not support "
> "instruction bound.\n"));
> ir.addr -= 1;
> goto no_support;
Generally speaking, I find the error message phrased in a way that
they can be confusing sometimes, such as in the example above.
I suggest instead something such as:
Instruction 'bound' is not supported by Process Record.
or:
Instruction not supported by Process Record: bound.
Instruction not supported by Process Record ("bound")
etc...
Also, the design you are using to bail out, is using labels and
gotos unnecessarily. This, in turn, leads to the following oddity
in the case above:
(gdb) cont
Process record does not support instruction bound.
Process record does not support instruction 0x62 at address 0xdeadbeef.
error: Process record: failed to record execution log.
The first two error messages are almost identical and the second one
should simply go. I also think that the reason for failing to record
the execution log should be placed *after* the error message, but
that may be a personal preference. For instance:
error: Process record: Failed to record execution log:
Process record does not support instruction bound at address 0xfeedface.
Again, let's not address this issue as part of this patch, but once
this patch is in, can you please start preparing another one which
cleans this up by getting rid of these labels:
1. Define a new function:
i386_insn_record_not_supported (struct gdbarch *gdbarch,
const char *insn_name,
CORE_ADDR insn_addr);
Change the code above to:
i386_insn_record_not_supported (gdbarch, "bound", ir.addr);
return -1;
2. Define a new function:
i386_opcode_record_not_supported (strct gdbarch* gdbarch,
uint32_t opcode,
CORE_ADDR insn_addr);
Change the goto no_support into:
i386_opcode_record_not_supported (gdbarch, opcode, ir.addr);
return -1;
I would even consider the idea of changing the semantics of your
function, and raise an error whose message carries the reason for
the error, instead of doing the printing yourself before returning -1.
> + case 0x0f0f: /* 3DNow! data */
> + if (i386_record_modrm (&ir))
> + return -1;
This is the type of code that could definitely use some comments.
Why are you return -1 (error condition, right?) in this case? Because
of this immediate return, there won't even been any feedback to the user
as to why the recording failed.
> + switch (tmpu8)
This is also for another followup patch, but if you could use more
meaningful variable names, that would help improve the code quality
(IMO).
--
Joel
next prev parent reply other threads:[~2010-01-09 12:28 UTC|newest]
Thread overview: 39+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-12-07 15:00 [RFA] " Hui Zhu
2009-12-07 16:54 ` Michael Snyder
2009-12-07 17:16 ` Michael Snyder
2009-12-07 17:43 ` Joel Brobecker
2009-12-07 17:54 ` Michael Snyder
2009-12-07 18:00 ` Joel Brobecker
2009-12-07 18:05 ` Michael Snyder
2009-12-08 5:51 ` Hui Zhu
2009-12-08 19:56 ` Michael Snyder
2009-12-07 18:08 ` Doug Evans
2009-12-08 17:43 ` Tom Tromey
2009-12-10 19:52 ` Michael Snyder
2009-12-11 15:00 ` Hui Zhu
2009-12-13 4:28 ` Hui Zhu
2009-12-13 10:35 ` Hui Zhu
2009-12-14 18:24 ` Michael Snyder
2009-12-15 1:47 ` Hui Zhu
2009-12-18 19:44 ` Michael Snyder
2010-01-08 16:07 ` Hui Zhu
2010-01-08 18:45 ` Michael Snyder
2010-01-09 12:28 ` Joel Brobecker [this message]
2010-01-11 2:48 ` [RFA/i386] " Hui Zhu
2010-01-11 4:05 ` Joel Brobecker
2010-01-12 1:38 ` Michael Snyder
2010-03-28 16:27 ` Hui Zhu
2010-03-29 1:35 ` Michael Snyder
2010-03-29 1:36 ` Michael Snyder
2010-03-29 9:25 ` Hui Zhu
2010-03-29 1:40 ` Michael Snyder
2010-03-29 2:23 ` Hui Zhu
2010-03-29 13:21 ` Hui Zhu
2010-03-29 17:52 ` Michael Snyder
2010-03-29 18:11 ` Michael Snyder
2010-03-30 6:29 ` Hui Zhu
2010-03-30 12:55 ` Hui Zhu
2010-04-01 15:36 ` Hui Zhu
2010-04-01 21:50 ` Michael Snyder
2010-04-02 5:14 ` Hui Zhu
2010-03-29 2:18 ` Michael Snyder
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=20100109122833.GB2007@adacore.com \
--to=brobecker@adacore.com \
--cc=gdb-patches@sourceware.org \
--cc=msnyder@vmware.com \
--cc=teawater@gmail.com \
/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