* [PATCH c++ 3/5] mep: Add cast for int to enum conversion
2015-10-11 4:37 [PATCH c++ 1/5] lm32: Add (const gdb_byte *) cast Simon Marchi
@ 2015-10-11 4:37 ` Simon Marchi
2015-10-12 10:35 ` Yao Qi
2015-10-11 4:37 ` [PATCH c++ 2/5] m32c: Split m32c_move_reg_t in read/write variants Simon Marchi
` (5 subsequent siblings)
6 siblings, 1 reply; 22+ messages in thread
From: Simon Marchi @ 2015-10-11 4:37 UTC (permalink / raw)
To: gdb-patches; +Cc: Simon Marchi
Taken directly from Pedro's branch.
gdb/ChangeLog:
* mep-tdep.c (current_me_module): Add cast.
(mep_gdbarch_init): Likewise.
---
gdb/mep-tdep.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/gdb/mep-tdep.c b/gdb/mep-tdep.c
index b6f242f..f7d33ca 100644
--- a/gdb/mep-tdep.c
+++ b/gdb/mep-tdep.c
@@ -848,7 +848,7 @@ current_me_module (void)
ULONGEST regval;
regcache_cooked_read_unsigned (get_current_regcache (),
MEP_MODULE_REGNUM, ®val);
- return regval;
+ return (CONFIG_ATTR) regval;
}
else
return gdbarch_tdep (target_gdbarch ())->me_module;
@@ -2396,7 +2396,10 @@ mep_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
/* The way to get the me_module code depends on the object file
format. At the moment, we only know how to handle ELF. */
if (bfd_get_flavour (info.abfd) == bfd_target_elf_flavour)
- me_module = elf_elfheader (info.abfd)->e_flags & EF_MEP_INDEX_MASK;
+ {
+ int flag = elf_elfheader (info.abfd)->e_flags & EF_MEP_INDEX_MASK;
+ me_module = (CONFIG_ATTR) flag;
+ }
else
me_module = CONFIG_NONE;
}
--
2.6.1
^ permalink raw reply [flat|nested] 22+ messages in thread
* [PATCH c++ 1/5] lm32: Add (const gdb_byte *) cast
@ 2015-10-11 4:37 Simon Marchi
2015-10-11 4:37 ` [PATCH c++ 3/5] mep: Add cast for int to enum conversion Simon Marchi
` (6 more replies)
0 siblings, 7 replies; 22+ messages in thread
From: Simon Marchi @ 2015-10-11 4:37 UTC (permalink / raw)
To: gdb-patches; +Cc: Simon Marchi
There might be a cleaner sequence of function calls to do what is done
here (I don't know), but since I don't want to risk breaking anything,
it's safer to just add the required cast.
gdb/ChangeLog:
* lm32-tdep.c (lm32_push_dummy_call): Add cast.
---
gdb/lm32-tdep.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/gdb/lm32-tdep.c b/gdb/lm32-tdep.c
index 25a7e1e..a0defad 100644
--- a/gdb/lm32-tdep.c
+++ b/gdb/lm32-tdep.c
@@ -289,7 +289,7 @@ lm32_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
regcache_cooked_write_unsigned (regcache, first_arg_reg + i, val);
else
{
- write_memory (sp, (void *) &val, TYPE_LENGTH (arg_type));
+ write_memory (sp, (const gdb_byte *) &val, TYPE_LENGTH (arg_type));
sp -= 4;
}
}
--
2.6.1
^ permalink raw reply [flat|nested] 22+ messages in thread
* [PATCH c++ 4/5] mips: fix void*/gdb_byte* compilation errors
2015-10-11 4:37 [PATCH c++ 1/5] lm32: Add (const gdb_byte *) cast Simon Marchi
2015-10-11 4:37 ` [PATCH c++ 3/5] mep: Add cast for int to enum conversion Simon Marchi
2015-10-11 4:37 ` [PATCH c++ 2/5] m32c: Split m32c_move_reg_t in read/write variants Simon Marchi
@ 2015-10-11 4:37 ` Simon Marchi
2015-10-22 13:13 ` Pedro Alves
2015-10-11 4:44 ` [PATCH c++ 5/5] mips: Add cast for int to enum conversion Simon Marchi
` (3 subsequent siblings)
6 siblings, 1 reply; 22+ messages in thread
From: Simon Marchi @ 2015-10-11 4:37 UTC (permalink / raw)
To: gdb-patches; +Cc: Simon Marchi
The error in mips64_linux_get_longjmp_target is fixed by changing "buf"
to be a gdb_byte*, as usual. supply_32bit_reg and mips64_fill_gregset
do some more complicated things however, so it's safer just to add the
explicit cast and avoid changing the code too much.
gdb/ChangeLog:
* mips-linux-tdep.c (mips64_linux_get_longjmp_target): Change type of
buf to gdb_byte*.
(supply_32bit_reg): Add cast.
(mips64_fill_gregset): Likewise.
---
gdb/mips-linux-tdep.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/gdb/mips-linux-tdep.c b/gdb/mips-linux-tdep.c
index a8c86bb..f7eaf34 100644
--- a/gdb/mips-linux-tdep.c
+++ b/gdb/mips-linux-tdep.c
@@ -120,7 +120,8 @@ supply_32bit_reg (struct regcache *regcache, int regnum, const void *addr)
enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
gdb_byte buf[MAX_REGISTER_SIZE];
store_signed_integer (buf, register_size (gdbarch, regnum), byte_order,
- extract_signed_integer (addr, 4, byte_order));
+ extract_signed_integer ((const gdb_byte *) addr, 4,
+ byte_order));
regcache_raw_supply (regcache, regnum, buf);
}
@@ -334,7 +335,8 @@ mips64_linux_get_longjmp_target (struct frame_info *frame, CORE_ADDR *pc)
CORE_ADDR jb_addr;
struct gdbarch *gdbarch = get_frame_arch (frame);
enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
- void *buf = alloca (gdbarch_ptr_bit (gdbarch) / TARGET_CHAR_BIT);
+ gdb_byte *buf
+ = (gdb_byte *) alloca (gdbarch_ptr_bit (gdbarch) / TARGET_CHAR_BIT);
int element_size = gdbarch_ptr_bit (gdbarch) == 32 ? 4 : 8;
jb_addr = get_frame_register_unsigned (frame, MIPS_A0_REGNUM);
@@ -475,7 +477,7 @@ mips64_fill_gregset (const struct regcache *regcache,
val = extract_signed_integer (buf, register_size (gdbarch, regno),
byte_order);
dst = regp + regaddr;
- store_signed_integer (dst, 8, byte_order, val);
+ store_signed_integer ((gdb_byte *) dst, 8, byte_order, val);
}
}
--
2.6.1
^ permalink raw reply [flat|nested] 22+ messages in thread
* [PATCH c++ 2/5] m32c: Split m32c_move_reg_t in read/write variants
2015-10-11 4:37 [PATCH c++ 1/5] lm32: Add (const gdb_byte *) cast Simon Marchi
2015-10-11 4:37 ` [PATCH c++ 3/5] mep: Add cast for int to enum conversion Simon Marchi
@ 2015-10-11 4:37 ` Simon Marchi
2015-10-12 10:47 ` Yao Qi
2015-10-11 4:37 ` [PATCH c++ 4/5] mips: fix void*/gdb_byte* compilation errors Simon Marchi
` (4 subsequent siblings)
6 siblings, 1 reply; 22+ messages in thread
From: Simon Marchi @ 2015-10-11 4:37 UTC (permalink / raw)
To: gdb-patches; +Cc: Simon Marchi
This allows to avoid casting away the const qualification in
m32c_pseudo_register_write (which is the entry points for all other
register read/write functions).
Also, use gdb_byte* instead of void* to avoid casts when calling gdb
common memory functions. It also allows to remove those "For adderss
arithmetic" local variables.
gdb/ChangeLog:
* m32c-tdep.c (m32c_move_reg_t): Replace with...
(m32c_write_reg_t): ...this and...
(m32c_read_reg_t): ...this.
(struct m32c_reg): Update types of read and write.
(m32c_raw_read): Change declaration type to m32c_read_reg_t and
adjust definition.
(m32c_banked_read): Likewise.
(m32c_sb_read): Likewise.
(m32c_part_read): Likewise.
(m32c_cat_read): Likewise.
(m32c_r3r2r1r0_read): Likewise.
(m32c_raw_write): Change declaration type to m32c_write_reg_t
and adjust definition.
(m32c_banked_write): Likewise.
(m32c_sb_write): Likewise.
(m32c_part_write): Likewise.
(m32c_cat_write): Likewise.
(m32c_r3r2r1r0_write): Likewise.
---
gdb/m32c-tdep.c | 130 +++++++++++++++++++++++++++++---------------------------
1 file changed, 68 insertions(+), 62 deletions(-)
diff --git a/gdb/m32c-tdep.c b/gdb/m32c-tdep.c
index f2d060a..40abe9d 100644
--- a/gdb/m32c-tdep.c
+++ b/gdb/m32c-tdep.c
@@ -46,9 +46,13 @@ struct m32c_reg;
/* The type of a function that moves the value of REG between CACHE or
BUF --- in either direction. */
-typedef enum register_status (m32c_move_reg_t) (struct m32c_reg *reg,
+typedef enum register_status (m32c_write_reg_t) (struct m32c_reg *reg,
+ struct regcache *cache,
+ const gdb_byte *buf);
+
+typedef enum register_status (m32c_read_reg_t) (struct m32c_reg *reg,
struct regcache *cache,
- void *buf);
+ gdb_byte *buf);
struct m32c_reg
{
@@ -78,7 +82,8 @@ struct m32c_reg
/* Functions to read its value from a regcache, and write its value
to a regcache. */
- m32c_move_reg_t *read, *write;
+ m32c_read_reg_t *read;
+ m32c_write_reg_t *write;
/* Data for READ and WRITE functions. The exact meaning depends on
the specific functions selected; see the comments for those
@@ -297,18 +302,24 @@ m32c_register_reggroup_p (struct gdbarch *gdbarch, int regnum,
/* Register move functions. We declare them here using
- m32c_move_reg_t to check the types. */
-static m32c_move_reg_t m32c_raw_read, m32c_raw_write;
-static m32c_move_reg_t m32c_banked_read, m32c_banked_write;
-static m32c_move_reg_t m32c_sb_read, m32c_sb_write;
-static m32c_move_reg_t m32c_part_read, m32c_part_write;
-static m32c_move_reg_t m32c_cat_read, m32c_cat_write;
-static m32c_move_reg_t m32c_r3r2r1r0_read, m32c_r3r2r1r0_write;
-
+ m32c_{read,write}_reg_t to check the types. */
+static m32c_read_reg_t m32c_raw_read,
+ m32c_banked_read,
+ m32c_sb_read,
+ m32c_part_read,
+ m32c_cat_read,
+ m32c_r3r2r1r0_read;
+
+static m32c_write_reg_t m32c_raw_write,
+ m32c_banked_write,
+ m32c_sb_write,
+ m32c_part_write,
+ m32c_cat_write,
+ m32c_r3r2r1r0_write;
/* Copy the value of the raw register REG from CACHE to BUF. */
static enum register_status
-m32c_raw_read (struct m32c_reg *reg, struct regcache *cache, void *buf)
+m32c_raw_read (struct m32c_reg *reg, struct regcache *cache, gdb_byte *buf)
{
return regcache_raw_read (cache, reg->num, buf);
}
@@ -316,9 +327,10 @@ m32c_raw_read (struct m32c_reg *reg, struct regcache *cache, void *buf)
/* Copy the value of the raw register REG from BUF to CACHE. */
static enum register_status
-m32c_raw_write (struct m32c_reg *reg, struct regcache *cache, void *buf)
+m32c_raw_write (struct m32c_reg *reg, struct regcache *cache,
+ const gdb_byte *buf)
{
- regcache_raw_write (cache, reg->num, (const void *) buf);
+ regcache_raw_write (cache, reg->num, buf);
return REG_VALID;
}
@@ -348,7 +360,7 @@ m32c_banked_register (struct m32c_reg *reg, struct regcache *cache)
masked in REG->n set, then read REG->ry. Otherwise, read
REG->rx. */
static enum register_status
-m32c_banked_read (struct m32c_reg *reg, struct regcache *cache, void *buf)
+m32c_banked_read (struct m32c_reg *reg, struct regcache *cache, gdb_byte *buf)
{
struct m32c_reg *bank_reg = m32c_banked_register (reg, cache);
return regcache_raw_read (cache, bank_reg->num, buf);
@@ -360,10 +372,11 @@ m32c_banked_read (struct m32c_reg *reg, struct regcache *cache, void *buf)
masked in REG->n set, then write REG->ry. Otherwise, write
REG->rx. */
static enum register_status
-m32c_banked_write (struct m32c_reg *reg, struct regcache *cache, void *buf)
+m32c_banked_write (struct m32c_reg *reg, struct regcache *cache,
+ const gdb_byte *buf)
{
struct m32c_reg *bank_reg = m32c_banked_register (reg, cache);
- regcache_raw_write (cache, bank_reg->num, (const void *) buf);
+ regcache_raw_write (cache, bank_reg->num, buf);
return REG_VALID;
}
@@ -372,7 +385,7 @@ m32c_banked_write (struct m32c_reg *reg, struct regcache *cache, void *buf)
/* Move the value of SB from CACHE to BUF. On bfd_mach_m32c, SB is a
banked register; on bfd_mach_m16c, it's not. */
static enum register_status
-m32c_sb_read (struct m32c_reg *reg, struct regcache *cache, void *buf)
+m32c_sb_read (struct m32c_reg *reg, struct regcache *cache, gdb_byte *buf)
{
if (gdbarch_bfd_arch_info (reg->arch)->mach == bfd_mach_m16c)
return m32c_raw_read (reg->rx, cache, buf);
@@ -384,7 +397,7 @@ m32c_sb_read (struct m32c_reg *reg, struct regcache *cache, void *buf)
/* Move the value of SB from BUF to CACHE. On bfd_mach_m32c, SB is a
banked register; on bfd_mach_m16c, it's not. */
static enum register_status
-m32c_sb_write (struct m32c_reg *reg, struct regcache *cache, void *buf)
+m32c_sb_write (struct m32c_reg *reg, struct regcache *cache, const gdb_byte *buf)
{
if (gdbarch_bfd_arch_info (reg->arch)->mach == bfd_mach_m16c)
m32c_raw_write (reg->rx, cache, buf);
@@ -437,7 +450,7 @@ m32c_find_part (struct m32c_reg *reg, int *offset_p, int *len_p)
REG->type values, where higher indices refer to more significant
bits, read the value of the REG->n'th element. */
static enum register_status
-m32c_part_read (struct m32c_reg *reg, struct regcache *cache, void *buf)
+m32c_part_read (struct m32c_reg *reg, struct regcache *cache, gdb_byte *buf)
{
int offset, len;
@@ -452,7 +465,8 @@ m32c_part_read (struct m32c_reg *reg, struct regcache *cache, void *buf)
values, where higher indices refer to more significant bits, write
the value of the REG->n'th element. */
static enum register_status
-m32c_part_write (struct m32c_reg *reg, struct regcache *cache, void *buf)
+m32c_part_write (struct m32c_reg *reg, struct regcache *cache,
+ const gdb_byte *buf)
{
int offset, len;
@@ -467,27 +481,25 @@ m32c_part_write (struct m32c_reg *reg, struct regcache *cache, void *buf)
concatenation of the values of the registers REG->rx and REG->ry,
with REG->rx contributing the more significant bits. */
static enum register_status
-m32c_cat_read (struct m32c_reg *reg, struct regcache *cache, void *buf)
+m32c_cat_read (struct m32c_reg *reg, struct regcache *cache, gdb_byte *buf)
{
int high_bytes = TYPE_LENGTH (reg->rx->type);
int low_bytes = TYPE_LENGTH (reg->ry->type);
- /* For address arithmetic. */
- unsigned char *cbuf = buf;
enum register_status status;
gdb_assert (TYPE_LENGTH (reg->type) == high_bytes + low_bytes);
if (gdbarch_byte_order (reg->arch) == BFD_ENDIAN_BIG)
{
- status = regcache_cooked_read (cache, reg->rx->num, cbuf);
+ status = regcache_cooked_read (cache, reg->rx->num, buf);
if (status == REG_VALID)
- status = regcache_cooked_read (cache, reg->ry->num, cbuf + high_bytes);
+ status = regcache_cooked_read (cache, reg->ry->num, buf + high_bytes);
}
else
{
- status = regcache_cooked_read (cache, reg->rx->num, cbuf + low_bytes);
+ status = regcache_cooked_read (cache, reg->rx->num, buf + low_bytes);
if (status == REG_VALID)
- status = regcache_cooked_read (cache, reg->ry->num, cbuf);
+ status = regcache_cooked_read (cache, reg->ry->num, buf);
}
return status;
@@ -498,24 +510,23 @@ m32c_cat_read (struct m32c_reg *reg, struct regcache *cache, void *buf)
concatenation of the values of the registers REG->rx and REG->ry,
with REG->rx contributing the more significant bits. */
static enum register_status
-m32c_cat_write (struct m32c_reg *reg, struct regcache *cache, void *buf)
+m32c_cat_write (struct m32c_reg *reg, struct regcache *cache,
+ const gdb_byte *buf)
{
int high_bytes = TYPE_LENGTH (reg->rx->type);
int low_bytes = TYPE_LENGTH (reg->ry->type);
- /* For address arithmetic. */
- unsigned char *cbuf = buf;
gdb_assert (TYPE_LENGTH (reg->type) == high_bytes + low_bytes);
if (gdbarch_byte_order (reg->arch) == BFD_ENDIAN_BIG)
{
- regcache_cooked_write (cache, reg->rx->num, cbuf);
- regcache_cooked_write (cache, reg->ry->num, cbuf + high_bytes);
+ regcache_cooked_write (cache, reg->rx->num, buf);
+ regcache_cooked_write (cache, reg->ry->num, buf + high_bytes);
}
else
{
- regcache_cooked_write (cache, reg->rx->num, cbuf + low_bytes);
- regcache_cooked_write (cache, reg->ry->num, cbuf);
+ regcache_cooked_write (cache, reg->rx->num, buf + low_bytes);
+ regcache_cooked_write (cache, reg->ry->num, buf);
}
return REG_VALID;
@@ -526,34 +537,31 @@ m32c_cat_write (struct m32c_reg *reg, struct regcache *cache, void *buf)
the concatenation (from most significant to least) of r3, r2, r1,
and r0. */
static enum register_status
-m32c_r3r2r1r0_read (struct m32c_reg *reg, struct regcache *cache, void *buf)
+m32c_r3r2r1r0_read (struct m32c_reg *reg, struct regcache *cache, gdb_byte *buf)
{
struct gdbarch_tdep *tdep = gdbarch_tdep (reg->arch);
int len = TYPE_LENGTH (tdep->r0->type);
enum register_status status;
- /* For address arithmetic. */
- unsigned char *cbuf = buf;
-
if (gdbarch_byte_order (reg->arch) == BFD_ENDIAN_BIG)
{
- status = regcache_cooked_read (cache, tdep->r0->num, cbuf + len * 3);
+ status = regcache_cooked_read (cache, tdep->r0->num, buf + len * 3);
if (status == REG_VALID)
- status = regcache_cooked_read (cache, tdep->r1->num, cbuf + len * 2);
+ status = regcache_cooked_read (cache, tdep->r1->num, buf + len * 2);
if (status == REG_VALID)
- status = regcache_cooked_read (cache, tdep->r2->num, cbuf + len * 1);
+ status = regcache_cooked_read (cache, tdep->r2->num, buf + len * 1);
if (status == REG_VALID)
- status = regcache_cooked_read (cache, tdep->r3->num, cbuf);
+ status = regcache_cooked_read (cache, tdep->r3->num, buf);
}
else
{
- status = regcache_cooked_read (cache, tdep->r0->num, cbuf);
+ status = regcache_cooked_read (cache, tdep->r0->num, buf);
if (status == REG_VALID)
- status = regcache_cooked_read (cache, tdep->r1->num, cbuf + len * 1);
+ status = regcache_cooked_read (cache, tdep->r1->num, buf + len * 1);
if (status == REG_VALID)
- status = regcache_cooked_read (cache, tdep->r2->num, cbuf + len * 2);
+ status = regcache_cooked_read (cache, tdep->r2->num, buf + len * 2);
if (status == REG_VALID)
- status = regcache_cooked_read (cache, tdep->r3->num, cbuf + len * 3);
+ status = regcache_cooked_read (cache, tdep->r3->num, buf + len * 3);
}
return status;
@@ -564,27 +572,25 @@ m32c_r3r2r1r0_read (struct m32c_reg *reg, struct regcache *cache, void *buf)
the concatenation (from most significant to least) of r3, r2, r1,
and r0. */
static enum register_status
-m32c_r3r2r1r0_write (struct m32c_reg *reg, struct regcache *cache, void *buf)
+m32c_r3r2r1r0_write (struct m32c_reg *reg, struct regcache *cache,
+ const gdb_byte *buf)
{
struct gdbarch_tdep *tdep = gdbarch_tdep (reg->arch);
int len = TYPE_LENGTH (tdep->r0->type);
- /* For address arithmetic. */
- unsigned char *cbuf = buf;
-
if (gdbarch_byte_order (reg->arch) == BFD_ENDIAN_BIG)
{
- regcache_cooked_write (cache, tdep->r0->num, cbuf + len * 3);
- regcache_cooked_write (cache, tdep->r1->num, cbuf + len * 2);
- regcache_cooked_write (cache, tdep->r2->num, cbuf + len * 1);
- regcache_cooked_write (cache, tdep->r3->num, cbuf);
+ regcache_cooked_write (cache, tdep->r0->num, buf + len * 3);
+ regcache_cooked_write (cache, tdep->r1->num, buf + len * 2);
+ regcache_cooked_write (cache, tdep->r2->num, buf + len * 1);
+ regcache_cooked_write (cache, tdep->r3->num, buf);
}
else
{
- regcache_cooked_write (cache, tdep->r0->num, cbuf);
- regcache_cooked_write (cache, tdep->r1->num, cbuf + len * 1);
- regcache_cooked_write (cache, tdep->r2->num, cbuf + len * 2);
- regcache_cooked_write (cache, tdep->r3->num, cbuf + len * 3);
+ regcache_cooked_write (cache, tdep->r0->num, buf);
+ regcache_cooked_write (cache, tdep->r1->num, buf + len * 1);
+ regcache_cooked_write (cache, tdep->r2->num, buf + len * 2);
+ regcache_cooked_write (cache, tdep->r3->num, buf + len * 3);
}
return REG_VALID;
@@ -623,7 +629,7 @@ m32c_pseudo_register_write (struct gdbarch *arch,
gdb_assert (arch == tdep->regs[cookednum].arch);
reg = &tdep->regs[cookednum];
- reg->write (reg, cache, (void *) buf);
+ reg->write (reg, cache, buf);
}
@@ -634,8 +640,8 @@ add_reg (struct gdbarch *arch,
const char *name,
struct type *type,
int sim_num,
- m32c_move_reg_t *read,
- m32c_move_reg_t *write,
+ m32c_read_reg_t *read,
+ m32c_write_reg_t *write,
struct m32c_reg *rx,
struct m32c_reg *ry,
int n)
--
2.6.1
^ permalink raw reply [flat|nested] 22+ messages in thread
* [PATCH c++ 5/5] mips: Add cast for int to enum conversion
2015-10-11 4:37 [PATCH c++ 1/5] lm32: Add (const gdb_byte *) cast Simon Marchi
` (2 preceding siblings ...)
2015-10-11 4:37 ` [PATCH c++ 4/5] mips: fix void*/gdb_byte* compilation errors Simon Marchi
@ 2015-10-11 4:44 ` Simon Marchi
2015-10-12 10:54 ` Pedro Alves
2015-10-12 10:52 ` [PATCH c++ 1/5] lm32: Add (const gdb_byte *) cast Yao Qi
` (2 subsequent siblings)
6 siblings, 1 reply; 22+ messages in thread
From: Simon Marchi @ 2015-10-11 4:44 UTC (permalink / raw)
To: gdb-patches; +Cc: Simon Marchi
This patch is taken directly from Pedro's branch.
/home/pedro/gdb/mygit/src/gdb/mips-tdep.c: In function âULONGEST mips_fetch_instruction(gdbarch*, mips_isa, CORE_ADDR, int*)â:
/home/pedro/gdb/mygit/src/gdb/mips-tdep.c:1460:28: error: invalid conversion from âintâ to âtarget_xfer_statusâ [-fpermissive]
memory_error (status, addr);
gdb/ChangeLog:
* mips-tdep.c (mips_fetch_instruction): Add cast.
---
gdb/mips-tdep.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/gdb/mips-tdep.c b/gdb/mips-tdep.c
index 2275138..73b9221 100644
--- a/gdb/mips-tdep.c
+++ b/gdb/mips-tdep.c
@@ -1456,7 +1456,7 @@ mips_fetch_instruction (struct gdbarch *gdbarch,
if (status)
{
if (statusp == NULL)
- memory_error (status, addr);
+ memory_error ((enum target_xfer_status) status, addr);
return 0;
}
return extract_unsigned_integer (buf, instlen, byte_order);
--
2.6.1
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [PATCH c++ 3/5] mep: Add cast for int to enum conversion
2015-10-11 4:37 ` [PATCH c++ 3/5] mep: Add cast for int to enum conversion Simon Marchi
@ 2015-10-12 10:35 ` Yao Qi
2015-10-12 16:43 ` Simon Marchi
0 siblings, 1 reply; 22+ messages in thread
From: Yao Qi @ 2015-10-12 10:35 UTC (permalink / raw)
To: Simon Marchi; +Cc: gdb-patches
Simon Marchi <simon.marchi@polymtl.ca> writes:
Hi Simon,
Patch is OK, one nit below,
> @@ -2396,7 +2396,10 @@ mep_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
> /* The way to get the me_module code depends on the object file
> format. At the moment, we only know how to handle ELF. */
> if (bfd_get_flavour (info.abfd) == bfd_target_elf_flavour)
> - me_module = elf_elfheader (info.abfd)->e_flags & EF_MEP_INDEX_MASK;
> + {
> + int flag = elf_elfheader (info.abfd)->e_flags & EF_MEP_INDEX_MASK;
A blank line is needed here.
> + me_module = (CONFIG_ATTR) flag;
> + }
> else
> me_module = CONFIG_NONE;
> }
--
Yao (齐尧)
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [PATCH c++ 2/5] m32c: Split m32c_move_reg_t in read/write variants
2015-10-11 4:37 ` [PATCH c++ 2/5] m32c: Split m32c_move_reg_t in read/write variants Simon Marchi
@ 2015-10-12 10:47 ` Yao Qi
2015-10-12 16:42 ` Simon Marchi
0 siblings, 1 reply; 22+ messages in thread
From: Yao Qi @ 2015-10-12 10:47 UTC (permalink / raw)
To: Simon Marchi; +Cc: gdb-patches
Simon Marchi <simon.marchi@polymtl.ca> writes:
> /* Register move functions. We declare them here using
> - m32c_move_reg_t to check the types. */
> -static m32c_move_reg_t m32c_raw_read, m32c_raw_write;
> -static m32c_move_reg_t m32c_banked_read, m32c_banked_write;
> -static m32c_move_reg_t m32c_sb_read, m32c_sb_write;
> -static m32c_move_reg_t m32c_part_read, m32c_part_write;
> -static m32c_move_reg_t m32c_cat_read, m32c_cat_write;
> -static m32c_move_reg_t m32c_r3r2r1r0_read, m32c_r3r2r1r0_write;
> -
> + m32c_{read,write}_reg_t to check the types. */
> +static m32c_read_reg_t m32c_raw_read,
> + m32c_banked_read,
> + m32c_sb_read,
> + m32c_part_read,
> + m32c_cat_read,
> + m32c_r3r2r1r0_read;
> +
> +static m32c_write_reg_t m32c_raw_write,
> + m32c_banked_write,
> + m32c_sb_write,
> + m32c_part_write,
> + m32c_cat_write,
> + m32c_r3r2r1r0_write;
I don't think this complies to GNU Coding Standard, which says
"Don’t declare multiple variables in one declaration that spans
lines. Start a new declaration on each line, instead."
Otherwise, patch is OK.
--
Yao (齐尧)
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [PATCH c++ 1/5] lm32: Add (const gdb_byte *) cast
2015-10-11 4:37 [PATCH c++ 1/5] lm32: Add (const gdb_byte *) cast Simon Marchi
` (3 preceding siblings ...)
2015-10-11 4:44 ` [PATCH c++ 5/5] mips: Add cast for int to enum conversion Simon Marchi
@ 2015-10-12 10:52 ` Yao Qi
2015-10-12 11:10 ` Pedro Alves
2015-10-22 9:59 ` Simon Marchi
6 siblings, 0 replies; 22+ messages in thread
From: Yao Qi @ 2015-10-12 10:52 UTC (permalink / raw)
To: Simon Marchi; +Cc: gdb-patches
Simon Marchi <simon.marchi@polymtl.ca> writes:
> There might be a cleaner sequence of function calls to do what is done
> here (I don't know), but since I don't want to risk breaking anything,
> it's safer to just add the required cast.
>
> gdb/ChangeLog:
>
> * lm32-tdep.c (lm32_push_dummy_call): Add cast.
Patch is OK.
--
Yao (齐尧)
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [PATCH c++ 5/5] mips: Add cast for int to enum conversion
2015-10-11 4:44 ` [PATCH c++ 5/5] mips: Add cast for int to enum conversion Simon Marchi
@ 2015-10-12 10:54 ` Pedro Alves
2015-10-12 16:28 ` Simon Marchi
0 siblings, 1 reply; 22+ messages in thread
From: Pedro Alves @ 2015-10-12 10:54 UTC (permalink / raw)
To: Simon Marchi, gdb-patches
On 10/11/2015 05:37 AM, Simon Marchi wrote:
> This patch is taken directly from Pedro's branch.
>
> /home/pedro/gdb/mygit/src/gdb/mips-tdep.c: In function âULONGEST mips_fetch_instruction(gdbarch*, mips_isa, CORE_ADDR, int*)â:
> /home/pedro/gdb/mygit/src/gdb/mips-tdep.c:1460:28: error: invalid conversion from âintâ to âtarget_xfer_statusâ [-fpermissive]
> memory_error (status, addr);
>
> gdb/ChangeLog:
>
> * mips-tdep.c (mips_fetch_instruction): Add cast.
> ---
> gdb/mips-tdep.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/gdb/mips-tdep.c b/gdb/mips-tdep.c
> index 2275138..73b9221 100644
> --- a/gdb/mips-tdep.c
> +++ b/gdb/mips-tdep.c
> @@ -1456,7 +1456,7 @@ mips_fetch_instruction (struct gdbarch *gdbarch,
> if (status)
> {
> if (statusp == NULL)
> - memory_error (status, addr);
> + memory_error ((enum target_xfer_status) status, addr);
> return 0;
> }
Please don't. As discussed a while ago in IRC, I think we should
stop making target_read_memory & friends return a target_xfer_status.
I have a different patch in the branch to do that:
https://github.com/palves/gdb/commit/22e5f84529cbe06a7b5c7fbbf662640b84e5cfb9
Thanks,
Pedro Alves
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [PATCH c++ 1/5] lm32: Add (const gdb_byte *) cast
2015-10-11 4:37 [PATCH c++ 1/5] lm32: Add (const gdb_byte *) cast Simon Marchi
` (4 preceding siblings ...)
2015-10-12 10:52 ` [PATCH c++ 1/5] lm32: Add (const gdb_byte *) cast Yao Qi
@ 2015-10-12 11:10 ` Pedro Alves
2015-10-12 12:18 ` Jon Beniston
2015-10-13 17:14 ` Simon Marchi
2015-10-22 9:59 ` Simon Marchi
6 siblings, 2 replies; 22+ messages in thread
From: Pedro Alves @ 2015-10-12 11:10 UTC (permalink / raw)
To: Simon Marchi, gdb-patches; +Cc: Jon Beniston
On 10/11/2015 05:37 AM, Simon Marchi wrote:
> There might be a cleaner sequence of function calls to do what is done
> here (I don't know), but since I don't want to risk breaking anything,
> it's safer to just add the required cast.
>
> gdb/ChangeLog:
>
> * lm32-tdep.c (lm32_push_dummy_call): Add cast.
> ---
> gdb/lm32-tdep.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/gdb/lm32-tdep.c b/gdb/lm32-tdep.c
> index 25a7e1e..a0defad 100644
> --- a/gdb/lm32-tdep.c
> +++ b/gdb/lm32-tdep.c
> @@ -289,7 +289,7 @@ lm32_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
> regcache_cooked_write_unsigned (regcache, first_arg_reg + i, val);
> else
> {
> - write_memory (sp, (void *) &val, TYPE_LENGTH (arg_type));
> + write_memory (sp, (const gdb_byte *) &val, TYPE_LENGTH (arg_type));
This reveals that the code has a host-dependency. It is assuming the
byte order of the target is the same as host's.
Please replace this with a call to write_memory_unsigned_integer.
Looks like this port hasn't been touched ever since it was
originally contributed. Jon, is there still interest in this port?
Thanks,
Pedro Alves
^ permalink raw reply [flat|nested] 22+ messages in thread
* RE: [PATCH c++ 1/5] lm32: Add (const gdb_byte *) cast
2015-10-12 11:10 ` Pedro Alves
@ 2015-10-12 12:18 ` Jon Beniston
2015-10-13 17:14 ` Simon Marchi
1 sibling, 0 replies; 22+ messages in thread
From: Jon Beniston @ 2015-10-12 12:18 UTC (permalink / raw)
To: 'Pedro Alves', 'Simon Marchi', gdb-patches
Hi Pedro,
Yes, I believe people are still using this port. (Probably no one on a host
with different byte ordering though!)
Regards,
Jon
-----Original Message-----
From: Pedro Alves [mailto:palves@redhat.com]
Sent: 12 October 2015 12:11
To: Simon Marchi; gdb-patches@sourceware.org
Cc: Jon Beniston
Subject: Re: [PATCH c++ 1/5] lm32: Add (const gdb_byte *) cast
On 10/11/2015 05:37 AM, Simon Marchi wrote:
> There might be a cleaner sequence of function calls to do what is done
> here (I don't know), but since I don't want to risk breaking anything,
> it's safer to just add the required cast.
>
> gdb/ChangeLog:
>
> * lm32-tdep.c (lm32_push_dummy_call): Add cast.
> ---
> gdb/lm32-tdep.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/gdb/lm32-tdep.c b/gdb/lm32-tdep.c index 25a7e1e..a0defad
> 100644
> --- a/gdb/lm32-tdep.c
> +++ b/gdb/lm32-tdep.c
> @@ -289,7 +289,7 @@ lm32_push_dummy_call (struct gdbarch *gdbarch, struct
value *function,
> regcache_cooked_write_unsigned (regcache, first_arg_reg + i, val);
> else
> {
> - write_memory (sp, (void *) &val, TYPE_LENGTH (arg_type));
> + write_memory (sp, (const gdb_byte *) &val, TYPE_LENGTH
> +(arg_type));
This reveals that the code has a host-dependency. It is assuming the byte
order of the target is the same as host's.
Please replace this with a call to write_memory_unsigned_integer.
Looks like this port hasn't been touched ever since it was originally
contributed. Jon, is there still interest in this port?
Thanks,
Pedro Alves
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [PATCH c++ 5/5] mips: Add cast for int to enum conversion
2015-10-12 10:54 ` Pedro Alves
@ 2015-10-12 16:28 ` Simon Marchi
0 siblings, 0 replies; 22+ messages in thread
From: Simon Marchi @ 2015-10-12 16:28 UTC (permalink / raw)
To: Pedro Alves, Simon Marchi, gdb-patches
On 12/10/15 06:54 AM, Pedro Alves wrote:
> Please don't. As discussed a while ago in IRC, I think we should
> stop making target_read_memory & friends return a target_xfer_status.
>
> I have a different patch in the branch to do that:
>
> https://github.com/palves/gdb/commit/22e5f84529cbe06a7b5c7fbbf662640b84e5cfb9
Ok. I remember that discussion, I didn't know that you followed up on
it. Great!
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [PATCH c++ 2/5] m32c: Split m32c_move_reg_t in read/write variants
2015-10-12 10:47 ` Yao Qi
@ 2015-10-12 16:42 ` Simon Marchi
0 siblings, 0 replies; 22+ messages in thread
From: Simon Marchi @ 2015-10-12 16:42 UTC (permalink / raw)
To: Yao Qi, Simon Marchi; +Cc: gdb-patches
On 12/10/15 06:47 AM, Yao Qi wrote:
> Simon Marchi <simon.marchi@polymtl.ca> writes:
>
>> /* Register move functions. We declare them here using
>> - m32c_move_reg_t to check the types. */
>> -static m32c_move_reg_t m32c_raw_read, m32c_raw_write;
>> -static m32c_move_reg_t m32c_banked_read, m32c_banked_write;
>> -static m32c_move_reg_t m32c_sb_read, m32c_sb_write;
>> -static m32c_move_reg_t m32c_part_read, m32c_part_write;
>> -static m32c_move_reg_t m32c_cat_read, m32c_cat_write;
>> -static m32c_move_reg_t m32c_r3r2r1r0_read, m32c_r3r2r1r0_write;
>> -
>> + m32c_{read,write}_reg_t to check the types. */
>> +static m32c_read_reg_t m32c_raw_read,
>> + m32c_banked_read,
>> + m32c_sb_read,
>> + m32c_part_read,
>> + m32c_cat_read,
>> + m32c_r3r2r1r0_read;
>> +
>> +static m32c_write_reg_t m32c_raw_write,
>> + m32c_banked_write,
>> + m32c_sb_write,
>> + m32c_part_write,
>> + m32c_cat_write,
>> + m32c_r3r2r1r0_write;
>
> I don't think this complies to GNU Coding Standard, which says
> "Donât declare multiple variables in one declaration that spans
> lines. Start a new declaration on each line, instead."
>
> Otherwise, patch is OK.
>
Thanks, pushed with that change:
From 6da660c76dd7c2998d847d2c978a293f13105eea Mon Sep 17 00:00:00 2001
From: Simon Marchi <simon.marchi@polymtl.ca>
Date: Mon, 12 Oct 2015 12:39:40 -0400
Subject: [PATCH] m32c: Split m32c_move_reg_t in read/write variants
This allows to avoid casting away the const qualification in
m32c_pseudo_register_write (which is the entry points for all other
register read/write functions).
Also, use gdb_byte* instead of void* to avoid casts when calling gdb
common memory functions. It also allows to remove those "For adderss
arithmetic" local variables.
gdb/ChangeLog:
* m32c-tdep.c (m32c_move_reg_t): Replace with...
(m32c_write_reg_t): ...this and...
(m32c_read_reg_t): ...this.
(struct m32c_reg): Update types of read and write.
(m32c_raw_read): Change declaration type to m32c_read_reg_t and
adjust definition.
(m32c_banked_read): Likewise.
(m32c_sb_read): Likewise.
(m32c_part_read): Likewise.
(m32c_cat_read): Likewise.
(m32c_r3r2r1r0_read): Likewise.
(m32c_raw_write): Change declaration type to m32c_write_reg_t
and adjust definition.
(m32c_banked_write): Likewise.
(m32c_sb_write): Likewise.
(m32c_part_write): Likewise.
(m32c_cat_write): Likewise.
(m32c_r3r2r1r0_write): Likewise.
---
gdb/ChangeLog | 21 +++++++++
gdb/m32c-tdep.c | 130 +++++++++++++++++++++++++++++---------------------------
2 files changed, 89 insertions(+), 62 deletions(-)
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 6825b7e..acfddef 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,26 @@
2015-10-12 Simon Marchi <simon.marchi@polymtl.ca>
+ * m32c-tdep.c (m32c_move_reg_t): Replace with...
+ (m32c_write_reg_t): ...this and...
+ (m32c_read_reg_t): ...this.
+ (struct m32c_reg): Update types of read and write.
+ (m32c_raw_read): Change declaration type to m32c_read_reg_t and
+ adjust definition.
+ (m32c_banked_read): Likewise.
+ (m32c_sb_read): Likewise.
+ (m32c_part_read): Likewise.
+ (m32c_cat_read): Likewise.
+ (m32c_r3r2r1r0_read): Likewise.
+ (m32c_raw_write): Change declaration type to m32c_write_reg_t
+ and adjust definition.
+ (m32c_banked_write): Likewise.
+ (m32c_sb_write): Likewise.
+ (m32c_part_write): Likewise.
+ (m32c_cat_write): Likewise.
+ (m32c_r3r2r1r0_write): Likewise.
+
+2015-10-12 Simon Marchi <simon.marchi@polymtl.ca>
+
* aarch64-linux-tdep.c (aarch64_linux_syscall_record): Add cast.
2015-10-12 Simon Marchi <simon.marchi@polymtl.ca>
diff --git a/gdb/m32c-tdep.c b/gdb/m32c-tdep.c
index f2d060a..e31397c 100644
--- a/gdb/m32c-tdep.c
+++ b/gdb/m32c-tdep.c
@@ -46,9 +46,13 @@ struct m32c_reg;
/* The type of a function that moves the value of REG between CACHE or
BUF --- in either direction. */
-typedef enum register_status (m32c_move_reg_t) (struct m32c_reg *reg,
+typedef enum register_status (m32c_write_reg_t) (struct m32c_reg *reg,
+ struct regcache *cache,
+ const gdb_byte *buf);
+
+typedef enum register_status (m32c_read_reg_t) (struct m32c_reg *reg,
struct regcache *cache,
- void *buf);
+ gdb_byte *buf);
struct m32c_reg
{
@@ -78,7 +82,8 @@ struct m32c_reg
/* Functions to read its value from a regcache, and write its value
to a regcache. */
- m32c_move_reg_t *read, *write;
+ m32c_read_reg_t *read;
+ m32c_write_reg_t *write;
/* Data for READ and WRITE functions. The exact meaning depends on
the specific functions selected; see the comments for those
@@ -297,18 +302,24 @@ m32c_register_reggroup_p (struct gdbarch *gdbarch, int regnum,
/* Register move functions. We declare them here using
- m32c_move_reg_t to check the types. */
-static m32c_move_reg_t m32c_raw_read, m32c_raw_write;
-static m32c_move_reg_t m32c_banked_read, m32c_banked_write;
-static m32c_move_reg_t m32c_sb_read, m32c_sb_write;
-static m32c_move_reg_t m32c_part_read, m32c_part_write;
-static m32c_move_reg_t m32c_cat_read, m32c_cat_write;
-static m32c_move_reg_t m32c_r3r2r1r0_read, m32c_r3r2r1r0_write;
-
+ m32c_{read,write}_reg_t to check the types. */
+static m32c_read_reg_t m32c_raw_read;
+static m32c_read_reg_t m32c_banked_read;
+static m32c_read_reg_t m32c_sb_read;
+static m32c_read_reg_t m32c_part_read;
+static m32c_read_reg_t m32c_cat_read;
+static m32c_read_reg_t m32c_r3r2r1r0_read;
+
+static m32c_write_reg_t m32c_raw_write;
+static m32c_write_reg_t m32c_banked_write;
+static m32c_write_reg_t m32c_sb_write;
+static m32c_write_reg_t m32c_part_write;
+static m32c_write_reg_t m32c_cat_write;
+static m32c_write_reg_t m32c_r3r2r1r0_write;
/* Copy the value of the raw register REG from CACHE to BUF. */
static enum register_status
-m32c_raw_read (struct m32c_reg *reg, struct regcache *cache, void *buf)
+m32c_raw_read (struct m32c_reg *reg, struct regcache *cache, gdb_byte *buf)
{
return regcache_raw_read (cache, reg->num, buf);
}
@@ -316,9 +327,10 @@ m32c_raw_read (struct m32c_reg *reg, struct regcache *cache, void *buf)
/* Copy the value of the raw register REG from BUF to CACHE. */
static enum register_status
-m32c_raw_write (struct m32c_reg *reg, struct regcache *cache, void *buf)
+m32c_raw_write (struct m32c_reg *reg, struct regcache *cache,
+ const gdb_byte *buf)
{
- regcache_raw_write (cache, reg->num, (const void *) buf);
+ regcache_raw_write (cache, reg->num, buf);
return REG_VALID;
}
@@ -348,7 +360,7 @@ m32c_banked_register (struct m32c_reg *reg, struct regcache *cache)
masked in REG->n set, then read REG->ry. Otherwise, read
REG->rx. */
static enum register_status
-m32c_banked_read (struct m32c_reg *reg, struct regcache *cache, void *buf)
+m32c_banked_read (struct m32c_reg *reg, struct regcache *cache, gdb_byte *buf)
{
struct m32c_reg *bank_reg = m32c_banked_register (reg, cache);
return regcache_raw_read (cache, bank_reg->num, buf);
@@ -360,10 +372,11 @@ m32c_banked_read (struct m32c_reg *reg, struct regcache *cache, void *buf)
masked in REG->n set, then write REG->ry. Otherwise, write
REG->rx. */
static enum register_status
-m32c_banked_write (struct m32c_reg *reg, struct regcache *cache, void *buf)
+m32c_banked_write (struct m32c_reg *reg, struct regcache *cache,
+ const gdb_byte *buf)
{
struct m32c_reg *bank_reg = m32c_banked_register (reg, cache);
- regcache_raw_write (cache, bank_reg->num, (const void *) buf);
+ regcache_raw_write (cache, bank_reg->num, buf);
return REG_VALID;
}
@@ -372,7 +385,7 @@ m32c_banked_write (struct m32c_reg *reg, struct regcache *cache, void *buf)
/* Move the value of SB from CACHE to BUF. On bfd_mach_m32c, SB is a
banked register; on bfd_mach_m16c, it's not. */
static enum register_status
-m32c_sb_read (struct m32c_reg *reg, struct regcache *cache, void *buf)
+m32c_sb_read (struct m32c_reg *reg, struct regcache *cache, gdb_byte *buf)
{
if (gdbarch_bfd_arch_info (reg->arch)->mach == bfd_mach_m16c)
return m32c_raw_read (reg->rx, cache, buf);
@@ -384,7 +397,7 @@ m32c_sb_read (struct m32c_reg *reg, struct regcache *cache, void *buf)
/* Move the value of SB from BUF to CACHE. On bfd_mach_m32c, SB is a
banked register; on bfd_mach_m16c, it's not. */
static enum register_status
-m32c_sb_write (struct m32c_reg *reg, struct regcache *cache, void *buf)
+m32c_sb_write (struct m32c_reg *reg, struct regcache *cache, const gdb_byte *buf)
{
if (gdbarch_bfd_arch_info (reg->arch)->mach == bfd_mach_m16c)
m32c_raw_write (reg->rx, cache, buf);
@@ -437,7 +450,7 @@ m32c_find_part (struct m32c_reg *reg, int *offset_p, int *len_p)
REG->type values, where higher indices refer to more significant
bits, read the value of the REG->n'th element. */
static enum register_status
-m32c_part_read (struct m32c_reg *reg, struct regcache *cache, void *buf)
+m32c_part_read (struct m32c_reg *reg, struct regcache *cache, gdb_byte *buf)
{
int offset, len;
@@ -452,7 +465,8 @@ m32c_part_read (struct m32c_reg *reg, struct regcache *cache, void *buf)
values, where higher indices refer to more significant bits, write
the value of the REG->n'th element. */
static enum register_status
-m32c_part_write (struct m32c_reg *reg, struct regcache *cache, void *buf)
+m32c_part_write (struct m32c_reg *reg, struct regcache *cache,
+ const gdb_byte *buf)
{
int offset, len;
@@ -467,27 +481,25 @@ m32c_part_write (struct m32c_reg *reg, struct regcache *cache, void *buf)
concatenation of the values of the registers REG->rx and REG->ry,
with REG->rx contributing the more significant bits. */
static enum register_status
-m32c_cat_read (struct m32c_reg *reg, struct regcache *cache, void *buf)
+m32c_cat_read (struct m32c_reg *reg, struct regcache *cache, gdb_byte *buf)
{
int high_bytes = TYPE_LENGTH (reg->rx->type);
int low_bytes = TYPE_LENGTH (reg->ry->type);
- /* For address arithmetic. */
- unsigned char *cbuf = buf;
enum register_status status;
gdb_assert (TYPE_LENGTH (reg->type) == high_bytes + low_bytes);
if (gdbarch_byte_order (reg->arch) == BFD_ENDIAN_BIG)
{
- status = regcache_cooked_read (cache, reg->rx->num, cbuf);
+ status = regcache_cooked_read (cache, reg->rx->num, buf);
if (status == REG_VALID)
- status = regcache_cooked_read (cache, reg->ry->num, cbuf + high_bytes);
+ status = regcache_cooked_read (cache, reg->ry->num, buf + high_bytes);
}
else
{
- status = regcache_cooked_read (cache, reg->rx->num, cbuf + low_bytes);
+ status = regcache_cooked_read (cache, reg->rx->num, buf + low_bytes);
if (status == REG_VALID)
- status = regcache_cooked_read (cache, reg->ry->num, cbuf);
+ status = regcache_cooked_read (cache, reg->ry->num, buf);
}
return status;
@@ -498,24 +510,23 @@ m32c_cat_read (struct m32c_reg *reg, struct regcache *cache, void *buf)
concatenation of the values of the registers REG->rx and REG->ry,
with REG->rx contributing the more significant bits. */
static enum register_status
-m32c_cat_write (struct m32c_reg *reg, struct regcache *cache, void *buf)
+m32c_cat_write (struct m32c_reg *reg, struct regcache *cache,
+ const gdb_byte *buf)
{
int high_bytes = TYPE_LENGTH (reg->rx->type);
int low_bytes = TYPE_LENGTH (reg->ry->type);
- /* For address arithmetic. */
- unsigned char *cbuf = buf;
gdb_assert (TYPE_LENGTH (reg->type) == high_bytes + low_bytes);
if (gdbarch_byte_order (reg->arch) == BFD_ENDIAN_BIG)
{
- regcache_cooked_write (cache, reg->rx->num, cbuf);
- regcache_cooked_write (cache, reg->ry->num, cbuf + high_bytes);
+ regcache_cooked_write (cache, reg->rx->num, buf);
+ regcache_cooked_write (cache, reg->ry->num, buf + high_bytes);
}
else
{
- regcache_cooked_write (cache, reg->rx->num, cbuf + low_bytes);
- regcache_cooked_write (cache, reg->ry->num, cbuf);
+ regcache_cooked_write (cache, reg->rx->num, buf + low_bytes);
+ regcache_cooked_write (cache, reg->ry->num, buf);
}
return REG_VALID;
@@ -526,34 +537,31 @@ m32c_cat_write (struct m32c_reg *reg, struct regcache *cache, void *buf)
the concatenation (from most significant to least) of r3, r2, r1,
and r0. */
static enum register_status
-m32c_r3r2r1r0_read (struct m32c_reg *reg, struct regcache *cache, void *buf)
+m32c_r3r2r1r0_read (struct m32c_reg *reg, struct regcache *cache, gdb_byte *buf)
{
struct gdbarch_tdep *tdep = gdbarch_tdep (reg->arch);
int len = TYPE_LENGTH (tdep->r0->type);
enum register_status status;
- /* For address arithmetic. */
- unsigned char *cbuf = buf;
-
if (gdbarch_byte_order (reg->arch) == BFD_ENDIAN_BIG)
{
- status = regcache_cooked_read (cache, tdep->r0->num, cbuf + len * 3);
+ status = regcache_cooked_read (cache, tdep->r0->num, buf + len * 3);
if (status == REG_VALID)
- status = regcache_cooked_read (cache, tdep->r1->num, cbuf + len * 2);
+ status = regcache_cooked_read (cache, tdep->r1->num, buf + len * 2);
if (status == REG_VALID)
- status = regcache_cooked_read (cache, tdep->r2->num, cbuf + len * 1);
+ status = regcache_cooked_read (cache, tdep->r2->num, buf + len * 1);
if (status == REG_VALID)
- status = regcache_cooked_read (cache, tdep->r3->num, cbuf);
+ status = regcache_cooked_read (cache, tdep->r3->num, buf);
}
else
{
- status = regcache_cooked_read (cache, tdep->r0->num, cbuf);
+ status = regcache_cooked_read (cache, tdep->r0->num, buf);
if (status == REG_VALID)
- status = regcache_cooked_read (cache, tdep->r1->num, cbuf + len * 1);
+ status = regcache_cooked_read (cache, tdep->r1->num, buf + len * 1);
if (status == REG_VALID)
- status = regcache_cooked_read (cache, tdep->r2->num, cbuf + len * 2);
+ status = regcache_cooked_read (cache, tdep->r2->num, buf + len * 2);
if (status == REG_VALID)
- status = regcache_cooked_read (cache, tdep->r3->num, cbuf + len * 3);
+ status = regcache_cooked_read (cache, tdep->r3->num, buf + len * 3);
}
return status;
@@ -564,27 +572,25 @@ m32c_r3r2r1r0_read (struct m32c_reg *reg, struct regcache *cache, void *buf)
the concatenation (from most significant to least) of r3, r2, r1,
and r0. */
static enum register_status
-m32c_r3r2r1r0_write (struct m32c_reg *reg, struct regcache *cache, void *buf)
+m32c_r3r2r1r0_write (struct m32c_reg *reg, struct regcache *cache,
+ const gdb_byte *buf)
{
struct gdbarch_tdep *tdep = gdbarch_tdep (reg->arch);
int len = TYPE_LENGTH (tdep->r0->type);
- /* For address arithmetic. */
- unsigned char *cbuf = buf;
-
if (gdbarch_byte_order (reg->arch) == BFD_ENDIAN_BIG)
{
- regcache_cooked_write (cache, tdep->r0->num, cbuf + len * 3);
- regcache_cooked_write (cache, tdep->r1->num, cbuf + len * 2);
- regcache_cooked_write (cache, tdep->r2->num, cbuf + len * 1);
- regcache_cooked_write (cache, tdep->r3->num, cbuf);
+ regcache_cooked_write (cache, tdep->r0->num, buf + len * 3);
+ regcache_cooked_write (cache, tdep->r1->num, buf + len * 2);
+ regcache_cooked_write (cache, tdep->r2->num, buf + len * 1);
+ regcache_cooked_write (cache, tdep->r3->num, buf);
}
else
{
- regcache_cooked_write (cache, tdep->r0->num, cbuf);
- regcache_cooked_write (cache, tdep->r1->num, cbuf + len * 1);
- regcache_cooked_write (cache, tdep->r2->num, cbuf + len * 2);
- regcache_cooked_write (cache, tdep->r3->num, cbuf + len * 3);
+ regcache_cooked_write (cache, tdep->r0->num, buf);
+ regcache_cooked_write (cache, tdep->r1->num, buf + len * 1);
+ regcache_cooked_write (cache, tdep->r2->num, buf + len * 2);
+ regcache_cooked_write (cache, tdep->r3->num, buf + len * 3);
}
return REG_VALID;
@@ -623,7 +629,7 @@ m32c_pseudo_register_write (struct gdbarch *arch,
gdb_assert (arch == tdep->regs[cookednum].arch);
reg = &tdep->regs[cookednum];
- reg->write (reg, cache, (void *) buf);
+ reg->write (reg, cache, buf);
}
@@ -634,8 +640,8 @@ add_reg (struct gdbarch *arch,
const char *name,
struct type *type,
int sim_num,
- m32c_move_reg_t *read,
- m32c_move_reg_t *write,
+ m32c_read_reg_t *read,
+ m32c_write_reg_t *write,
struct m32c_reg *rx,
struct m32c_reg *ry,
int n)
--
2.6.1
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [PATCH c++ 3/5] mep: Add cast for int to enum conversion
2015-10-12 10:35 ` Yao Qi
@ 2015-10-12 16:43 ` Simon Marchi
0 siblings, 0 replies; 22+ messages in thread
From: Simon Marchi @ 2015-10-12 16:43 UTC (permalink / raw)
To: Yao Qi, Simon Marchi; +Cc: gdb-patches
On 12/10/15 06:34 AM, Yao Qi wrote:
> Simon Marchi <simon.marchi@polymtl.ca> writes:
>
> Hi Simon,
> Patch is OK, one nit below,
>
>> @@ -2396,7 +2396,10 @@ mep_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
>> /* The way to get the me_module code depends on the object file
>> format. At the moment, we only know how to handle ELF. */
>> if (bfd_get_flavour (info.abfd) == bfd_target_elf_flavour)
>> - me_module = elf_elfheader (info.abfd)->e_flags & EF_MEP_INDEX_MASK;
>> + {
>> + int flag = elf_elfheader (info.abfd)->e_flags & EF_MEP_INDEX_MASK;
>
> A blank line is needed here.
>
>> + me_module = (CONFIG_ATTR) flag;
>> + }
>> else
>> me_module = CONFIG_NONE;
>> }
>
Thanks, pushed with the newline.
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [PATCH c++ 1/5] lm32: Add (const gdb_byte *) cast
2015-10-12 11:10 ` Pedro Alves
2015-10-12 12:18 ` Jon Beniston
@ 2015-10-13 17:14 ` Simon Marchi
2015-10-13 17:32 ` Pedro Alves
1 sibling, 1 reply; 22+ messages in thread
From: Simon Marchi @ 2015-10-13 17:14 UTC (permalink / raw)
To: gdb-patches
On 15-10-12 07:10 AM, Pedro Alves wrote:
> This reveals that the code has a host-dependency. It is assuming the
> byte order of the target is the same as host's.
>
> Please replace this with a call to write_memory_unsigned_integer.
>
> Looks like this port hasn't been touched ever since it was
> originally contributed. Jon, is there still interest in this port?
>
> Thanks,
> Pedro Alves
Ah, thanks for the tip. It would look like this then:
From 5543b8ee060c5d0d171f5a8220a927c35bd3e5d5 Mon Sep 17 00:00:00 2001
From: Simon Marchi <simon.marchi@polymtl.ca>
Date: Sun, 11 Oct 2015 00:37:14 -0400
Subject: [PATCH] lm32: Replace call to write_memory with write_memory_unsigned_integer
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Fixes this error:
/home/emaisin/src/binutils-gdb/gdb/lm32-tdep.c: In function ‘CORE_ADDR lm32_push_dummy_call(gdbarch*, value*, regcache*, CORE_ADDR, int, value**, CORE_ADDR, int, CORE_ADDR)’:
/home/emaisin/src/binutils-gdb/gdb/lm32-tdep.c:292:59: error: invalid conversion from ‘void*’ to ‘const gdb_byte* {aka const unsigned char*}’ [-fpermissive]
write_memory (sp, (void *) &val, TYPE_LENGTH (arg_type));
^
In file included from /home/emaisin/src/binutils-gdb/gdb/lm32-tdep.c:29:0:
/home/emaisin/src/binutils-gdb/gdb/gdbcore.h:107:13: error: initializing argument 2 of ‘void write_memory(CORE_ADDR, const gdb_byte*, ssize_t)’ [-fpermissive]
extern void write_memory (CORE_ADDR memaddr, const gdb_byte *myaddr,
^
gdb/ChangeLog:
* lm32-tdep.c (lm32_push_dummy_call): Replace call to
write_memory with write_memory_unsigned_integer.
---
gdb/lm32-tdep.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/gdb/lm32-tdep.c b/gdb/lm32-tdep.c
index 25a7e1e..2dcc9a3 100644
--- a/gdb/lm32-tdep.c
+++ b/gdb/lm32-tdep.c
@@ -289,7 +289,8 @@ lm32_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
regcache_cooked_write_unsigned (regcache, first_arg_reg + i, val);
else
{
- write_memory (sp, (void *) &val, TYPE_LENGTH (arg_type));
+ write_memory_unsigned_integer (sp, TYPE_LENGTH (arg_type), byte_order,
+ val);
sp -= 4;
}
}
--
2.5.1
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [PATCH c++ 1/5] lm32: Add (const gdb_byte *) cast
2015-10-13 17:14 ` Simon Marchi
@ 2015-10-13 17:32 ` Pedro Alves
2015-10-13 17:37 ` Simon Marchi
0 siblings, 1 reply; 22+ messages in thread
From: Pedro Alves @ 2015-10-13 17:32 UTC (permalink / raw)
To: Simon Marchi, gdb-patches
On 10/13/2015 06:14 PM, Simon Marchi wrote:
> On 15-10-12 07:10 AM, Pedro Alves wrote:
>> This reveals that the code has a host-dependency. It is assuming the
>> byte order of the target is the same as host's.
>>
>> Please replace this with a call to write_memory_unsigned_integer.
>>
>> Looks like this port hasn't been touched ever since it was
>> originally contributed. Jon, is there still interest in this port?
>>
>> Thanks,
>> Pedro Alves
>
> Ah, thanks for the tip. It would look like this then:
Looks good.
Thanks,
Pedro Alves
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [PATCH c++ 1/5] lm32: Add (const gdb_byte *) cast
2015-10-13 17:32 ` Pedro Alves
@ 2015-10-13 17:37 ` Simon Marchi
0 siblings, 0 replies; 22+ messages in thread
From: Simon Marchi @ 2015-10-13 17:37 UTC (permalink / raw)
To: Pedro Alves, gdb-patches
On 15-10-13 01:32 PM, Pedro Alves wrote:
> Looks good.
>
> Thanks,
> Pedro Alves
Pushed, thanks.
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [PATCH c++ 1/5] lm32: Add (const gdb_byte *) cast
2015-10-11 4:37 [PATCH c++ 1/5] lm32: Add (const gdb_byte *) cast Simon Marchi
` (5 preceding siblings ...)
2015-10-12 11:10 ` Pedro Alves
@ 2015-10-22 9:59 ` Simon Marchi
2015-10-22 13:34 ` Pedro Alves
2015-10-22 15:21 ` Simon Marchi
6 siblings, 2 replies; 22+ messages in thread
From: Simon Marchi @ 2015-10-22 9:59 UTC (permalink / raw)
To: gdb-patches
On 15-10-11 12:37 AM, Simon Marchi wrote:
> There might be a cleaner sequence of function calls to do what is done
> here (I don't know), but since I don't want to risk breaking anything,
> it's safer to just add the required cast.
>
> gdb/ChangeLog:
>
> * lm32-tdep.c (lm32_push_dummy_call): Add cast.
> ---
> gdb/lm32-tdep.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/gdb/lm32-tdep.c b/gdb/lm32-tdep.c
> index 25a7e1e..a0defad 100644
> --- a/gdb/lm32-tdep.c
> +++ b/gdb/lm32-tdep.c
> @@ -289,7 +289,7 @@ lm32_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
> regcache_cooked_write_unsigned (regcache, first_arg_reg + i, val);
> else
> {
> - write_memory (sp, (void *) &val, TYPE_LENGTH (arg_type));
> + write_memory (sp, (const gdb_byte *) &val, TYPE_LENGTH (arg_type));
> sp -= 4;
> }
> }
>
Ping for patches 1 and 4.
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [PATCH c++ 4/5] mips: fix void*/gdb_byte* compilation errors
2015-10-11 4:37 ` [PATCH c++ 4/5] mips: fix void*/gdb_byte* compilation errors Simon Marchi
@ 2015-10-22 13:13 ` Pedro Alves
0 siblings, 0 replies; 22+ messages in thread
From: Pedro Alves @ 2015-10-22 13:13 UTC (permalink / raw)
To: Simon Marchi, gdb-patches
On 10/11/2015 05:37 AM, Simon Marchi wrote:
> The error in mips64_linux_get_longjmp_target is fixed by changing "buf"
> to be a gdb_byte*, as usual. supply_32bit_reg and mips64_fill_gregset
> do some more complicated things however, so it's safer just to add the
> explicit cast and avoid changing the code too much.
>
> gdb/ChangeLog:
>
> * mips-linux-tdep.c (mips64_linux_get_longjmp_target): Change type of
> buf to gdb_byte*.
> (supply_32bit_reg): Add cast.
> (mips64_fill_gregset): Likewise.
OK.
Thanks,
Pedro Alves
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [PATCH c++ 1/5] lm32: Add (const gdb_byte *) cast
2015-10-22 9:59 ` Simon Marchi
@ 2015-10-22 13:34 ` Pedro Alves
2015-10-22 13:39 ` Simon Marchi
2015-10-22 15:21 ` Simon Marchi
1 sibling, 1 reply; 22+ messages in thread
From: Pedro Alves @ 2015-10-22 13:34 UTC (permalink / raw)
To: Simon Marchi, gdb-patches
On 10/21/2015 07:44 PM, Simon Marchi wrote:
> Ping for patches 1 and 4.
I think patch #1 is already in, it was the one that ended up
using write_memory_unsigned_integer.
Thanks,
Pedro Alves
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [PATCH c++ 1/5] lm32: Add (const gdb_byte *) cast
2015-10-22 13:34 ` Pedro Alves
@ 2015-10-22 13:39 ` Simon Marchi
0 siblings, 0 replies; 22+ messages in thread
From: Simon Marchi @ 2015-10-22 13:39 UTC (permalink / raw)
To: Pedro Alves, gdb-patches
On 15-10-22 06:55 AM, Pedro Alves wrote:
> On 10/21/2015 07:44 PM, Simon Marchi wrote:
>
>> Ping for patches 1 and 4.
>
> I think patch #1 is already in, it was the one that ended up
> using write_memory_unsigned_integer.
>
> Thanks,
> Pedro Alves
>
Ah indeed, sorry about that.
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [PATCH c++ 1/5] lm32: Add (const gdb_byte *) cast
2015-10-22 9:59 ` Simon Marchi
2015-10-22 13:34 ` Pedro Alves
@ 2015-10-22 15:21 ` Simon Marchi
1 sibling, 0 replies; 22+ messages in thread
From: Simon Marchi @ 2015-10-22 15:21 UTC (permalink / raw)
To: gdb-patches
On 15-10-21 02:44 PM, Simon Marchi wrote:
> Ping for patches 1 and 4.
This is now all pushed, except #5 which is dropped because
Pedro has a more appropriate fix.
^ permalink raw reply [flat|nested] 22+ messages in thread
end of thread, other threads:[~2015-10-22 13:51 UTC | newest]
Thread overview: 22+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-10-11 4:37 [PATCH c++ 1/5] lm32: Add (const gdb_byte *) cast Simon Marchi
2015-10-11 4:37 ` [PATCH c++ 3/5] mep: Add cast for int to enum conversion Simon Marchi
2015-10-12 10:35 ` Yao Qi
2015-10-12 16:43 ` Simon Marchi
2015-10-11 4:37 ` [PATCH c++ 2/5] m32c: Split m32c_move_reg_t in read/write variants Simon Marchi
2015-10-12 10:47 ` Yao Qi
2015-10-12 16:42 ` Simon Marchi
2015-10-11 4:37 ` [PATCH c++ 4/5] mips: fix void*/gdb_byte* compilation errors Simon Marchi
2015-10-22 13:13 ` Pedro Alves
2015-10-11 4:44 ` [PATCH c++ 5/5] mips: Add cast for int to enum conversion Simon Marchi
2015-10-12 10:54 ` Pedro Alves
2015-10-12 16:28 ` Simon Marchi
2015-10-12 10:52 ` [PATCH c++ 1/5] lm32: Add (const gdb_byte *) cast Yao Qi
2015-10-12 11:10 ` Pedro Alves
2015-10-12 12:18 ` Jon Beniston
2015-10-13 17:14 ` Simon Marchi
2015-10-13 17:32 ` Pedro Alves
2015-10-13 17:37 ` Simon Marchi
2015-10-22 9:59 ` Simon Marchi
2015-10-22 13:34 ` Pedro Alves
2015-10-22 13:39 ` Simon Marchi
2015-10-22 15:21 ` Simon Marchi
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox