From: Joel Brobecker <brobecker@adacore.com>
To: Kevin Buettner <kevinb@redhat.com>
Cc: gdb-patches@sourceware.org
Subject: Re: [RFC] remote-mips.c: Add support for NEC rockhopper boards
Date: Sat, 06 Mar 2010 04:42:00 -0000 [thread overview]
Message-ID: <20100306044223.GP2832@adacore.com> (raw)
In-Reply-To: <20100305161522.735aadec@redhat.com>
> * remote-mips.c (rockhopper_ops): New target_ops struct.
> (MON_ROCKHOPPER): New mips_monitor_type.
> (read_hex_value): New function.
> (mips_request): Send 8-byte values with a 'T' packet. Read the
> packet argument as a string and use read_hex_value to parse it.
> (mips_exit_debug): Wait for response when using MON_ROCKHOPPER.
> (rockhopper_open): New function.
> (mips_wait): Read the PC, FP and SP fields as strings. Use
> read_hex_value to parse them and mips_set_register to commit them.
> (mips_set_register): New function.
> (mips_fetch_registers): Do not cast register value to "unsigned"
> when reading a MON_ROCKHOPPER 't' packet. Use mips_set_register.
> (mips_store_registers): Use a 'T' packet to set registers when
> using MON_ROCKHOPPER.
> (pmon_end_download): Don't run initEther if using MON_ROCKHOPPER
> and expect the total to be printed before the entry address.
> (_initialize_remote_mips): Initialize and add rockhopper_ops.
I have a few questions on a few things I don't understand.
> @@ -1196,11 +1227,12 @@ mips_request (int cmd,
> {
> int addr_size = gdbarch_addr_bit (target_gdbarch) / 8;
> char myBuff[DATA_MAXLEN + 1];
> + char response_string[17];
[...]
> - if (sscanf (buff, "0x%x %c 0x%x 0x%lx",
> - &rpid, &rcmd, &rerrflg, &rresponse) != 4
> + if (sscanf (buff, "0x%x %c 0x%x 0x%16s",
> + &rpid, &rcmd, &rerrflg, response_string) != 4
> + || !read_hex_value (response_string, &rresponse)
I don't understand the need to change the sscanf format for the last
item from %lx to %16s. It definitely makes the code more complex...
> +static void
> +mips_set_register (int regno, ULONGEST value)
[...]
> + if (mips_monitor != MON_ROCKHOPPER
> + && (regno == mips_regnum (gdbarch)->pc || regno < 32))
> + /* Some 64-bit boards have monitors that only send the bottom 32 bits.
> + In such cases we can only really debug 32-bit code properly so,
> + when reading a GPR or the PC, assume that the full 64-bit
> + value is the sign extension of the lower 32 bits. */
> + store_signed_integer (buf, register_size (gdbarch, regno), byte_order,
> + value);
> + else
> + store_unsigned_integer (buf, register_size (gdbarch, regno), byte_order,
> + value);
I just wanted to make sure that you are sure that this is correct
(you must be - otherwise I think it'd have shown up in testing).
But it's significantly different from the code that it replaces,
so it attracted my attention. I guess the initial code had a bug
that's unrelated to the rockhopper, which this hunk fixes.
> @@ -1942,6 +1998,9 @@ mips_fetch_registers (struct target_ops
> if (mips_monitor == MON_DDB)
> val = (unsigned) mips_request ('t', pmon_reg, 0,
> &err, mips_receive_wait, NULL);
> + else if (mips_monitor == MON_ROCKHOPPER)
> + val = mips_request ('t', pmon_reg, 0,
> + &err, mips_receive_wait, NULL);
In this function, val is declared as "unsigned LONGEST" (first time
I ever see this!). Can you simplify this to "ULONGEST"? And also remove
the cast to unsigned in the call to mips_request when mips_monitor ==
MON_DDB. And finally, since the call to mips_request seems to be
identical if mips_monitor == MON_DDB or mips_monitor == MON_ROCKHOPPER,
how about merging them the two branches into one block:
if (mips_monitor == MON_DDB || mips_monitor == MON_ROCKHOPPER)
val = mips_request ('t', pmon_reg, 0, [...]);
?
--
Joel
next prev parent reply other threads:[~2010-03-06 4:42 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-03-05 23:15 Kevin Buettner
2010-03-06 4:42 ` Joel Brobecker [this message]
2010-03-06 7:04 ` Kevin Buettner
2010-03-07 5:33 ` Joel Brobecker
2010-03-08 19:10 ` Kevin Buettner
2010-03-09 4:52 ` Joel Brobecker
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=20100306044223.GP2832@adacore.com \
--to=brobecker@adacore.com \
--cc=gdb-patches@sourceware.org \
--cc=kevinb@redhat.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