Re: [PATCH v2 0/3] Support --enable-newlib-reent-thread-local Newlib configuration option

2022-07-21 Thread Sebastian Huber



On 21.07.22 10:36, Chris Johns wrote:

On 21/7/2022 6:30 pm, Sebastian Huber wrote:

On 21.07.22 10:27, Chris Johns wrote:

On 21/7/2022 6:21 pm, Sebastian Huber wrote:

On 21.07.22 10:16, Chris Johns wrote:

On 21/7/2022 6:11 pm, Sebastian Huber wrote:

On 21.07.22 10:03, Chris Johns wrote:

As an aside, does gdb know about TLS variables and so will `errno` be
visible?

Good question, there seems to be some support missing. For example for
arm/xilinx_zynq_a9_qemu:

Breakpoint 7, Init (ignored=2118804) at
/home/EB/sebastian_h/src/rtems/testsuites/samples/fileio/init.c:1169
1169  TEST_BEGIN();
(gdb) watch _tls_errno
Cannot find thread-local variables on this target
(gdb) p _tls_errno
Cannot find thread-local variables on this target

I wonder if we need to configure gdb so it understands how we handle TLS
variables?

It could be a Qemu issue. In GDB there is a

    /* Check for the TLS register feature.  */
    feature = tdesc_find_feature (tdesc, "org.gnu.gdb.arm.tls");

However, this is not provided by Qemu.

Is this something in the remote protocol? I would have thought the ABI would
define the register?

Yes, I guess this is a part of the machine description provided by the server
(Qemu). This stuff seems to be quite new (from 2022) added by John Baldwin for
FreeBSD.

That would only apply if qemu was providing the XML description and it is not
normally something I have seen. Most of time the built in XML is used.

The only packet I could see in a quick look at the protocol is offsets for TLS
variables for dynamically loaded object files. This is needed because the link
editor allocates the variables when relocating.


Maybe this feature is not included in GDB 12 and earlier?

--
embedded brains GmbH
Herr Sebastian HUBER
Dornierstr. 4
82178 Puchheim
Germany
email: sebastian.hu...@embedded-brains.de
phone: +49-89-18 94 741 - 16
fax:   +49-89-18 94 741 - 08

Registergericht: Amtsgericht München
Registernummer: HRB 157899
Vertretungsberechtigte Geschäftsführer: Peter Rasmussen, Thomas Dörfler
Unsere Datenschutzerklärung finden Sie hier:
https://embedded-brains.de/datenschutzerklaerung/
___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel

Re: [PATCH v2 0/3] Support --enable-newlib-reent-thread-local Newlib configuration option

2022-07-21 Thread Chris Johns
On 21/7/2022 6:30 pm, Sebastian Huber wrote:
> On 21.07.22 10:27, Chris Johns wrote:
>> On 21/7/2022 6:21 pm, Sebastian Huber wrote:
>>> On 21.07.22 10:16, Chris Johns wrote:
 On 21/7/2022 6:11 pm, Sebastian Huber wrote:
> On 21.07.22 10:03, Chris Johns wrote:
>> As an aside, does gdb know about TLS variables and so will `errno` be
>> visible?
> Good question, there seems to be some support missing. For example for
> arm/xilinx_zynq_a9_qemu:
>
> Breakpoint 7, Init (ignored=2118804) at
> /home/EB/sebastian_h/src/rtems/testsuites/samples/fileio/init.c:1169
> 1169  TEST_BEGIN();
> (gdb) watch _tls_errno
> Cannot find thread-local variables on this target
> (gdb) p _tls_errno
> Cannot find thread-local variables on this target
 I wonder if we need to configure gdb so it understands how we handle TLS
 variables?
>>> It could be a Qemu issue. In GDB there is a
>>>
>>>    /* Check for the TLS register feature.  */
>>>    feature = tdesc_find_feature (tdesc, "org.gnu.gdb.arm.tls");
>>>
>>> However, this is not provided by Qemu.
>> Is this something in the remote protocol? I would have thought the ABI would
>> define the register?
> 
> Yes, I guess this is a part of the machine description provided by the server
> (Qemu). This stuff seems to be quite new (from 2022) added by John Baldwin for
> FreeBSD.

That would only apply if qemu was providing the XML description and it is not
normally something I have seen. Most of time the built in XML is used.

The only packet I could see in a quick look at the protocol is offsets for TLS
variables for dynamically loaded object files. This is needed because the link
editor allocates the variables when relocating.

