All of lore.kernel.org
 help / color / mirror / Atom feed
* Re: [PATCH libevl 1/2] tests: ptrace-sync: skip SOH and STX in pipe message
  2026-01-24 11:42 [PATCH libevl 1/2] tests: ptrace-sync: skip SOH and STX in pipe message Junxiao Chang
@ 2026-01-23 13:22 ` Philippe Gerum
  2026-01-24 11:42 ` [PATCH libevl 2/2] tests: ptrace-sync: only integrate ptrace-sync in debug build Junxiao Chang
  1 sibling, 0 replies; 5+ messages in thread
From: Philippe Gerum @ 2026-01-23 13:22 UTC (permalink / raw)
  To: Junxiao Chang; +Cc: xenomai, yuan1.wang

Junxiao Chang <junxiao.chang@intel.com> writes:

> Sometimes there might be SOH(Start of Heading) or STX(Start of
> Text) in be beginning of message. It needs to be skipped, or else
> regex function might return wrong result.

Thanks. A fix [1] addressing the same issue was merged into the -next
branch a couple of hours ago.

https://gitlab.com/Xenomai/xenomai4/libevl/-/commit/a8f7ef7fcfda7edcc1ca4cae9661e0395eeb4674

-- 
Philippe.

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

* Re: [PATCH libevl 2/2] tests: ptrace-sync: only integrate ptrace-sync in debug build
  2026-01-24 11:42 ` [PATCH libevl 2/2] tests: ptrace-sync: only integrate ptrace-sync in debug build Junxiao Chang
@ 2026-01-23 13:28   ` Philippe Gerum
  2026-01-26  0:15     ` Chang, Junxiao
  0 siblings, 1 reply; 5+ messages in thread
From: Philippe Gerum @ 2026-01-23 13:28 UTC (permalink / raw)
  To: Junxiao Chang; +Cc: xenomai, yuan1.wang

Junxiao Chang <junxiao.chang@intel.com> writes:

> ptrace-sync test case needs to load debug symbol in gdb. There is
> debug symbol in debug build. If buildtype is release, this case
> should not be integrated because it doesn't have debug symbol.
>

I don't think so, -g and the optimization level are unrelated in this
day and age (have been at some point though, many, many moons ago).

This is the output log of an x86 build for ptrace-sync.c with
--buildtype release passed to meson, -O2 and -g are both set.

[111/226] x86_64-blade-linux-gcc -m64 -march=nehalem -mtune=generic -mfpmath=sse -msse4.2 -fstack-protector-strong -O2 -D_FORTIFY_SOURCE=2 -Wformat -Wformat-security -Werror=format-security --sysroot=/var/lab/sdk/cpc/x86-corei7/blade-2025.10/sysroots/corei7-64-blade-linux -Itests/ptrace-sync.p -Itests -I../../../../git/xenomai/v4/libevl/tests -Iinclude -I../../../../git/xenomai/v4/libevl/include -I../../../../git/xenomai/v4/libevl/lib/arch/x86/include -fdiagnostics-color=always -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -Wextra -Wpedantic -Werror -std=gnu11 -O3 -pipe -Wstrict-aliasing -Wno-unused-parameter -Wno-pedantic -D_GNU_SOURCE -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -Wshadow=local -Wstrict-prototypes -Wmissing-prototypes -O2 -g -pthread -g -MD -MQ tests/ptrace-sync.p/ptrace-sync.c.o -MF tests/ptrace-sync.p/ptrace-sync.c.o.d -o tests/ptrace-sync.p/ptrace-sync.c.o -c ../../../../git/xenomai/v4/libevl/tests/ptrace-sync.c

~# file /usr/libexec/evl/tests/ptrace-sync 
/usr/libexec/evl/tests/ptrace-sync: ELF 64-bit LSB pie executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib/ld-linux-x86-64.so.2, BuildID[sha1]=7b1a13b097bccaf82b65d49b221ef8c0dd450887, for GNU/Linux 5.15.0, with debug_info, not stripped

Stripping the ptrace-sync executable may be the actual cause of the
issue.

-- 
Philippe.

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

* [PATCH libevl 1/2] tests: ptrace-sync: skip SOH and STX in pipe message
@ 2026-01-24 11:42 Junxiao Chang
  2026-01-23 13:22 ` Philippe Gerum
  2026-01-24 11:42 ` [PATCH libevl 2/2] tests: ptrace-sync: only integrate ptrace-sync in debug build Junxiao Chang
  0 siblings, 2 replies; 5+ messages in thread
From: Junxiao Chang @ 2026-01-24 11:42 UTC (permalink / raw)
  To: xenomai; +Cc: yuan1.wang, junxiao.chang

Sometimes there might be SOH(Start of Heading) or STX(Start of
Text) in be beginning of message. It needs to be skipped, or else
regex function might return wrong result.

This issue could be reproduced with gdb 15.0.50 in ubuntu 24.04.

Signed-off-by: Junxiao Chang <junxiao.chang@intel.com>
---
 tests/ptrace-sync.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/tests/ptrace-sync.c b/tests/ptrace-sync.c
index ec6fbb3..68ce353 100644
--- a/tests/ptrace-sync.c
+++ b/tests/ptrace-sync.c
@@ -40,6 +40,8 @@
  */
 
 #define CONCURRENCY  2
+#define SOH          1
+#define STX          2
 
 static struct evl_sem handshake;
 static struct evl_event barrier;
@@ -153,6 +155,7 @@ static int consume_and_match(FILE *fp, const char *expect, bool verbose)
 	int ret = EXIT_FAILURE;
 	char buf[BUFSIZ], *p;
 	regex_t re;
+	size_t len;
 
 	if (verbose)
 		fprintf(stderr, "EXPECT {{ %s }}\n", expect);
@@ -166,8 +169,14 @@ static int consume_and_match(FILE *fp, const char *expect, bool verbose)
 		alarm(0);
 
 		if (p) {
+			len = strlen(p);
+			if (len > 1 && (p[0] == SOH || p[0] == STX)) {
+				/* Ignore SOH(start of header) or STX(start of Text */
+				p++;
+				len--;
+			}
 			if (verbose) {
-				fprintf(stderr, "<- {{ \"%.*s\" }}\n", (int)(strlen(p) - 1), p);
+				fprintf(stderr, "<- {{ \"%.*s\" }}\n", (int)(len - 1), p);
 				fflush(stderr);
 			}
 			if (!regexec(&re, p, 0, NULL, 0)) {
-- 
2.43.0


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

* [PATCH libevl 2/2] tests: ptrace-sync: only integrate ptrace-sync in debug build
  2026-01-24 11:42 [PATCH libevl 1/2] tests: ptrace-sync: skip SOH and STX in pipe message Junxiao Chang
  2026-01-23 13:22 ` Philippe Gerum
