* [PATCH] gcc: Adjust gdbhooks.py VecPrinter for vec layout changes
@ 2023-03-03 16:44 Jonathan Wakely
2023-03-03 16:45 ` Jakub Jelinek
0 siblings, 1 reply; 6+ messages in thread
From: Jonathan Wakely @ 2023-03-03 16:44 UTC (permalink / raw)
To: gcc-patches
OK for trunk?
gcc/ChangeLog:
* gdbhooks.py (VecPrinter): Adjust for new vec layout.
---
gcc/gdbhooks.py | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/gcc/gdbhooks.py b/gcc/gdbhooks.py
index c9dea9bf828..78e6c97c30d 100644
--- a/gcc/gdbhooks.py
+++ b/gcc/gdbhooks.py
@@ -461,7 +461,11 @@ class VecPrinter:
return
m_vecpfx = self.gdbval['m_vecpfx']
m_num = m_vecpfx['m_num']
- m_vecdata = self.gdbval['m_vecdata']
+ typ = self.gdbval.type
+ if typ.code == gdb.TYPE_CODE_PTR:
+ typ = typ.target()
+ typ = typ.template_argument(0) # the type T
+ m_vecdata = (self.gdbval.address + 1).cast(typ.pointer())
for i in range(m_num):
yield ('[%d]' % i, m_vecdata[i])
--
2.39.2
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] gcc: Adjust gdbhooks.py VecPrinter for vec layout changes
2023-03-03 16:44 [PATCH] gcc: Adjust gdbhooks.py VecPrinter for vec layout changes Jonathan Wakely
@ 2023-03-03 16:45 ` Jakub Jelinek
2023-03-03 17:01 ` Jakub Jelinek
0 siblings, 1 reply; 6+ messages in thread
From: Jakub Jelinek @ 2023-03-03 16:45 UTC (permalink / raw)
To: Jonathan Wakely; +Cc: gcc-patches
On Fri, Mar 03, 2023 at 04:44:39PM +0000, Jonathan Wakely via Gcc-patches wrote:
> OK for trunk?
>
> gcc/ChangeLog:
>
Please add
PR middle-end/109006
here
> * gdbhooks.py (VecPrinter): Adjust for new vec layout.
Ok with that, thanks.
> gcc/gdbhooks.py | 6 +++++-
> 1 file changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/gcc/gdbhooks.py b/gcc/gdbhooks.py
> index c9dea9bf828..78e6c97c30d 100644
> --- a/gcc/gdbhooks.py
> +++ b/gcc/gdbhooks.py
> @@ -461,7 +461,11 @@ class VecPrinter:
> return
> m_vecpfx = self.gdbval['m_vecpfx']
> m_num = m_vecpfx['m_num']
> - m_vecdata = self.gdbval['m_vecdata']
> + typ = self.gdbval.type
> + if typ.code == gdb.TYPE_CODE_PTR:
> + typ = typ.target()
> + typ = typ.template_argument(0) # the type T
> + m_vecdata = (self.gdbval.address + 1).cast(typ.pointer())
> for i in range(m_num):
> yield ('[%d]' % i, m_vecdata[i])
>
> --
> 2.39.2
Jakub
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] gcc: Adjust gdbhooks.py VecPrinter for vec layout changes
2023-03-03 16:45 ` Jakub Jelinek
@ 2023-03-03 17:01 ` Jakub Jelinek
2023-03-03 17:52 ` Jonathan Wakely
0 siblings, 1 reply; 6+ messages in thread
From: Jakub Jelinek @ 2023-03-03 17:01 UTC (permalink / raw)
To: Jonathan Wakely, gcc-patches
On Fri, Mar 03, 2023 at 05:45:59PM +0100, Jakub Jelinek via Gcc-patches wrote:
> On Fri, Mar 03, 2023 at 04:44:39PM +0000, Jonathan Wakely via Gcc-patches wrote:
> > OK for trunk?
> >
> > gcc/ChangeLog:
> >
>
> Please add
> PR middle-end/109006
> here
> > * gdbhooks.py (VecPrinter): Adjust for new vec layout.
>
> Ok with that, thanks.
Though, trying it on another vector it doesn't work in that case.
Testcase:
int
foo (void)
{
return 1;
}
gdb ./cc1 -quiet -O2 test.c
b pass_reassoc::execute
r
p debug_bb_n (2)
p $1->preds
(gdb) p $1->preds
$2 = 0x7fffea2d1f50 = {<error reading variable: Cannot access memory at address 0x100000058>}
(gdb) p $1->succs
$3 = 0x7fffea3010a0 = {<edge 0x0>}
But if I try to print it the hard way:
(gdb) p ((edge_def**)(&$1->preds.m_vecpfx+1))[0]
$4 = <edge 0x7fffea2fcdb0 (ENTRY -> 2)>
(gdb) p ((edge_def**)(&$1->succs.m_vecpfx+1))[0]
$5 = <edge 0x7fffea2fce70 (2 -> EXIT)>
> > diff --git a/gcc/gdbhooks.py b/gcc/gdbhooks.py
> > index c9dea9bf828..78e6c97c30d 100644
> > --- a/gcc/gdbhooks.py
> > +++ b/gcc/gdbhooks.py
> > @@ -461,7 +461,11 @@ class VecPrinter:
> > return
> > m_vecpfx = self.gdbval['m_vecpfx']
> > m_num = m_vecpfx['m_num']
> > - m_vecdata = self.gdbval['m_vecdata']
> > + typ = self.gdbval.type
> > + if typ.code == gdb.TYPE_CODE_PTR:
> > + typ = typ.target()
> > + typ = typ.template_argument(0) # the type T
> > + m_vecdata = (self.gdbval.address + 1).cast(typ.pointer())
> > for i in range(m_num):
> > yield ('[%d]' % i, m_vecdata[i])
Jakub
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] gcc: Adjust gdbhooks.py VecPrinter for vec layout changes
2023-03-03 17:01 ` Jakub Jelinek
@ 2023-03-03 17:52 ` Jonathan Wakely
2023-03-03 18:07 ` [PATCH] gcc: Fix gdbhooks.py VecPrinter for vec<> as well as vec<>* [PR109006] Jonathan Wakely
0 siblings, 1 reply; 6+ messages in thread
From: Jonathan Wakely @ 2023-03-03 17:52 UTC (permalink / raw)
To: Jakub Jelinek; +Cc: gcc-patches
[-- Attachment #1: Type: text/plain, Size: 1694 bytes --]
On Fri, 3 Mar 2023 at 17:01, Jakub Jelinek <jakub@redhat.com> wrote:
> On Fri, Mar 03, 2023 at 05:45:59PM +0100, Jakub Jelinek via Gcc-patches
> wrote:
> > On Fri, Mar 03, 2023 at 04:44:39PM +0000, Jonathan Wakely via
> Gcc-patches wrote:
> > > OK for trunk?
> > >
> > > gcc/ChangeLog:
> > >
> >
> > Please add
> > PR middle-end/109006
> > here
> > > * gdbhooks.py (VecPrinter): Adjust for new vec layout.
> >
> > Ok with that, thanks.
>
> Though, trying it on another vector it doesn't work in that case.
> Testcase:
> int
> foo (void)
> {
> return 1;
> }
> gdb ./cc1 -quiet -O2 test.c
> b pass_reassoc::execute
> r
> p debug_bb_n (2)
> p $1->preds
> (gdb) p $1->preds
> $2 = 0x7fffea2d1f50 = {<error reading variable: Cannot access memory at
> address 0x100000058>}
> (gdb) p $1->succs
> $3 = 0x7fffea3010a0 = {<edge 0x0>}
>
> But if I try to print it the hard way:
> (gdb) p ((edge_def**)(&$1->preds.m_vecpfx+1))[0]
> $4 = <edge 0x7fffea2fcdb0 (ENTRY -> 2)>
> (gdb) p ((edge_def**)(&$1->succs.m_vecpfx+1))[0]
> $5 = <edge 0x7fffea2fce70 (2 -> EXIT)>
>
Here's a fix for that testcase:
--- a/gcc/gdbhooks.py
+++ b/gcc/gdbhooks.py
@@ -462,10 +462,13 @@ class VecPrinter:
m_vecpfx = self.gdbval['m_vecpfx']
m_num = m_vecpfx['m_num']
typ = self.gdbval.type
+ val = self.gdbval
if typ.code == gdb.TYPE_CODE_PTR:
typ = typ.target()
+ else:
+ val = val.address
typ = typ.template_argument(0) # the type T
- m_vecdata = (self.gdbval.address + 1).cast(typ.pointer())
+ m_vecdata = (val + 1).cast(typ.pointer())
for i in range(m_num):
yield ('[%d]' % i, m_vecdata[i])
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH] gcc: Fix gdbhooks.py VecPrinter for vec<> as well as vec<>* [PR109006]
2023-03-03 17:52 ` Jonathan Wakely
@ 2023-03-03 18:07 ` Jonathan Wakely
2023-03-03 18:12 ` Jakub Jelinek
0 siblings, 1 reply; 6+ messages in thread
From: Jonathan Wakely @ 2023-03-03 18:07 UTC (permalink / raw)
To: gcc-patches
This fixes Jakub's second testcase. The printer needs to do slightly
different things depending on whether the gdbval obejct is a vec or a
pointer to a vec.
OK for trunk?
-- >8 --
gcc/ChangeLog:
PR middle-end/109006
* gdbhooks.py (VecPrinter): Handle vec<T> as well as vec<T>*.
---
gcc/gdbhooks.py | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)
diff --git a/gcc/gdbhooks.py b/gcc/gdbhooks.py
index 78e6c97c30d..e29bd458909 100644
--- a/gcc/gdbhooks.py
+++ b/gcc/gdbhooks.py
@@ -461,13 +461,16 @@ class VecPrinter:
return
m_vecpfx = self.gdbval['m_vecpfx']
m_num = m_vecpfx['m_num']
- typ = self.gdbval.type
+ val = self.gdbval
+ typ = val.type
if typ.code == gdb.TYPE_CODE_PTR:
typ = typ.target()
- typ = typ.template_argument(0) # the type T
- m_vecdata = (self.gdbval.address + 1).cast(typ.pointer())
+ else:
+ val = val.address
+ typ_T = typ.template_argument(0) # the type T
+ vecdata = (val + 1).cast(typ_T.pointer())
for i in range(m_num):
- yield ('[%d]' % i, m_vecdata[i])
+ yield ('[%d]' % i, vecdata[i])
######################################################################
--
2.39.2
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] gcc: Fix gdbhooks.py VecPrinter for vec<> as well as vec<>* [PR109006]
2023-03-03 18:07 ` [PATCH] gcc: Fix gdbhooks.py VecPrinter for vec<> as well as vec<>* [PR109006] Jonathan Wakely
@ 2023-03-03 18:12 ` Jakub Jelinek
0 siblings, 0 replies; 6+ messages in thread
From: Jakub Jelinek @ 2023-03-03 18:12 UTC (permalink / raw)
To: Jonathan Wakely; +Cc: gcc-patches
On Fri, Mar 03, 2023 at 06:07:48PM +0000, Jonathan Wakely via Gcc-patches wrote:
> This fixes Jakub's second testcase. The printer needs to do slightly
> different things depending on whether the gdbval obejct is a vec or a
> pointer to a vec.
>
> OK for trunk?
>
> -- >8 --
>
> gcc/ChangeLog:
>
> PR middle-end/109006
> * gdbhooks.py (VecPrinter): Handle vec<T> as well as vec<T>*.
Yes, thanks.
Jakub
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2023-03-03 18:12 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-03 16:44 [PATCH] gcc: Adjust gdbhooks.py VecPrinter for vec layout changes Jonathan Wakely
2023-03-03 16:45 ` Jakub Jelinek
2023-03-03 17:01 ` Jakub Jelinek
2023-03-03 17:52 ` Jonathan Wakely
2023-03-03 18:07 ` [PATCH] gcc: Fix gdbhooks.py VecPrinter for vec<> as well as vec<>* [PR109006] Jonathan Wakely
2023-03-03 18:12 ` Jakub Jelinek
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).