* [PATCH 6/11] Add ALPHA_MAX_REGISTER_SIZE @ 2017-04-04 10:14 Alan Hayward 2017-04-11 9:16 ` Yao Qi 0 siblings, 1 reply; 6+ messages in thread From: Alan Hayward @ 2017-04-04 10:14 UTC (permalink / raw) To: gdb-patches; +Cc: nd Max size set to 64bits, which I determined using alpha_register_type() Tested on a --enable-targets=all build using make check with board files unix and native-gdbserver. I do not have an ALPHA machine to test on. Ok to commit? Alan. 2017-04-04 Alan Hayward <alan.hayward@arm.com> * alpha-tdep.c (alpha_register_to_value): Use ALPHA_MAX_REGISTER_SIZE (alpha_value_to_register): Likewise. * alpha-tdep.h (ALPHA_MAX_REGISTER_SIZE): Add. diff --git a/gdb/alpha-tdep.h b/gdb/alpha-tdep.h index ab46ba56bef1ffb1cea541c506ffed6a5ae9b556..316d94d0bb53e9bc7943d406bf81f7d597437ff3 100644 --- a/gdb/alpha-tdep.h +++ b/gdb/alpha-tdep.h @@ -26,6 +26,9 @@ struct regcache; real way to know how big a register is. */ #define ALPHA_REGISTER_SIZE 8 +/* Big enough to hold the size of the largest register in bytes. */ +#define ALPHA_MAX_REGISTER_SIZE 8 + /* Number of machine registers. */ #define ALPHA_NUM_REGS 67 diff --git a/gdb/alpha-tdep.c b/gdb/alpha-tdep.c index 4dd65c58cc2896ea6038399128e3eb376d1ee672..5a1024e8697a14963b226d275c19721cb6d4e327 100644 --- a/gdb/alpha-tdep.c +++ b/gdb/alpha-tdep.c @@ -244,7 +244,7 @@ alpha_register_to_value (struct frame_info *frame, int regnum, int *optimizedp, int *unavailablep) { struct gdbarch *gdbarch = get_frame_arch (frame); - gdb_byte in[MAX_REGISTER_SIZE]; + gdb_byte in[ALPHA_MAX_REGISTER_SIZE]; /* Convert to TYPE. */ if (!get_frame_register_bytes (frame, regnum, 0, @@ -266,7 +266,7 @@ static void alpha_value_to_register (struct frame_info *frame, int regnum, struct type *valtype, const gdb_byte *in) { - gdb_byte out[MAX_REGISTER_SIZE]; + gdb_byte out[ALPHA_MAX_REGISTER_SIZE]; switch (TYPE_LENGTH (valtype)) { ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 6/11] Add ALPHA_MAX_REGISTER_SIZE 2017-04-04 10:14 [PATCH 6/11] Add ALPHA_MAX_REGISTER_SIZE Alan Hayward @ 2017-04-11 9:16 ` Yao Qi 2017-04-12 8:25 ` Alan Hayward 0 siblings, 1 reply; 6+ messages in thread From: Yao Qi @ 2017-04-11 9:16 UTC (permalink / raw) To: Alan Hayward; +Cc: gdb-patches, nd Alan Hayward <Alan.Hayward@arm.com> writes: > diff --git a/gdb/alpha-tdep.h b/gdb/alpha-tdep.h > index ab46ba56bef1ffb1cea541c506ffed6a5ae9b556..316d94d0bb53e9bc7943d406bf81f7d597437ff3 100644 > --- a/gdb/alpha-tdep.h > +++ b/gdb/alpha-tdep.h > @@ -26,6 +26,9 @@ struct regcache; > real way to know how big a register is. */ > #define ALPHA_REGISTER_SIZE 8 > > +/* Big enough to hold the size of the largest register in bytes. */ > +#define ALPHA_MAX_REGISTER_SIZE 8 > + > --- a/gdb/alpha-tdep.c > +++ b/gdb/alpha-tdep.c > @@ -244,7 +244,7 @@ alpha_register_to_value (struct frame_info *frame, int regnum, > int *optimizedp, int *unavailablep) > { > struct gdbarch *gdbarch = get_frame_arch (frame); > - gdb_byte in[MAX_REGISTER_SIZE]; > + gdb_byte in[ALPHA_MAX_REGISTER_SIZE]; > > /* Convert to TYPE. */ > if (!get_frame_register_bytes (frame, regnum, 0, We can use get_frame_register_value, so "in" can be removed. > @@ -266,7 +266,7 @@ static void > alpha_value_to_register (struct frame_info *frame, int regnum, > struct type *valtype, const gdb_byte *in) > { > - gdb_byte out[MAX_REGISTER_SIZE]; > + gdb_byte out[ALPHA_MAX_REGISTER_SIZE]; Why don't you use ALPHA_REGISTER_SIZE? -- Yao (齐尧) ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 6/11] Add ALPHA_MAX_REGISTER_SIZE 2017-04-11 9:16 ` Yao Qi @ 2017-04-12 8:25 ` Alan Hayward 2017-06-05 16:25 ` Alan Hayward 0 siblings, 1 reply; 6+ messages in thread From: Alan Hayward @ 2017-04-12 8:25 UTC (permalink / raw) To: Yao Qi; +Cc: gdb-patches, nd > On 11 Apr 2017, at 10:16, Yao Qi <qiyaoltc@gmail.com> wrote: > > Alan Hayward <Alan.Hayward@arm.com> writes: > >> diff --git a/gdb/alpha-tdep.h b/gdb/alpha-tdep.h >> index ab46ba56bef1ffb1cea541c506ffed6a5ae9b556..316d94d0bb53e9bc7943d406bf81f7d597437ff3 100644 >> --- a/gdb/alpha-tdep.h >> +++ b/gdb/alpha-tdep.h >> @@ -26,6 +26,9 @@ struct regcache; >> real way to know how big a register is. */ >> #define ALPHA_REGISTER_SIZE 8 >> >> +/* Big enough to hold the size of the largest register in bytes. */ >> +#define ALPHA_MAX_REGISTER_SIZE 8 >> + > >> --- a/gdb/alpha-tdep.c >> +++ b/gdb/alpha-tdep.c >> @@ -244,7 +244,7 @@ alpha_register_to_value (struct frame_info *frame, int regnum, >> int *optimizedp, int *unavailablep) >> { >> struct gdbarch *gdbarch = get_frame_arch (frame); >> - gdb_byte in[MAX_REGISTER_SIZE]; >> + gdb_byte in[ALPHA_MAX_REGISTER_SIZE]; >> >> /* Convert to TYPE. */ >> if (!get_frame_register_bytes (frame, regnum, 0, > > We can use get_frame_register_value, so "in" can be removed. > >> @@ -266,7 +266,7 @@ static void >> alpha_value_to_register (struct frame_info *frame, int regnum, >> struct type *valtype, const gdb_byte *in) >> { >> - gdb_byte out[MAX_REGISTER_SIZE]; >> + gdb_byte out[ALPHA_MAX_REGISTER_SIZE]; > > Why don't you use ALPHA_REGISTER_SIZE? Hmmm... yes. Not sure why I ignored that! > > -- > Yao (齐尧) Updated changes below. I don't have a ALPHA machine to test on. Tested on a --enable-targets=all build using make check with board files unix and native-gdbserver. Ok to commit? Alan. 2017-04-12 Alan Hayward <alan.hayward@arm.com> * alpha-tdep.c (alpha_register_to_value): Use get_frame_register_value. (alpha_value_to_register): Use ALPHA_REGISTER_SIZE. diff --git a/gdb/alpha-tdep.c b/gdb/alpha-tdep.c index 4dd65c58cc2896ea6038399128e3eb376d1ee672..2f9f81952fea0e7fa050866db3fe05776edcdc63 100644 --- a/gdb/alpha-tdep.c +++ b/gdb/alpha-tdep.c @@ -244,17 +244,23 @@ alpha_register_to_value (struct frame_info *frame, int regnum, int *optimizedp, int *unavailablep) { struct gdbarch *gdbarch = get_frame_arch (frame); - gdb_byte in[MAX_REGISTER_SIZE]; + struct value *value; /* Convert to TYPE. */ - if (!get_frame_register_bytes (frame, regnum, 0, - register_size (gdbarch, regnum), - in, optimizedp, unavailablep)) + + value = get_frame_register_value (frame, regnum); + + gdb_assert (value != NULL); + + *optimizedp = value_optimized_out (value); + *unavailablep = !value_entirely_available (value); + + if (*optimizedp || *unavailablep) return 0; if (TYPE_LENGTH (valtype) == 4) { - alpha_sts (gdbarch, out, in); + alpha_sts (gdbarch, out, value_contents (value)); *optimizedp = *unavailablep = 0; return 1; } @@ -266,7 +272,7 @@ static void alpha_value_to_register (struct frame_info *frame, int regnum, struct type *valtype, const gdb_byte *in) { - gdb_byte out[MAX_REGISTER_SIZE]; + gdb_byte out[ALPHA_REGISTER_SIZE]; switch (TYPE_LENGTH (valtype)) { ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 6/11] Add ALPHA_MAX_REGISTER_SIZE 2017-04-12 8:25 ` Alan Hayward @ 2017-06-05 16:25 ` Alan Hayward 2017-06-06 14:02 ` Yao Qi 0 siblings, 1 reply; 6+ messages in thread From: Alan Hayward @ 2017-06-05 16:25 UTC (permalink / raw) To: Yao Qi; +Cc: gdb-patches, nd > On 12 Apr 2017, at 09:25, Alan Hayward <Alan.Hayward@arm.com> wrote: > >> >> On 11 Apr 2017, at 10:16, Yao Qi <qiyaoltc@gmail.com> wrote: >> >> Alan Hayward <Alan.Hayward@arm.com> writes: >> I’ve rebased this patch due to Yao’s unit test changes. Added two asserts a well. I don't have a ALPHA machine to test on. Tested on a --enable-targets=all and --enable-libsanitizer build using make check with board files unix and native-gdbserver. Ok to commit? Alan. 2017-05-30 Alan Hayward <alan.hayward@arm.com> * alpha-tdep.c (alpha_register_to_value): Use get_frame_register_value. (alpha_value_to_register): Use ALPHA_REGISTER_SIZE. diff --git a/gdb/alpha-tdep.c b/gdb/alpha-tdep.c index d7cc0f4974362af89c2b42f4d5934fa8cd5d8a39..06ee90cbc7785d8277e773bdb6b98065e2e19568 100644 --- a/gdb/alpha-tdep.c +++ b/gdb/alpha-tdep.c @@ -244,17 +244,26 @@ alpha_register_to_value (struct frame_info *frame, int regnum, int *optimizedp, int *unavailablep) { struct gdbarch *gdbarch = get_frame_arch (frame); - gdb_byte in[MAX_REGISTER_SIZE]; + struct value *value = get_frame_register_value (frame, regnum); - /* Convert to TYPE. */ - if (!get_frame_register_bytes (frame, regnum, 0, - register_size (gdbarch, regnum), - in, optimizedp, unavailablep)) - return 0; + gdb_assert (value != NULL); + *optimizedp = value_optimized_out (value); + *unavailablep = !value_entirely_available (value); + + if (*optimizedp || *unavailablep) + { + release_value (value); + value_free (value); + return 0; + } + + /* Convert to VALTYPE. */ gdb_assert (TYPE_LENGTH (valtype) == 4); - alpha_sts (gdbarch, out, in); - *optimizedp = *unavailablep = 0; + alpha_sts (gdbarch, out, value_contents_all (value)); + + release_value (value); + value_free (value); return 1; } @@ -262,9 +271,11 @@ static void alpha_value_to_register (struct frame_info *frame, int regnum, struct type *valtype, const gdb_byte *in) { - gdb_byte out[MAX_REGISTER_SIZE]; + gdb_byte out[ALPHA_REGISTER_SIZE]; gdb_assert (TYPE_LENGTH (valtype) == 4); + gdb_assert (register_size (get_frame_arch (frame), regnum) + <= ALPHA_REGISTER_SIZE); alpha_lds (get_frame_arch (frame), out, in); put_frame_register (frame, regnum, out); ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 6/11] Add ALPHA_MAX_REGISTER_SIZE 2017-06-05 16:25 ` Alan Hayward @ 2017-06-06 14:02 ` Yao Qi 2017-06-06 14:47 ` Alan Hayward 0 siblings, 1 reply; 6+ messages in thread From: Yao Qi @ 2017-06-06 14:02 UTC (permalink / raw) To: Alan Hayward; +Cc: gdb-patches, nd Alan Hayward <Alan.Hayward@arm.com> writes: > I don't have a ALPHA machine to test on. > Tested on a --enable-targets=all and --enable-libsanitizer build using > make check with board files unix and native-gdbserver. Could you build GDB with option -fsanitize=address (make CXXFLAGS='-fsanitize=address') and run gdb.gdb/unittest.exp? > > Ok to commit? > OK if there is no fail in unit tests. > Alan. > > 2017-05-30 Alan Hayward <alan.hayward@arm.com> > > * alpha-tdep.c (alpha_register_to_value): Use get_frame_register_value. This line is too long. The line max length in ChangeLog is 74. https://sourceware.org/gdb/wiki/ContributionChecklist#Properly_Formatted_GNU_ChangeLog > (alpha_value_to_register): Use ALPHA_REGISTER_SIZE. -- Yao (齐尧) ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 6/11] Add ALPHA_MAX_REGISTER_SIZE 2017-06-06 14:02 ` Yao Qi @ 2017-06-06 14:47 ` Alan Hayward 0 siblings, 0 replies; 6+ messages in thread From: Alan Hayward @ 2017-06-06 14:47 UTC (permalink / raw) To: Yao Qi; +Cc: gdb-patches, nd > On 6 Jun 2017, at 15:02, Yao Qi <qiyaoltc@gmail.com> wrote: > > Alan Hayward <Alan.Hayward@arm.com> writes: > >> I don't have a ALPHA machine to test on. >> Tested on a --enable-targets=all and --enable-libsanitizer build using >> make check with board files unix and native-gdbserver. > > Could you build GDB with option -fsanitize=address > (make CXXFLAGS='-fsanitize=address') and run gdb.gdb/unittest.exp? > >> >> Ok to commit? >> > > OK if there is no fail in unit tests. Tested along with the IA64 patch. unittest.exp passes. > >> Alan. >> >> 2017-05-30 Alan Hayward <alan.hayward@arm.com> >> >> * alpha-tdep.c (alpha_register_to_value): Use get_frame_register_value. > > This line is too long. The line max length in ChangeLog is 74. > https://sourceware.org/gdb/wiki/ContributionChecklist#Properly_Formatted_GNU_ChangeLog Sorry, that was new to me (As far as I’m aware, gcc uses 80). > >> (alpha_value_to_register): Use ALPHA_REGISTER_SIZE. > > Committed with newline added in changelog. Alan. ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2017-06-06 14:47 UTC | newest] Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2017-04-04 10:14 [PATCH 6/11] Add ALPHA_MAX_REGISTER_SIZE Alan Hayward 2017-04-11 9:16 ` Yao Qi 2017-04-12 8:25 ` Alan Hayward 2017-06-05 16:25 ` Alan Hayward 2017-06-06 14:02 ` Yao Qi 2017-06-06 14:47 ` 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).