Chris
___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel

Re: [PATCH v2 0/3] Support --enable-newlib-reent-thread-local Newlib configuration option

2022-07-21 Thread Sebastian Huber



On 21.07.22 10:27, Chris Johns wrote:

On 21/7/2022 6:21 pm, Sebastian Huber wrote:

On 21.07.22 10:16, Chris Johns wrote:

On 21/7/2022 6:11 pm, Sebastian Huber wrote:

On 21.07.22 10:03, Chris Johns wrote:

As an aside, does gdb know about TLS variables and so will `errno` be visible?

Good question, there seems to be some support missing. For example for
arm/xilinx_zynq_a9_qemu:

Breakpoint 7, Init (ignored=2118804) at
/home/EB/sebastian_h/src/rtems/testsuites/samples/fileio/init.c:1169
1169  TEST_BEGIN();
(gdb) watch _tls_errno
Cannot find thread-local variables on this target
(gdb) p _tls_errno
Cannot find thread-local variables on this target

I wonder if we need to configure gdb so it understands how we handle TLS
variables?

It could be a Qemu issue. In GDB there is a

   /* Check for the TLS register feature.  */
   feature = tdesc_find_feature (tdesc, "org.gnu.gdb.arm.tls");

However, this is not provided by Qemu.

Is this something in the remote protocol? I would have thought the ABI would
define the register?


Yes, I guess this is a part of the machine description provided by the 
server (Qemu). This stuff seems to be quite new (from 2022) added by 
John Baldwin for FreeBSD.


--
embedded brains GmbH
Herr Sebastian HUBER
Dornierstr. 4
82178 Puchheim
Germany
email: sebastian.hu...@embedded-brains.de
phone: +49-89-18 94 741 - 16
fax:   +49-89-18 94 741 - 08

Registergericht: Amtsgericht München
Registernummer: HRB 157899
Vertretungsberechtigte Geschäftsführer: Peter Rasmussen, Thomas Dörfler
Unsere Datenschutzerklärung finden Sie hier:
https://embedded-brains.de/datenschutzerklaerung/
___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel

Re: [PATCH v2 0/3] Support --enable-newlib-reent-thread-local Newlib configuration option

2022-07-21 Thread Chris Johns
On 21/7/2022 6:21 pm, Sebastian Huber wrote:
> On 21.07.22 10:16, Chris Johns wrote:
>> On 21/7/2022 6:11 pm, Sebastian Huber wrote:
>>> On 21.07.22 10:03, Chris Johns wrote:
 As an aside, does gdb know about TLS variables and so will `errno` be 
 visible?
>>> Good question, there seems to be some support missing. For example for
>>> arm/xilinx_zynq_a9_qemu:
>>>
>>> Breakpoint 7, Init (ignored=2118804) at
>>> /home/EB/sebastian_h/src/rtems/testsuites/samples/fileio/init.c:1169
>>> 1169  TEST_BEGIN();
>>> (gdb) watch _tls_errno
>>> Cannot find thread-local variables on this target
>>> (gdb) p _tls_errno
>>> Cannot find thread-local variables on this target
>> I wonder if we need to configure gdb so it understands how we handle TLS
>> variables?
> 
> It could be a Qemu issue. In GDB there is a
> 
>   /* Check for the TLS register feature.  */
>   feature = tdesc_find_feature (tdesc, "org.gnu.gdb.arm.tls");
> 
> However, this is not provided by Qemu.

Is this something in the remote protocol? I would have thought the ABI would
define the register?

Chris
___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel

Re: [PATCH v2 0/3] Support --enable-newlib-reent-thread-local Newlib configuration option

2022-07-21 Thread Sebastian Huber

On 21.07.22 10:16, Chris Johns wrote:

On 21/7/2022 6:11 pm, Sebastian Huber wrote:

On 21.07.22 10:03, Chris Johns wrote:

As an aside, does gdb know about TLS variables and so will `errno` be visible?

Good question, there seems to be some support missing. For example for
arm/xilinx_zynq_a9_qemu:

Breakpoint 7, Init (ignored=2118804) at
/home/EB/sebastian_h/src/rtems/testsuites/samples/fileio/init.c:1169
1169  TEST_BEGIN();
(gdb) watch _tls_errno
Cannot find thread-local variables on this target
(gdb) p _tls_errno
Cannot find thread-local variables on this target

I wonder if we need to configure gdb so it understands how we handle TLS 
variables?


