public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] PowerPC, correct the gdb ioctl values for TCGETS, TCSETS, TCSETSW and TCSETSF.
@ 2022-06-08 16:37 Carl Love
  2022-06-08 16:59 ` Ulrich Weigand
  0 siblings, 1 reply; 5+ messages in thread
From: Carl Love @ 2022-06-08 16:37 UTC (permalink / raw)
  To: gdb-patches, Ulrich Weigand, Will Schmidt, cel

GDB maintainers:

The current value for the ioctl numbers for TCGETS, TCSETS, TCSETSW and
TCSETSF on PowerPC are not correct.  The ioctl number is based on the 
size of the termios data structure for PowerPC.  The size of the
termios data structure on PowerPC is 0x2c, however the size in the
ioctl number is set at 0x3c.  This patch fixes the size of the ioctl
numbers.

This patch has been tested by running various ioctl tests in the
ncurses testsuite using gdb record full.  Without the patch gdb record
full complains that the various ioctl calls are unkown.  For example
the following message is printed for the ncurses test firework when run
under gdb and record full enabled.

  Process record and replay target doesn't support ioctl request 0x402c7413.

With the patch, the ioctl number for TCGETS is corrected and gdb record
full now records the ioctl call.

The patch has been tested manually with various ncurses test case on a
Power 10 system to verify the patch.

Please let me know if this patch is acceptable for mainline.

                        Carl Love

-------------------------------------------------

PowerPC, correct the gdb ioctl values for TCGETS, TCSETS, TCSETSW and TCSETSF.

Some of the ioctl numbers are based on the size of kernel termios structure.
Currently the PowerPC GDB definitions are "hard coded" into the ioctl
number.

The current PowerPC values for TCGETS, TCSETS, TCSETSW and TCSETSF are
defined in gdb/ppc-linux-tdep.c as:

  record_tdep->ioctl_TCGETS = 0x403c7413;
  record_tdep->ioctl_TCSETS = 0x803c7414;
  record_tdep->ioctl_TCSETSW = 0x803c7415;
  record_tdep->ioctl_TCSETSF = 0x803c7416;

Where the termios structure size is in hex digits [5:4] as 0x3c.

The definition for the PowerPC termios structure is given in:
  arch/powerpc/include/uapi/asm/termbits.h

The size of the termios data structure in this file is 0x2c not 0x3c.

This patch changes the hex digits for the size of the PowerPC termios size
in the ioctl values for TCGETS, TCSETS, TCSETSW and TCSETSF to 0x2c.
This patch also changes the hard coding to generate the number based on a
#define to make it clearer how the ioctl numbers are generated and to make
it easier to update the ioctl numbers.
---
 gdb/ppc-linux-tdep.c | 16 +++++++++++-----
 1 file changed, 11 insertions(+), 5 deletions(-)

diff --git a/gdb/ppc-linux-tdep.c b/gdb/ppc-linux-tdep.c
index 4c5f8b7a281..469f06d2f22 100644
--- a/gdb/ppc-linux-tdep.c
+++ b/gdb/ppc-linux-tdep.c
@@ -1738,6 +1738,11 @@ static void
 ppc_init_linux_record_tdep (struct linux_record_tdep *record_tdep,
 			    int wordsize)
 {
+  /* The values for TCGETS, TCSETS, TCSETSW, TCSETSF are based on the
+     size of struct termios in the kernel source.
+     include/uapi/asm-generic/termbits.h  */
+#define SIZE_OF_STRUCT_TERMIOS  0x2c
+
   /* Simply return if it had been initialized.  */
   if (record_tdep->size_pointer != 0)
     return;
@@ -1898,15 +1903,16 @@ ppc_init_linux_record_tdep (struct linux_record_tdep *record_tdep,
 
   /* These values are the second argument of system call "sys_ioctl".
      They are obtained from Linux Kernel source.
-     See arch/powerpc/include/uapi/asm/ioctls.h.  */
-  record_tdep->ioctl_TCGETS = 0x403c7413;
-  record_tdep->ioctl_TCSETS = 0x803c7414;
-  record_tdep->ioctl_TCSETSW = 0x803c7415;
-  record_tdep->ioctl_TCSETSF = 0x803c7416;
   record_tdep->ioctl_TCGETA = 0x40147417;
   record_tdep->ioctl_TCSETA = 0x80147418;
   record_tdep->ioctl_TCSETAW = 0x80147419;
   record_tdep->ioctl_TCSETAF = 0x8014741c;
+     See arch/powerpc/include/uapi/asm/ioctls.h. */
+  record_tdep->ioctl_TCGETS = 0x40007413 | (SIZE_OF_STRUCT_TERMIOS << 16);
+  record_tdep->ioctl_TCSETS = 0x80007414 | (SIZE_OF_STRUCT_TERMIOS << 16);
+  record_tdep->ioctl_TCSETSW = 0x80007415 | (SIZE_OF_STRUCT_TERMIOS << 16);
+  record_tdep->ioctl_TCSETSF = 0x80007416 | (SIZE_OF_STRUCT_TERMIOS << 16);
+
   record_tdep->ioctl_TCSBRK = 0x2000741d;
   record_tdep->ioctl_TCXONC = 0x2000741e;
   record_tdep->ioctl_TCFLSH = 0x2000741f;
-- 
2.31.1



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] PowerPC, correct the gdb ioctl values for TCGETS, TCSETS,  TCSETSW and TCSETSF.
  2022-06-08 16:37 [PATCH] PowerPC, correct the gdb ioctl values for TCGETS, TCSETS, TCSETSW and TCSETSF Carl Love
@ 2022-06-08 16:59 ` Ulrich Weigand
  2022-06-08 17:26   ` Carl Love
  2022-06-08 17:43   ` [PATCH ver 2] " Carl Love
  0 siblings, 2 replies; 5+ messages in thread
From: Ulrich Weigand @ 2022-06-08 16:59 UTC (permalink / raw)
  To: gdb-patches, will_schmidt, cel

Carl Love <cel@us.ibm.com> wrote:

>@@ -1898,15 +1903,16 @@ ppc_init_linux_record_tdep (struct
>linux_record_tdep *record_tdep,
> 
>   /* These values are the second argument of system call "sys_ioctl".
>      They are obtained from Linux Kernel source.
>-     See arch/powerpc/include/uapi/asm/ioctls.h.  */
>-  record_tdep->ioctl_TCGETS = 0x403c7413;
>-  record_tdep->ioctl_TCSETS = 0x803c7414;
>-  record_tdep->ioctl_TCSETSW = 0x803c7415;
>-  record_tdep->ioctl_TCSETSF = 0x803c7416;
>   record_tdep->ioctl_TCGETA = 0x40147417;
>   record_tdep->ioctl_TCSETA = 0x80147418;
>   record_tdep->ioctl_TCSETAW = 0x80147419;
>   record_tdep->ioctl_TCSETAF = 0x8014741c;
>+     See arch/powerpc/include/uapi/asm/ioctls.h. */
>+  record_tdep->ioctl_TCGETS = 0x40007413 | (SIZE_OF_STRUCT_TERMIOS <<
>16);

This doesn't look right - unless I'm missing something this patch now
effectively comments out the ioctl_TC[GS]ETA* assingments?

Bye,
Ulrich


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] PowerPC, correct the gdb ioctl values for TCGETS, TCSETS, TCSETSW and TCSETSF.
  2022-06-08 16:59 ` Ulrich Weigand
@ 2022-06-08 17:26   ` Carl Love
  2022-06-08 17:43   ` [PATCH ver 2] " Carl Love
  1 sibling, 0 replies; 5+ messages in thread
From: Carl Love @ 2022-06-08 17:26 UTC (permalink / raw)
  To: Ulrich Weigand, gdb-patches, will_schmidt

Ulrich:

On Wed, 2022-06-08 at 16:59 +0000, Ulrich Weigand wrote:
> Carl Love <cel@us.ibm.com> wrote:
> 
> > @@ -1898,15 +1903,16 @@ ppc_init_linux_record_tdep (struct
> > linux_record_tdep *record_tdep,
> > 
> >   /* These values are the second argument of system call
> > "sys_ioctl".
> >      They are obtained from Linux Kernel source.
> > -     See arch/powerpc/include/uapi/asm/ioctls.h.  */
> > -  record_tdep->ioctl_TCGETS = 0x403c7413;
> > -  record_tdep->ioctl_TCSETS = 0x803c7414;
> > -  record_tdep->ioctl_TCSETSW = 0x803c7415;
> > -  record_tdep->ioctl_TCSETSF = 0x803c7416;
> >   record_tdep->ioctl_TCGETA = 0x40147417;
> >   record_tdep->ioctl_TCSETA = 0x80147418;
> >   record_tdep->ioctl_TCSETAW = 0x80147419;
> >   record_tdep->ioctl_TCSETAF = 0x8014741c;
> > +     See arch/powerpc/include/uapi/asm/ioctls.h. */
> > +  record_tdep->ioctl_TCGETS = 0x40007413 | (SIZE_OF_STRUCT_TERMIOS
> > <<
> > 16);
> 
> This doesn't look right - unless I'm missing something this patch now
> effectively comments out the ioctl_TC[GS]ETA* assingments?

Argh!  Yes, you are correct.  Will fix, retest and repost.  Thanks.

                      Carl 


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH ver 2] PowerPC, correct the gdb ioctl values for TCGETS, TCSETS, TCSETSW and TCSETSF.
  2022-06-08 16:59 ` Ulrich Weigand
  2022-06-08 17:26   ` Carl Love
@ 2022-06-08 17:43   ` Carl Love
  2022-06-10 12:00     ` Ulrich Weigand
  1 sibling, 1 reply; 5+ messages in thread
From: Carl Love @ 2022-06-08 17:43 UTC (permalink / raw)
  To: Ulrich Weigand, gdb-patches, will_schmidt

Ulrich, GDB maintainers:

Per Ulrich's feedback, I fixed the closing comment to not accidentally
comment out the ioctl_TC[GS]ETA* assignments. 

The current value for the ioctl numbers for TCGETS, TCSETS, TCSETSW and
TCSETSF on PowerPC are not correct.  The ioctl number is based on the 
size of the termios data structure for PowerPC.  The size of the
termios data structure on PowerPC is 0x2c, however the size in the
ioctl number is set at 0x3c.  This patch fixes the size of the ioctl
numbers.

This patch has been tested by running various ioctl tests in the
ncurses testsuite using gdb record full.  Without the patch gdb record
full complains that the various ioctl calls are unkown.  For example
the following message is printed for the ncurses test firework when run
under gdb and record full enabled.

  Process record and replay target doesn't support ioctl request
0x402c7413.

With the patch, the ioctl number for TCGETS is corrected and gdb record
full now records the ioctl call.

The patch has been tested manually with various ncurses test case on a
Power 10 system to verify the patch.

Please let me know if this patch is acceptable for mainline.

                        Carl Love

------------------------------------------------------------

PowerPC, correct the gdb ioctl values for TCGETS, TCSETS, TCSETSW and TCSETSF.

Some of the ioctl numbers are based on the size of kernel termios structure.
Currently the PowerPC GDB definitions are "hard coded" into the ioctl
number.

The current PowerPC values for TCGETS, TCSETS, TCSETSW and TCSETSF are
defined in gdb/ppc-linux-tdep.c as:

  record_tdep->ioctl_TCGETS = 0x403c7413;
  record_tdep->ioctl_TCSETS = 0x803c7414;
  record_tdep->ioctl_TCSETSW = 0x803c7415;
  record_tdep->ioctl_TCSETSF = 0x803c7416;

Where the termios structure size is in hex digits [5:4] as 0x3c.

The definition for the PowerPC termios structure is given in:
  arch/powerpc/include/uapi/asm/termbits.h

The size of the termios data structure in this file is 0x2c not 0x3c.

This patch changes the hex digits for the size of the PowerPC termios size
in the ioctl values for TCGETS, TCSETS, TCSETSW and TCSETSF to 0x2c.
This patch also changes the hard coding to generate the number based on a
it easier to update the ioctl numbers.
---
 gdb/ppc-linux-tdep.c | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/gdb/ppc-linux-tdep.c b/gdb/ppc-linux-tdep.c
index 4c5f8b7a281..bf95f395515 100644
--- a/gdb/ppc-linux-tdep.c
+++ b/gdb/ppc-linux-tdep.c
@@ -1738,6 +1738,11 @@ static void
 ppc_init_linux_record_tdep (struct linux_record_tdep *record_tdep,
 			    int wordsize)
 {
+  /* The values for TCGETS, TCSETS, TCSETSW, TCSETSF are based on the
+     size of struct termios in the kernel source.
+     include/uapi/asm-generic/termbits.h  */
+#define SIZE_OF_STRUCT_TERMIOS  0x2c
+
   /* Simply return if it had been initialized.  */
   if (record_tdep->size_pointer != 0)
     return;
@@ -1899,14 +1904,15 @@ ppc_init_linux_record_tdep (struct linux_record_tdep *record_tdep,
   /* These values are the second argument of system call "sys_ioctl".
      They are obtained from Linux Kernel source.
      See arch/powerpc/include/uapi/asm/ioctls.h.  */
-  record_tdep->ioctl_TCGETS = 0x403c7413;
-  record_tdep->ioctl_TCSETS = 0x803c7414;
-  record_tdep->ioctl_TCSETSW = 0x803c7415;
-  record_tdep->ioctl_TCSETSF = 0x803c7416;
   record_tdep->ioctl_TCGETA = 0x40147417;
   record_tdep->ioctl_TCSETA = 0x80147418;
   record_tdep->ioctl_TCSETAW = 0x80147419;
   record_tdep->ioctl_TCSETAF = 0x8014741c;
+  record_tdep->ioctl_TCGETS = 0x40007413 | (SIZE_OF_STRUCT_TERMIOS << 16);
+  record_tdep->ioctl_TCSETS = 0x80007414 | (SIZE_OF_STRUCT_TERMIOS << 16);
+  record_tdep->ioctl_TCSETSW = 0x80007415 | (SIZE_OF_STRUCT_TERMIOS << 16);
+  record_tdep->ioctl_TCSETSF = 0x80007416 | (SIZE_OF_STRUCT_TERMIOS << 16);
+
   record_tdep->ioctl_TCSBRK = 0x2000741d;
   record_tdep->ioctl_TCXONC = 0x2000741e;
   record_tdep->ioctl_TCFLSH = 0x2000741f;
-- 
2.31.1



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH ver 2] PowerPC, correct the gdb ioctl values for TCGETS, TCSETS, TCSETSW and TCSETSF.
  2022-06-08 17:43   ` [PATCH ver 2] " Carl Love
@ 2022-06-10 12:00     ` Ulrich Weigand
  0 siblings, 0 replies; 5+ messages in thread
From: Ulrich Weigand @ 2022-06-10 12:00 UTC (permalink / raw)
  To: gdb-patches, will_schmidt, cel

Carl Love <cel@us.ibm.com> wrote:

>PowerPC, correct the gdb ioctl values for TCGETS, TCSETS, TCSETSW and
>TCSETSF.

This version is OK.

Thanks,
Ulrich


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2022-06-10 12:00 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-08 16:37 [PATCH] PowerPC, correct the gdb ioctl values for TCGETS, TCSETS, TCSETSW and TCSETSF Carl Love
2022-06-08 16:59 ` Ulrich Weigand
2022-06-08 17:26   ` Carl Love
2022-06-08 17:43   ` [PATCH ver 2] " Carl Love
2022-06-10 12:00     ` Ulrich Weigand

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).