@ 2026-01-24 11:42 ` Junxiao Chang
  2026-01-23 13:28   ` Philippe Gerum
  1 sibling, 1 reply; 5+ messages in thread
From: Junxiao Chang @ 2026-01-24 11:42 UTC (permalink / raw)
  To: xenomai; +Cc: yuan1.wang, junxiao.chang

ptrace-sync test case needs to load debug symbol in gdb. There is
debug symbol in debug build. If buildtype is release, this case
should not be integrated because it doesn't have debug symbol.

Signed-off-by: Junxiao Chang <junxiao.chang@intel.com>
---
 tests/meson.build | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/tests/meson.build b/tests/meson.build
index fb8b291..89e542f 100644
--- a/tests/meson.build
+++ b/tests/meson.build
@@ -64,7 +64,6 @@ test_programs = [
     'proxy-eventfd',
     'proxy-pipe',
     'proxy-poll',
-    'ptrace-sync',
     'rwlock-read',
     'rwlock-write',
     'sched-quota-accuracy',
@@ -80,6 +79,10 @@ test_programs = [
     'thread-mode-bits',
 ]
 
+if get_option('buildtype').startswith('debug')
+   test_programs += 'ptrace-sync'
+endif
+
 foreach t : test_programs
     x = executable(t, t + '.c',
     install : true,
-- 
2.43.0


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

* RE: [PATCH libevl 2/2] tests: ptrace-sync: only integrate ptrace-sync in debug build
  2026-01-23 13:28   ` Philippe Gerum
@ 2026-01-26  0:15     ` Chang, Junxiao
  0 siblings, 0 replies; 5+ messages in thread
From: Chang, Junxiao @ 2026-01-26  0:15 UTC (permalink / raw)
  To: Philippe Gerum; +Cc: xenomai@lists.linux.dev, Wang, Yuan1


Philippe Gerum <rpm@xenomai.org> wrote:
>Junxiao Chang <junxiao.chang@intel.com> writes:
>
>> ptrace-sync test case needs to load debug symbol in gdb. There is
>> debug symbol in debug build. If buildtype is release, this case should
>> not be integrated because it doesn't have debug symbol.
>>
>
>I don't think so, -g and the optimization level are unrelated in this day and age
>(have been at some point though, many, many moons ago).
>
>This is the output log of an x86 build for ptrace-sync.c with --buildtype release
>passed to meson, -O2 and -g are both set.
>
>[111/226] x86_64-blade-linux-gcc -m64 -march=nehalem -mtune=generic -
>mfpmath=sse -msse4.2 -fstack-protector-strong -O2 -D_FORTIFY_SOURCE=2 -
>Wformat -Wformat-security -Werror=format-security --
>sysroot=/var/lab/sdk/cpc/x86-corei7/blade-2025.10/sysroots/corei7-64-blade-
>linux -Itests/ptrace-sync.p -Itests -I../../../../git/xenomai/v4/libevl/tests -
>Iinclude -I../../../../git/xenomai/v4/libevl/include -
>I../../../../git/xenomai/v4/libevl/lib/arch/x86/include -fdiagnostics-color=always
>-D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -Wextra -Wpedantic -Werror -
>std=gnu11 -O3 -pipe -Wstrict-aliasing -Wno-unused-parameter -Wno-pedantic -
>D_GNU_SOURCE -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -Wshadow=local
>-Wstrict-prototypes -Wmissing-prototypes -O2 -g -pthread -g -MD -MQ
>tests/ptrace-sync.p/ptrace-sync.c.o -MF tests/ptrace-sync.p/ptrace-sync.c.o.d -
>o tests/ptrace-sync.p/ptrace-sync.c.o -
>c ../../../../git/xenomai/v4/libevl/tests/ptrace-sync.c
>
>~# file /usr/libexec/evl/tests/ptrace-sync
>/usr/libexec/evl/tests/ptrace-sync: ELF 64-bit LSB pie executable, x86-64,
>version 1 (SYSV), dynamically linked, interpreter /lib/ld-linux-x86-64.so.2,
>BuildID[sha1]=7b1a13b097bccaf82b65d49b221ef8c0dd450887, for GNU/Linux
>5.15.0, with debug_info, not stripped
>
>Stripping the ptrace-sync executable may be the actual cause of the issue.
>
>--
>Philippe.

My OS is ubuntu 24.04, kernel is latest xenomai 6.18.2. With " -Dbuildtype=release", there is no debug symbol after installing, and the test case failed(with next branch, "remove gdb prompt escape" fix integrated):

intel@intel-NUC13ANHi5:~/code/libevl/build$ readelf --debug-dump=info /usr/libexec/evl/tests/ptrace-sync
intel@intel-NUC13ANHi5:~/code/libevl/build$ sudo /usr/libexec/evl/tests/ptrace-sync
intel@intel-NUC13ANHi5:~/code/libevl/build$ echo $?
1

With "-Dbuildtype=debug" or no buildtype definition, there is debug symbol info. Test case could pass:

intel@intel-NUC13ANHi5:~/code/libevl/build$ readelf --debug-dump=info /usr/libexec/evl/tests/ptrace-sync | more
Contents of the .debug_info section:

  Compilation Unit @ offset 0:
   Length:        0x23d2 (32-bit)
   Version:       5
   Unit Type:     DW_UT_compile (1)
   Abbrev Offset: 0
   Pointer Size:  8
 <0><c>: Abbrev Number: 61 (DW_TAG_compile_unit)
    <d>   DW_AT_producer    : (indirect string, offset: 0x1d7): GNU C11 13.3.0 -mtune=generic -march=x86-64 -g -O2 -std=gnu11 -fasynchronous-unwind-tables -fstack-protector-strong -fstack-clash-protection -
fcf-protection
    <11>   DW_AT_language    : 29       (C11)
    <12>   DW_AT_name        : (indirect line string, offset: 0): ../tests/ptrace-sync.c
...

intel@intel-NUC13ANHi5:~/code/libevl/build$ sudo /usr/libexec/evl/tests/ptrace-sync
intel@intel-NUC13ANHi5:~/code/libevl/build$ echo $?
0

Maybe as you mentioned, debug symbol is stripped during installation.
Thanks,
Junxiao

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

end of thread, other threads:[~2026-01-26  0:15 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-01-24 11:42 [PATCH libevl 1/2] tests: ptrace-sync: skip SOH and STX in pipe message Junxiao Chang
2026-01-23 13:22 ` Philippe Gerum
2026-01-24 11:42 ` [PATCH libevl 2/2] tests: ptrace-sync: only integrate ptrace-sync in debug build Junxiao Chang
2026-01-23 13:28   ` Philippe Gerum
2026-01-26  0:15     ` Chang, Junxiao

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.