It could be a Qemu issue. In GDB there is a

  /* Check for the TLS register feature.  */
  feature = tdesc_find_feature (tdesc, "org.gnu.gdb.arm.tls");

However, this is not provided by Qemu.

--
embedded brains GmbH
Herr Sebastian HUBER
Dornierstr. 4
82178 Puchheim
Germany
email: sebastian.hu...@embedded-brains.de
phone: +49-89-18 94 741 - 16
fax:   +49-89-18 94 741 - 08

Registergericht: Amtsgericht München
Registernummer: HRB 157899
Vertretungsberechtigte Geschäftsführer: Peter Rasmussen, Thomas Dörfler
Unsere Datenschutzerklärung finden Sie hier:
https://embedded-brains.de/datenschutzerklaerung/
___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel

Re: [PATCH v2 0/3] Support --enable-newlib-reent-thread-local Newlib configuration option

2022-07-21 Thread Chris Johns
On 21/7/2022 6:11 pm, Sebastian Huber wrote:
> On 21.07.22 10:03, Chris Johns wrote:
>> As an aside, does gdb know about TLS variables and so will `errno` be 
>> visible?
> 
> Good question, there seems to be some support missing. For example for
> arm/xilinx_zynq_a9_qemu:
> 
> Breakpoint 7, Init (ignored=2118804) at
> /home/EB/sebastian_h/src/rtems/testsuites/samples/fileio/init.c:1169
> 1169  TEST_BEGIN();
> (gdb) watch _tls_errno
> Cannot find thread-local variables on this target
> (gdb) p _tls_errno
> Cannot find thread-local variables on this target

I wonder if we need to configure gdb so it understands how we handle TLS 
variables?

Chris
___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel

Re: [PATCH v2 0/3] Support --enable-newlib-reent-thread-local Newlib configuration option

2022-07-21 Thread Sebastian Huber

On 21.07.22 10:03, Chris Johns wrote:

As an aside, does gdb know about TLS variables and so will `errno` be visible?


Good question, there seems to be some support missing. For example for 
arm/xilinx_zynq_a9_qemu:


Breakpoint 7, Init (ignored=2118804) at 
/home/EB/sebastian_h/src/rtems/testsuites/samples/fileio/init.c:1169

1169  TEST_BEGIN();
(gdb) watch _tls_errno
Cannot find thread-local variables on this target
(gdb) p _tls_errno
Cannot find thread-local variables on this target

--
embedded brains GmbH
Herr Sebastian HUBER
Dornierstr. 4
82178 Puchheim
Germany
email: sebastian.hu...@embedded-brains.de
phone: +49-89-18 94 741 - 16
fax:   +49-89-18 94 741 - 08

Registergericht: Amtsgericht München
Registernummer: HRB 157899
Vertretungsberechtigte Geschäftsführer: Peter Rasmussen, Thomas Dörfler
Unsere Datenschutzerklärung finden Sie hier:
https://embedded-brains.de/datenschutzerklaerung/
___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel

Re: [PATCH v2 0/3] Support --enable-newlib-reent-thread-local Newlib configuration option

2022-07-21 Thread Chris Johns
+1

Really great patch and change. I think the performance improvements will be
excellent.

As an aside, does gdb know about TLS variables and so will `errno` be visible?

Chris

