* [PATCH v3] Unbreak gdb build on 32-bit host with ADI support
@ 2017-08-26 0:44 Weimin Pan
2017-08-30 19:01 ` ping: " Jan Kratochvil
2017-08-31 8:31 ` Pedro Alves
0 siblings, 2 replies; 4+ messages in thread
From: Weimin Pan @ 2017-08-26 0:44 UTC (permalink / raw)
To: gdb-patches
The problem of failing to build with arm-linux-gnueabihf-g++-4.8 was
that type CORE_ADDR is of "unsigned long" on a 64-bit machine so it's
OK to use %lx but is of type "unsigned long long" on a 32 bit system.
Fixed the problem in three places - (1) use a temp variable of type CORE_ADDR
as argument 3 when calling target_auxv_search() then assign its value to
"blksize" and "nbits" in 2 calls; (2) redo adi_normalize_address() using
masks and xor operators to calculate normalized address; (3) call paddress()
to print CORE_ADDR in either printf_filtered() or error(). Thank you, Pedro,
for all your suggestions.
---
gdb/ChangeLog | 4 ++++
gdb/sparc64-tdep.c | 36 ++++++++++++++++++++++++------------
2 files changed, 28 insertions(+), 12 deletions(-)
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 7eeab62..6b413f4 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,7 @@
+2017-08-25 Weimin Pan <weimin.pan@oracle.com>
+
+ * sparc64-tdep.c: Unbreak gdb build on 32-bit host with ADI support.
+
2017-08-23 Jan Kratochvil <jan.kratochvil@redhat.com>
* NEWS (Changes since GDB 8.0): Add set compile-gcc and show
diff --git a/gdb/sparc64-tdep.c b/gdb/sparc64-tdep.c
index 6f4fca7..b07bed2 100644
--- a/gdb/sparc64-tdep.c
+++ b/gdb/sparc64-tdep.c
@@ -93,8 +93,8 @@ typedef struct
unsigned long blksize;
/* Number of bits used for an ADI version tag which can be
- * used together with the shift value for an ADI version tag
- * to encode or extract the ADI version value in a pointer. */
+ used together with the shift value for an ADI version tag
+ to encode or extract the ADI version value in a pointer. */
unsigned long nbits;
/* The maximum ADI version tag value supported. */
@@ -217,15 +217,17 @@ adi_available (void)
{
pid_t pid = ptid_get_pid (inferior_ptid);
sparc64_adi_info *proc = get_adi_info_proc (pid);
+ CORE_ADDR value;
if (proc->stat.checked_avail)
return proc->stat.is_avail;
proc->stat.checked_avail = true;
- if (target_auxv_search (¤t_target, AT_ADI_BLKSZ,
- &proc->stat.blksize) <= 0)
- return false;
- target_auxv_search (¤t_target, AT_ADI_NBITS, &proc->stat.nbits);
+ if (target_auxv_search (¤t_target, AT_ADI_BLKSZ, &value) <= 0)
+ return false;
+ proc->stat.blksize = value;
+ target_auxv_search (¤t_target, AT_ADI_NBITS, &value);
+ proc->stat.nbits = value;
proc->stat.max_version = (1 << proc->stat.nbits) - 2;
proc->stat.is_avail = true;
@@ -240,7 +242,14 @@ adi_normalize_address (CORE_ADDR addr)
adi_stat_t ast = get_adi_info (ptid_get_pid (inferior_ptid));
if (ast.nbits)
- return ((CORE_ADDR)(((long)addr << ast.nbits) >> ast.nbits));
+ {
+ /* Clear upper bits. */
+ addr &= ((uint64_t) -1) >> ast.nbits;
+
+ /* Sign extend. */
+ CORE_ADDR signbit = (uint64_t) 1 << (64 - ast.nbits - 1);
+ return (addr ^ signbit) - signbit;
+ }
return addr;
}
@@ -346,7 +355,8 @@ adi_read_versions (CORE_ADDR vaddr, size_t size, unsigned char *tags)
if (!adi_is_addr_mapped (vaddr, size))
{
adi_stat_t ast = get_adi_info (ptid_get_pid (inferior_ptid));
- error(_("Address at 0x%lx is not in ADI maps"), vaddr*ast.blksize);
+ error(_("Address at %s is not in ADI maps"),
+ paddress (target_gdbarch (), vaddr * ast.blksize));
}
int target_errno;
@@ -366,7 +376,8 @@ adi_write_versions (CORE_ADDR vaddr, size_t size, unsigned char *tags)
if (!adi_is_addr_mapped (vaddr, size))
{
adi_stat_t ast = get_adi_info (ptid_get_pid (inferior_ptid));
- error(_("Address at 0x%lx is not in ADI maps"), vaddr*ast.blksize);
+ error(_("Address at %s is not in ADI maps"),
+ paddress (target_gdbarch (), vaddr * ast.blksize));
}
int target_errno;
@@ -387,7 +398,8 @@ adi_print_versions (CORE_ADDR vaddr, size_t cnt, unsigned char *tags)
while (cnt > 0)
{
QUIT;
- printf_filtered ("0x%016lx:\t", vaddr * adi_stat.blksize);
+ printf_filtered ("%s:\t",
+ paddress (target_gdbarch (), vaddr * adi_stat.blksize));
for (int i = maxelts; i > 0 && cnt > 0; i--, cnt--)
{
if (tags[v_idx] == 0xff) /* no version tag */
@@ -418,7 +430,7 @@ do_examine (CORE_ADDR start, int bcnt)
if (read_cnt == -1)
error (_("No ADI information"));
else if (read_cnt < cnt)
- error(_("No ADI information at 0x%lx"), vaddr);
+ error(_("No ADI information at %s"), paddress (target_gdbarch (), vaddr));
adi_print_versions (vstart, cnt, buf);
@@ -438,7 +450,7 @@ do_assign (CORE_ADDR start, size_t bcnt, int version)
if (set_cnt == -1)
error (_("No ADI information"));
else if (set_cnt < cnt)
- error(_("No ADI information at 0x%lx"), vaddr);
+ error(_("No ADI information at %s"), paddress (target_gdbarch (), vaddr));
}
--
1.7.1
^ permalink raw reply [flat|nested] 4+ messages in thread
* ping: [PATCH v3] Unbreak gdb build on 32-bit host with ADI support
2017-08-26 0:44 [PATCH v3] Unbreak gdb build on 32-bit host with ADI support Weimin Pan
@ 2017-08-30 19:01 ` Jan Kratochvil
2017-08-31 8:31 ` Pedro Alves
1 sibling, 0 replies; 4+ messages in thread
From: Jan Kratochvil @ 2017-08-30 19:01 UTC (permalink / raw)
To: Weimin Pan; +Cc: gdb-patches, Pedro Alves
On Sat, 26 Aug 2017 02:33:25 +0200, Weimin Pan wrote:
> The problem of failing to build with arm-linux-gnueabihf-g++-4.8 was
> that type CORE_ADDR is of "unsigned long" on a 64-bit machine so it's
> OK to use %lx but is of type "unsigned long long" on a 32 bit system.
This is a bit annoying during testing, could there be an approval?
Jan
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v3] Unbreak gdb build on 32-bit host with ADI support
2017-08-26 0:44 [PATCH v3] Unbreak gdb build on 32-bit host with ADI support Weimin Pan
2017-08-30 19:01 ` ping: " Jan Kratochvil
@ 2017-08-31 8:31 ` Pedro Alves
2017-08-31 16:35 ` Wei-min Pan
1 sibling, 1 reply; 4+ messages in thread
From: Pedro Alves @ 2017-08-31 8:31 UTC (permalink / raw)
To: Weimin Pan, gdb-patches
Hi Weimin,
> +2017-08-25 Weimin Pan <weimin.pan@oracle.com>
> +
> + * sparc64-tdep.c: Unbreak gdb build on 32-bit host with ADI support.
> +
In the GNU ChangeLog format, this should say which functions were touched,
and what was changed, as opposed to "why" things were changed. Please take a
look here to learn more about this:
https://sourceware.org/gdb/wiki/ContributionChecklist
You actually already had the right info in the commit log, so I cooked up
an entry for you, and pushed the patch in with that:
2017-08-31 Weimin Pan <weimin.pan@oracle.com>
* sparc64-tdep.c (adi_stat_t): Fix comment formatting.
(adi_available): Use a temp variable of type CORE_ADDR as argument
3 when calling target_auxv_search.
(adi_normalize_address): Use masks and xor operators to calculate
normalized address.
(adi_read_versions, adi_write_versions, adi_print_versions)
(do_examine, do_assign): Use paddress.
Thanks for the patch.
Pedro Alves
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v3] Unbreak gdb build on 32-bit host with ADI support
2017-08-31 8:31 ` Pedro Alves
@ 2017-08-31 16:35 ` Wei-min Pan
0 siblings, 0 replies; 4+ messages in thread
From: Wei-min Pan @ 2017-08-31 16:35 UTC (permalink / raw)
To: Pedro Alves, gdb-patches
HI Pedro,
Thank you very much for your helpful suggestions/ideas. While I've
learned quite
a bit from the reviews on my first patch, I believe I have a long way to
go :)
Thanks again,
Weimin
On 8/31/2017 1:31 AM, Pedro Alves wrote:
> Hi Weimin,
>
>> +2017-08-25 Weimin Pan <weimin.pan@oracle.com>
>> +
>> + * sparc64-tdep.c: Unbreak gdb build on 32-bit host with ADI support.
>> +
> In the GNU ChangeLog format, this should say which functions were touched,
> and what was changed, as opposed to "why" things were changed. Please take a
> look here to learn more about this:
>
> https://sourceware.org/gdb/wiki/ContributionChecklist
>
> You actually already had the right info in the commit log, so I cooked up
> an entry for you, and pushed the patch in with that:
>
> 2017-08-31 Weimin Pan <weimin.pan@oracle.com>
>
> * sparc64-tdep.c (adi_stat_t): Fix comment formatting.
> (adi_available): Use a temp variable of type CORE_ADDR as argument
> 3 when calling target_auxv_search.
> (adi_normalize_address): Use masks and xor operators to calculate
> normalized address.
> (adi_read_versions, adi_write_versions, adi_print_versions)
> (do_examine, do_assign): Use paddress.
>
> Thanks for the patch.
>
> Pedro Alves
>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2017-08-31 16:35 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-08-26 0:44 [PATCH v3] Unbreak gdb build on 32-bit host with ADI support Weimin Pan
2017-08-30 19:01 ` ping: " Jan Kratochvil
2017-08-31 8:31 ` Pedro Alves
2017-08-31 16:35 ` Wei-min Pan
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).