* [PATCH] Remove MAX_REGISTER_SIZE from remote-sim.c
@ 2017-02-24 10:03 Alan Hayward
2017-03-23 14:12 ` Alan Hayward
2017-03-24 10:41 ` Yao Qi
0 siblings, 2 replies; 8+ messages in thread
From: Alan Hayward @ 2017-02-24 10:03 UTC (permalink / raw)
To: gdb-patches; +Cc: nd
Used a std::vector in the first case and struct value in the second.
Tested using make check with board files unix and native-gdbserver.
Ok to commit?
Alan.
2017-02-21 Alan Hayward <alan.hayward@arm.com>
* gdb/remote-sim.c (gdbsim_fetch_register): Use vec instead of array.
(gdbsim_store_register): Read register using value.
diff --git a/gdb/remote-sim.c b/gdb/remote-sim.c
index b0c68c617e365c0ea18ac2eca525598b688ffbb5..aeceb06a557eb31778d0a85194fb47ea311eec09 100644
--- a/gdb/remote-sim.c
+++ b/gdb/remote-sim.c
@@ -439,6 +439,9 @@ gdbsim_fetch_register (struct target_ops *ops,
return;
}
+ int regsize = register_size (gdbarch, regno);
+ std::vector<gdb_byte> buf (regsize);
+
switch (gdbarch_register_sim_regno (gdbarch, regno))
{
case LEGACY_SIM_REGNO_IGNORE:
@@ -447,38 +450,32 @@ gdbsim_fetch_register (struct target_ops *ops,
{
/* For moment treat a `does not exist' register the same way
as an ``unavailable'' register. */
- gdb_byte buf[MAX_REGISTER_SIZE];
int nr_bytes;
- memset (buf, 0, MAX_REGISTER_SIZE);
- regcache_raw_supply (regcache, regno, buf);
+ regcache_raw_supply (regcache, regno, buf.data ());
break;
}
default:
{
static int warn_user = 1;
- gdb_byte buf[MAX_REGISTER_SIZE];
int nr_bytes;
gdb_assert (regno >= 0 && regno < gdbarch_num_regs (gdbarch));
- memset (buf, 0, MAX_REGISTER_SIZE);
nr_bytes = sim_fetch_register (sim_data->gdbsim_desc,
gdbarch_register_sim_regno
(gdbarch, regno),
- buf,
- register_size (gdbarch, regno));
+ buf.data (), regsize);
if (nr_bytes > 0
- && nr_bytes != register_size (gdbarch, regno) && warn_user)
+ && nr_bytes != regsize && warn_user)
{
fprintf_unfiltered (gdb_stderr,
"Size of register %s (%d/%d) "
"incorrect (%d instead of %d))",
gdbarch_register_name (gdbarch, regno),
regno,
- gdbarch_register_sim_regno
- (gdbarch, regno),
- nr_bytes, register_size (gdbarch, regno));
+ gdbarch_register_sim_regno (gdbarch, regno),
+ nr_bytes, regsize);
warn_user = 0;
}
/* FIXME: cagney/2002-05-27: Should check `nr_bytes == 0'
@@ -486,13 +483,13 @@ gdbsim_fetch_register (struct target_ops *ops,
which registers are fetchable. */
/* Else if (nr_bytes < 0): an old simulator, that doesn't
think to return the register size. Just assume all is ok. */
- regcache_raw_supply (regcache, regno, buf);
+ regcache_raw_supply (regcache, regno, buf.data ());
if (remote_debug)
{
fprintf_unfiltered (gdb_stdlog,
"gdbsim_fetch_register: %d", regno);
/* FIXME: We could print something more intelligible. */
- dump_mem (buf, register_size (gdbarch, regno));
+ dump_mem (buf.data (), regsize);
}
break;
}
@@ -516,15 +513,14 @@ gdbsim_store_register (struct target_ops *ops,
}
else if (gdbarch_register_sim_regno (gdbarch, regno) >= 0)
{
- gdb_byte tmp[MAX_REGISTER_SIZE];
- int nr_bytes;
-
- regcache_cooked_read (regcache, regno, tmp);
- nr_bytes = sim_store_register (sim_data->gdbsim_desc,
- gdbarch_register_sim_regno
- (gdbarch, regno),
- tmp, register_size (gdbarch, regno));
- if (nr_bytes > 0 && nr_bytes != register_size (gdbarch, regno))
+ int regsize = register_size (gdbarch, regno);
+ int sim_regno = gdbarch_register_sim_regno (gdbarch, regno);
+
+ struct value *value = regcache_cooked_read_value (regcache, regno);
+ int nr_bytes = sim_store_register (sim_data->gdbsim_desc, sim_regno,
+ value_contents_all (value), regsize);
+
+ if (nr_bytes > 0 && nr_bytes != regsize)
internal_error (__FILE__, __LINE__,
_("Register size different to expected"));
if (nr_bytes < 0)
@@ -538,8 +534,11 @@ gdbsim_store_register (struct target_ops *ops,
{
fprintf_unfiltered (gdb_stdlog, "gdbsim_store_register: %d", regno);
/* FIXME: We could print something more intelligible. */
- dump_mem (tmp, register_size (gdbarch, regno));
+ dump_mem (value_contents_all (value), regsize);
}
+
+ release_value (value);
+ value_free (value);
}
}
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] Remove MAX_REGISTER_SIZE from remote-sim.c
2017-02-24 10:03 [PATCH] Remove MAX_REGISTER_SIZE from remote-sim.c Alan Hayward
@ 2017-03-23 14:12 ` Alan Hayward
2017-03-24 10:41 ` Yao Qi
1 sibling, 0 replies; 8+ messages in thread
From: Alan Hayward @ 2017-03-23 14:12 UTC (permalink / raw)
To: gdb-patches; +Cc: nd
Ping.
> On 24 Feb 2017, at 10:03, Alan Hayward <Alan.Hayward@arm.com> wrote:
>
> Used a std::vector in the first case and struct value in the second.
>
> Tested using make check with board files unix and native-gdbserver.
>
> Ok to commit?
>
> Alan.
>
>
> 2017-02-21 Alan Hayward <alan.hayward@arm.com>
>
> * gdb/remote-sim.c (gdbsim_fetch_register): Use vec instead of array.
> (gdbsim_store_register): Read register using value.
>
>
> diff --git a/gdb/remote-sim.c b/gdb/remote-sim.c
> index b0c68c617e365c0ea18ac2eca525598b688ffbb5..aeceb06a557eb31778d0a85194fb47ea311eec09 100644
> --- a/gdb/remote-sim.c
> +++ b/gdb/remote-sim.c
> @@ -439,6 +439,9 @@ gdbsim_fetch_register (struct target_ops *ops,
> return;
> }
>
> + int regsize = register_size (gdbarch, regno);
> + std::vector<gdb_byte> buf (regsize);
> +
> switch (gdbarch_register_sim_regno (gdbarch, regno))
> {
> case LEGACY_SIM_REGNO_IGNORE:
> @@ -447,38 +450,32 @@ gdbsim_fetch_register (struct target_ops *ops,
> {
> /* For moment treat a `does not exist' register the same way
> as an ``unavailable'' register. */
> - gdb_byte buf[MAX_REGISTER_SIZE];
> int nr_bytes;
>
> - memset (buf, 0, MAX_REGISTER_SIZE);
> - regcache_raw_supply (regcache, regno, buf);
> + regcache_raw_supply (regcache, regno, buf.data ());
> break;
> }
>
> default:
> {
> static int warn_user = 1;
> - gdb_byte buf[MAX_REGISTER_SIZE];
> int nr_bytes;
>
> gdb_assert (regno >= 0 && regno < gdbarch_num_regs (gdbarch));
> - memset (buf, 0, MAX_REGISTER_SIZE);
> nr_bytes = sim_fetch_register (sim_data->gdbsim_desc,
> gdbarch_register_sim_regno
> (gdbarch, regno),
> - buf,
> - register_size (gdbarch, regno));
> + buf.data (), regsize);
> if (nr_bytes > 0
> - && nr_bytes != register_size (gdbarch, regno) && warn_user)
> + && nr_bytes != regsize && warn_user)
> {
> fprintf_unfiltered (gdb_stderr,
> "Size of register %s (%d/%d) "
> "incorrect (%d instead of %d))",
> gdbarch_register_name (gdbarch, regno),
> regno,
> - gdbarch_register_sim_regno
> - (gdbarch, regno),
> - nr_bytes, register_size (gdbarch, regno));
> + gdbarch_register_sim_regno (gdbarch, regno),
> + nr_bytes, regsize);
> warn_user = 0;
> }
> /* FIXME: cagney/2002-05-27: Should check `nr_bytes == 0'
> @@ -486,13 +483,13 @@ gdbsim_fetch_register (struct target_ops *ops,
> which registers are fetchable. */
> /* Else if (nr_bytes < 0): an old simulator, that doesn't
> think to return the register size. Just assume all is ok. */
> - regcache_raw_supply (regcache, regno, buf);
> + regcache_raw_supply (regcache, regno, buf.data ());
> if (remote_debug)
> {
> fprintf_unfiltered (gdb_stdlog,
> "gdbsim_fetch_register: %d", regno);
> /* FIXME: We could print something more intelligible. */
> - dump_mem (buf, register_size (gdbarch, regno));
> + dump_mem (buf.data (), regsize);
> }
> break;
> }
> @@ -516,15 +513,14 @@ gdbsim_store_register (struct target_ops *ops,
> }
> else if (gdbarch_register_sim_regno (gdbarch, regno) >= 0)
> {
> - gdb_byte tmp[MAX_REGISTER_SIZE];
> - int nr_bytes;
> -
> - regcache_cooked_read (regcache, regno, tmp);
> - nr_bytes = sim_store_register (sim_data->gdbsim_desc,
> - gdbarch_register_sim_regno
> - (gdbarch, regno),
> - tmp, register_size (gdbarch, regno));
> - if (nr_bytes > 0 && nr_bytes != register_size (gdbarch, regno))
> + int regsize = register_size (gdbarch, regno);
> + int sim_regno = gdbarch_register_sim_regno (gdbarch, regno);
> +
> + struct value *value = regcache_cooked_read_value (regcache, regno);
> + int nr_bytes = sim_store_register (sim_data->gdbsim_desc, sim_regno,
> + value_contents_all (value), regsize);
> +
> + if (nr_bytes > 0 && nr_bytes != regsize)
> internal_error (__FILE__, __LINE__,
> _("Register size different to expected"));
> if (nr_bytes < 0)
> @@ -538,8 +534,11 @@ gdbsim_store_register (struct target_ops *ops,
> {
> fprintf_unfiltered (gdb_stdlog, "gdbsim_store_register: %d", regno);
> /* FIXME: We could print something more intelligible. */
> - dump_mem (tmp, register_size (gdbarch, regno));
> + dump_mem (value_contents_all (value), regsize);
> }
> +
> + release_value (value);
> + value_free (value);
> }
> }
>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] Remove MAX_REGISTER_SIZE from remote-sim.c
2017-02-24 10:03 [PATCH] Remove MAX_REGISTER_SIZE from remote-sim.c Alan Hayward
2017-03-23 14:12 ` Alan Hayward
@ 2017-03-24 10:41 ` Yao Qi
2017-03-24 11:41 ` Alan Hayward
[not found] ` <E7F813B0-BCB9-464C-BD4C-95F0A3D789E1@arm.com>
1 sibling, 2 replies; 8+ messages in thread
From: Yao Qi @ 2017-03-24 10:41 UTC (permalink / raw)
To: Alan Hayward; +Cc: gdb-patches, vapier
Alan Hayward <Alan.Hayward@arm.com> writes:
> Used a std::vector in the first case and struct value in the second.
>
> Tested using make check with board files unix and native-gdbserver.
>
What is your target triplet? Do you see remote-sim.o in your build
directory? remote-sim.c may not be built at all.
> Ok to commit?
>
It is good to me. This patch is related to SIM, so I'd like Mike to
take a look too.
--
Yao (齐尧)
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] Remove MAX_REGISTER_SIZE from remote-sim.c
2017-03-24 10:41 ` Yao Qi
@ 2017-03-24 11:41 ` Alan Hayward
[not found] ` <E7F813B0-BCB9-464C-BD4C-95F0A3D789E1@arm.com>
1 sibling, 0 replies; 8+ messages in thread
From: Alan Hayward @ 2017-03-24 11:41 UTC (permalink / raw)
To: Yao Qi; +Cc: gdb-patches, vapier, nd
> On 24 Mar 2017, at 10:41, Yao Qi <qiyaoltc@gmail.com> wrote:
>
> Alan Hayward <Alan.Hayward@arm.com> writes:
>
>> Used a std::vector in the first case and struct value in the second.
>>
>> Tested using make check with board files unix and native-gdbserver.
>>
>
> What is your target triplet? Do you see remote-sim.o in your build
> directory? remote-sim.c may not be built at all.
You’re correct - I’m not building remote-sim at all!
Forcing SIM_OBS in Makefile.in gives me a compile error (just need to
cast result of value_contents_all to remove the const).
Is there an easy way to build and test remote-sim ?
>
>> Ok to commit?
>>
>
> It is good to me. This patch is related to SIM, so I'd like Mike to
> take a look too.
>
> --
> Yao (齐尧)
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] Remove MAX_REGISTER_SIZE from remote-sim.c
[not found] ` <E7F813B0-BCB9-464C-BD4C-95F0A3D789E1@arm.com>
@ 2017-03-24 11:59 ` Yao Qi
2017-06-26 12:41 ` Alan Hayward
0 siblings, 1 reply; 8+ messages in thread
From: Yao Qi @ 2017-03-24 11:59 UTC (permalink / raw)
To: Alan Hayward; +Cc: gdb-patches, vapier
On Fri, Mar 24, 2017 at 11:39 AM, Alan Hayward <Alan.Hayward@arm.com> wrote:
>>
>> What is your target triplet? Do you see remote-sim.o in your build
>> directory? remote-sim.c may not be built at all.
>
> You’re correct - I’m not building remote-sim at all!
> Forcing SIM_OBS in Makefile.in gives me a compile error (just need to
> cast result of value_contents_all to remove the const).
>
> Is there an easy way to build and test remote-sim ?
>
remote-sim.c is built if I configure gdb --target=arm-none-eabi.
I don't know how to test either, running sim test cases, Mike?
--
Yao (齐尧)
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] Remove MAX_REGISTER_SIZE from remote-sim.c
2017-03-24 11:59 ` Yao Qi
@ 2017-06-26 12:41 ` Alan Hayward
2017-06-27 10:57 ` Yao Qi
0 siblings, 1 reply; 8+ messages in thread
From: Alan Hayward @ 2017-06-26 12:41 UTC (permalink / raw)
To: Yao Qi; +Cc: gdb-patches, vapier, nd
> On 24 Mar 2017, at 11:59, Yao Qi <qiyaoltc@gmail.com> wrote:
>
> On Fri, Mar 24, 2017 at 11:39 AM, Alan Hayward <Alan.Hayward@arm.com> wrote:
>>>
>>> What is your target triplet? Do you see remote-sim.o in your build
>>> directory? remote-sim.c may not be built at all.
>>
>> You’re correct - I’m not building remote-sim at all!
>> Forcing SIM_OBS in Makefile.in gives me a compile error (just need to
>> cast result of value_contents_all to remove the const).
>>
>> Is there an easy way to build and test remote-sim ?
>>
>
> remote-sim.c is built if I configure gdb --target=arm-none-eabi.
> I don't know how to test either, running sim test cases, Mike?
>
> --
> Yao (齐尧)
Reworked this patch based on changes I’ve mode to similar patches.
Built using --target=arm-none-eabi then tested using
--target_board=arm-sim
Ok to commit?
2017-06-26 Alan Hayward <alan.hayward@arm.com>
* remote-sim.c (gdbsim_fetch_register): Use byte_vector.
(gdbsim_store_register): Likewise.
diff --git a/gdb/remote-sim.c b/gdb/remote-sim.c
index fd1bc66642389a4879171af8eeee30a5df7cbaec..8ff0bc937e5f2ec61d965788166b2bb12fdf7045 100644
--- a/gdb/remote-sim.c
+++ b/gdb/remote-sim.c
@@ -40,6 +40,7 @@
#include "arch-utils.h"
#include "readline/readline.h"
#include "gdbthread.h"
+#include "common/byte-vector.h"
/* Prototypes */
@@ -448,38 +449,32 @@ gdbsim_fetch_register (struct target_ops *ops,
{
/* For moment treat a `does not exist' register the same way
as an ``unavailable'' register. */
- gdb_byte buf[MAX_REGISTER_SIZE];
- int nr_bytes;
-
- memset (buf, 0, MAX_REGISTER_SIZE);
- regcache_raw_supply (regcache, regno, buf);
+ regcache->raw_supply_zeroed (regno);
break;
}
default:
{
static int warn_user = 1;
- gdb_byte buf[MAX_REGISTER_SIZE];
+ int regsize = register_size (gdbarch, regno);
+ gdb::byte_vector buf (regsize, 0);
int nr_bytes;
gdb_assert (regno >= 0 && regno < gdbarch_num_regs (gdbarch));
- memset (buf, 0, MAX_REGISTER_SIZE);
nr_bytes = sim_fetch_register (sim_data->gdbsim_desc,
gdbarch_register_sim_regno
(gdbarch, regno),
- buf,
- register_size (gdbarch, regno));
+ buf.data (), regsize);
if (nr_bytes > 0
- && nr_bytes != register_size (gdbarch, regno) && warn_user)
+ && nr_bytes != regsize && warn_user)
{
fprintf_unfiltered (gdb_stderr,
"Size of register %s (%d/%d) "
"incorrect (%d instead of %d))",
gdbarch_register_name (gdbarch, regno),
regno,
- gdbarch_register_sim_regno
- (gdbarch, regno),
- nr_bytes, register_size (gdbarch, regno));
+ gdbarch_register_sim_regno (gdbarch, regno),
+ nr_bytes, regsize);
warn_user = 0;
}
/* FIXME: cagney/2002-05-27: Should check `nr_bytes == 0'
@@ -487,13 +482,13 @@ gdbsim_fetch_register (struct target_ops *ops,
which registers are fetchable. */
/* Else if (nr_bytes < 0): an old simulator, that doesn't
think to return the register size. Just assume all is ok. */
- regcache_raw_supply (regcache, regno, buf);
+ regcache->raw_supply (regno, buf.data ());
if (remote_debug)
{
fprintf_unfiltered (gdb_stdlog,
"gdbsim_fetch_register: %d", regno);
/* FIXME: We could print something more intelligible. */
- dump_mem (buf, register_size (gdbarch, regno));
+ dump_mem (buf.data (), regsize);
}
break;
}
@@ -518,15 +513,17 @@ gdbsim_store_register (struct target_ops *ops,
}
else if (gdbarch_register_sim_regno (gdbarch, regno) >= 0)
{
- gdb_byte tmp[MAX_REGISTER_SIZE];
+ int regsize = register_size (gdbarch, regno);
+ gdb::byte_vector tmp (regsize);
int nr_bytes;
- regcache_cooked_read (regcache, regno, tmp);
+ regcache->cooked_read (regno, tmp.data ());
nr_bytes = sim_store_register (sim_data->gdbsim_desc,
gdbarch_register_sim_regno
(gdbarch, regno),
- tmp, register_size (gdbarch, regno));
- if (nr_bytes > 0 && nr_bytes != register_size (gdbarch, regno))
+ tmp.data (), regsize);
+
+ if (nr_bytes > 0 && nr_bytes != regsize)
internal_error (__FILE__, __LINE__,
_("Register size different to expected"));
if (nr_bytes < 0)
@@ -540,7 +537,7 @@ gdbsim_store_register (struct target_ops *ops,
{
fprintf_unfiltered (gdb_stdlog, "gdbsim_store_register: %d", regno);
/* FIXME: We could print something more intelligible. */
- dump_mem (tmp, register_size (gdbarch, regno));
+ dump_mem (tmp.data (), regsize);
}
}
}
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] Remove MAX_REGISTER_SIZE from remote-sim.c
2017-06-26 12:41 ` Alan Hayward
@ 2017-06-27 10:57 ` Yao Qi
2017-06-27 12:14 ` Alan Hayward
0 siblings, 1 reply; 8+ messages in thread
From: Yao Qi @ 2017-06-27 10:57 UTC (permalink / raw)
To: Alan Hayward; +Cc: gdb-patches, vapier, nd
Alan Hayward <Alan.Hayward@arm.com> writes:
Patch is good to me.
> if (nr_bytes > 0
> - && nr_bytes != register_size (gdbarch, regno) && warn_user)
> + && nr_bytes != regsize && warn_user)
> {
A nit, can you put them in a single line?
--
Yao (齐尧)
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] Remove MAX_REGISTER_SIZE from remote-sim.c
2017-06-27 10:57 ` Yao Qi
@ 2017-06-27 12:14 ` Alan Hayward
0 siblings, 0 replies; 8+ messages in thread
From: Alan Hayward @ 2017-06-27 12:14 UTC (permalink / raw)
To: Yao Qi; +Cc: gdb-patches, vapier, nd
> On 27 Jun 2017, at 11:57, Yao Qi <qiyaoltc@gmail.com> wrote:
>
> Alan Hayward <Alan.Hayward@arm.com> writes:
>
> Patch is good to me.
>
>> if (nr_bytes > 0
>> - && nr_bytes != register_size (gdbarch, regno) && warn_user)
>> + && nr_bytes != regsize && warn_user)
>> {
>
> A nit, can you put them in a single line?
>
> --
> Yao (齐尧)
Pushed with the above IF on a single line.
Alan.
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2017-06-27 12:14 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-02-24 10:03 [PATCH] Remove MAX_REGISTER_SIZE from remote-sim.c Alan Hayward
2017-03-23 14:12 ` Alan Hayward
2017-03-24 10:41 ` Yao Qi
2017-03-24 11:41 ` Alan Hayward
[not found] ` <E7F813B0-BCB9-464C-BD4C-95F0A3D789E1@arm.com>
2017-03-24 11:59 ` Yao Qi
2017-06-26 12:41 ` Alan Hayward
2017-06-27 10:57 ` Yao Qi
2017-06-27 12:14 ` Alan Hayward
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).