On 21/7/2022 5:09 pm, Sebastian Huber wrote:
> This patch set adds support for the --enable-newlib-reent-thread-local
> (_REENT_THREAD_LOCAL_STORAGE) Newlib configuration option.
> 
> By default, Newlib uses a huge object of type struct _reent to store
> thread-specific data.  This object is returned by __getreent() if the
> __DYNAMIC_REENT__ Newlib configuration option is defined.
>   
> The reentrancy structure contains for example errno and the standard input,
> output, and error file streams.  This means that if an application only uses
> errno it has a dependency on the file stream support even if it does not use
> it.  This is an issue for lower end targets and applications which need to
> qualify the software according to safety standards (for example ECSS-E-ST-40C,
> ECSS-Q-ST-80C, IEC 61508, ISO 26262, DO-178, DO-330, DO-333).
>   
> If the new _REENT_THREAD_LOCAL configuration option is enabled, then struct
> _reent is replaced by dedicated thread-local objects for each struct _reent
> member.  The thread-local objects are defined in translation units which use
> the corresponding object.
> 
> v2:
> 
> * Remove i386, microblaze, and m68k from default enabled list.
> 
> * Support --with-newlib-tls and --without-newlib-tls.
> 
> Sebastian Huber (3):
>   6/7: Update Newlib
>   newlib: Support --with/without-newlib-tls
>   6/7: Use TLS in Newlib for some targets by default
> 
>  rtems/config/6/rtems-aarch64.bset |  1 +
>  rtems/config/6/rtems-arm.bset |  1 +
>  rtems/config/6/rtems-nios2.bset   |  1 +
>  rtems/config/6/rtems-powerpc.bset |  1 +
>  rtems/config/6/rtems-riscv.bset   |  1 +
>  rtems/config/6/rtems-sparc.bset   |  1 +
>  rtems/config/7/rtems-aarch64.bset |  1 +
>  rtems/config/7/rtems-arm.bset |  1 +
>  rtems/config/7/rtems-nios2.bset   |  1 +
>  rtems/config/7/rtems-powerpc.bset |  1 +
>  rtems/config/7/rtems-riscv.bset   |  1 +
>  rtems/config/7/rtems-sparc.bset   |  1 +
>  .../config/tools/rtems-gcc-10-newlib-head.cfg |  4 +--
>  .../tools/rtems-gcc-10.4-newlib-head.cfg  | 27 +++
>  .../config/tools/rtems-gcc-12-newlib-head.cfg |  5 ++--
>  .../tools/rtems-gcc-head-newlib-head.cfg  |  4 +--
>  source-builder/config/checks.cfg  |  9 +++
>  source-builder/config/gcc-common-1.cfg|  1 +
>  18 files changed, 55 insertions(+), 7 deletions(-)
>  create mode 100644 rtems/config/tools/rtems-gcc-10.4-newlib-head.cfg
> 
___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


[PATCH v2 0/3] Support --enable-newlib-reent-thread-local Newlib configuration option

2022-07-21 Thread Sebastian Huber
This patch set adds support for the --enable-newlib-reent-thread-local
(_REENT_THREAD_LOCAL_STORAGE) Newlib configuration option.

By default, Newlib uses a huge object of type struct _reent to store
thread-specific data.  This object is returned by __getreent() if the
__DYNAMIC_REENT__ Newlib configuration option is defined.
  
The reentrancy structure contains for example errno and the standard input,
output, and error file streams.  This means that if an application only uses
errno it has a dependency on the file stream support even if it does not use
it.  This is an issue for lower end targets and applications which need to
qualify the software according to safety standards (for example ECSS-E-ST-40C,
ECSS-Q-ST-80C, IEC 61508, ISO 26262, DO-178, DO-330, DO-333).
  
If the new _REENT_THREAD_LOCAL configuration option is enabled, then struct
_reent is replaced by dedicated thread-local objects for each struct _reent
member.  The thread-local objects are defined in translation units which use
the corresponding object.

v2:

* Remove i386, microblaze, and m68k from default enabled list.

* Support --with-newlib-tls and --without-newlib-tls.

Sebastian Huber (3):
  6/7: Update Newlib
  newlib: Support --with/without-newlib-tls
  6/7: Use TLS in Newlib for some targets by default

 rtems/config/6/rtems-aarch64.bset |  1 +
 rtems/config/6/rtems-arm.bset |  1 +
 rtems/config/6/rtems-nios2.bset   |  1 +
 rtems/config/6/rtems-powerpc.bset |  1 +
 rtems/config/6/rtems-riscv.bset   |  1 +
 rtems/config/6/rtems-sparc.bset   |  1 +
 rtems/config/7/rtems-aarch64.bset |  1 +
 rtems/config/7/rtems-arm.bset |  1 +
 rtems/config/7/rtems-nios2.bset   |  1 +
 rtems/config/7/rtems-powerpc.bset |  1 +
 rtems/config/7/rtems-riscv.bset   |  1 +
 rtems/config/7/rtems-sparc.bset   |  1 +
 .../config/tools/rtems-gcc-10-newlib-head.cfg |  4 +--
 .../tools/rtems-gcc-10.4-newlib-head.cfg  | 27 +++
 .../config/tools/rtems-gcc-12-newlib-head.cfg |  5 ++--
 .../tools/rtems-gcc-head-newlib-head.cfg  |  4 +--
 source-builder/config/checks.cfg  |  9 +++
 source-builder/config/gcc-common-1.cfg|  1 +
 18 files changed, 55 insertions(+), 7 deletions(-)
 create mode 100644 rtems/config/tools/rtems-gcc-10.4-newlib-head.cfg

-- 
2.35.3

___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel