tests: ptrace-sync: skip SOH and STX in pipe message
PATCH 1/2 tests: ptrace-sync: skip SOH and STX in pipe message
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.
--- tests/ptrace-sync.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-)
tests/ptrace-sync.c +10 -1
@@ -40,6 +40,8 @@*/ #define CONCURRENCY 2 +#define SOH 1 +#define STX 2static 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 )) {
Signature · 1 line
2.43.0
PATCH 2/2 tests: ptrace-sync: only integrate ptrace-sync in debug build
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.
--- tests/meson.build | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
tests/meson.build +4 -1
@@ -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,
Signature · 1 line
2.43.0
Re: [PATCH libevl 2/2] tests: ptrace-sync: only integrate ptrace-sync in debug build
Quoted 4 lines · 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.
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.
Signature · 1 line
Philippe.
RE: [PATCH libevl 2/2] tests: ptrace-sync: only integrate ptrace-sync in debug build
Quoted 34 lines · Philippe Gerum
Quoted 4 lines · 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.
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.cwith --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 -MQtests/ptrace-sync.p/ptrace-sync.c.o-MF tests/ptrace-sync.p/ptrace-sync.c.o.d -
otests/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, withdebug_info, not stripped
Quoted 4 lines
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
Quoted 3 lines · 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.
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
Signature · 1 line
Philippe.