From: Denis Revunov <rnovds@gmail.com>
To: Tom Tromey <tom@tromey.com>
Cc: Denis Revunov via Gdb-patches <gdb-patches@sourceware.org>
Subject: Re: [RFC] [PATCH] Return intptr when dereferencing integer
Date: Sat, 29 Jul 2023 03:14:47 +0300 [thread overview]
Message-ID: <CAAY_WRbj4X1UYzfMs_-MFiQ6vuVNAqsbSuncD4oFWQPyvA08xg@mail.gmail.com> (raw)
In-Reply-To: <87lef1ib4o.fsf@tromey.com>
[-- Attachment #1: Type: text/plain, Size: 3016 bytes --]
>>>>> "Tom" == Tom Tromey via Gdb-patches <gdb-patches@sourceware.org>
writes:
Tom> Does this impact any test?
I cannot be 100% sure because i get slightly different test results on
consecutive runs even without any changes, but it seems the only failures
appearing in gdb.sum diff (with/without the patch) are timeouts and some
server stuff, and there's like 2-5 of them. So we're probably fine.
Tom> If not, can a test be written for it?
Sure, see a diff in the end.
Tom> I guess from context the scenario is something like: "print *23",
Tom> and here gdb acts like you typed "print *(int*)23"?
That's right, and my point is to make it act like "print *(intptr_t*)23".
Because int is intptr_t everywhere except 64-bit.
Here's a diff for the test:
---
gdb/testsuite/gdb.base/pointers.c | 5 ++++-
gdb/testsuite/gdb.base/pointers.exp | 4 ++++
2 files changed, 8 insertions(+), 1 deletion(-)
diff --git a/gdb/testsuite/gdb.base/pointers.c
b/gdb/testsuite/gdb.base/pointers.c
index 96f2b52f5e8..d3a9689b46a 100644
--- a/gdb/testsuite/gdb.base/pointers.c
+++ b/gdb/testsuite/gdb.base/pointers.c
@@ -1,4 +1,4 @@
-
+#include <stdint.h>
#if !defined (__STDC__) && !defined (_AIX)
#define signed /**/
#endif
@@ -71,6 +71,8 @@ float ** ptr_to_ptr_to_float;
int y;
+const intptr_t intptr_max = INTPTR_MAX;
+intptr_t intptr_p;
typedef long k[5];
@@ -170,6 +172,7 @@ void dummy()
v_float_array[0] = v_float;
v_double_array[0] = v_double;
+ intptr_p = (intptr_t)&intptr_max;
}
diff --git a/gdb/testsuite/gdb.base/pointers.exp
b/gdb/testsuite/gdb.base/pointers.exp
index d72fa5ad613..5787b873cca 100644
--- a/gdb/testsuite/gdb.base/pointers.exp
+++ b/gdb/testsuite/gdb.base/pointers.exp
@@ -202,6 +202,10 @@ gdb_test "print *( *(matrix+1) +2)" " = 5" \
gdb_test "print **ptr_to_ptr_to_float" " = 100" \
"print through ptr to ptr"
+# when we attempt to dereference an integer,
+# it should be treated as a pointer to intptr_t.
+gdb_test "print *intptr_p == intptr_max" " = 1" "deref size is intptr"
+
# tests for pointers
# with elementary type variables and pointers.
#
--
2.41.0
On Thu, 27 Jul 2023 at 19:15, Tom Tromey <tom@tromey.com> wrote:
> >>>>> "Denis" == Denis Revunov via Gdb-patches <gdb-patches@sourceware.org>
> writes:
>
> Denis> The code which makes default dereference type an int was intruduced
> in
> Denis> gdb-3.4(1c997a4ae869) in 1989, 10 years before AMD64 was released.
> With
> Denis> current adoption of 64-bit it makes sense to change default
> dereference
> Denis> size to match the native address size, which will enable us to
> easily
> Denis> inspect .got entries and follow chains of pointers on 64-bit systems
> Denis> without excessive casting. This change won't affect 32-and-less bit
> Denis> systems since intptr is the same as int there.
>
> Does this impact any test?
> If not, can a test be written for it?
>
> I guess from context the scenario is something like: "print *23",
> and here gdb acts like you typed "print *(int*)23"?
>
> Tom
>
next prev parent reply other threads:[~2023-07-29 0:15 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-07-26 21:52 Denis Revunov
2023-07-27 16:15 ` Tom Tromey
2023-07-29 0:14 ` Denis Revunov [this message]
2023-08-13 16:35 ` Revunov Denis
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CAAY_WRbj4X1UYzfMs_-MFiQ6vuVNAqsbSuncD4oFWQPyvA08xg@mail.gmail.com \
--to=rnovds@gmail.com \
--cc=gdb-patches@sourceware.org \
--cc=tom@tromey.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).