Package: gdb Version: 12.1-4 Severity: minor X-Debbugs-Cc: msl0000023...@gmail.com
Hello. The issue happens when I specific a return value to the 'return' command in gdb(1), in order to return from a shared library function with my specified return value. The following example uses function geteuid(2) from libc.so.6: root@debian:~/src# cat rval-test.c #include <unistd.h> #include <stdio.h> int main() { while(1) { printf("geteuid returned %u\n", (unsigned int)geteuid()); sleep(1); } } root@debian:~/src# gcc -Wall -g rval-test.c -o rval-test root@debian:~/src# gdb rval-test GNU gdb (Debian 12.1-4) 12.1 Copyright (C) 2022 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html> This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Type "show copying" and "show warranty" for details. This GDB was configured as "powerpc64le-linux-gnu". Type "show configuration" for configuration details. For bug reporting instructions, please see: <https://www.gnu.org/software/gdb/bugs/>. Find the GDB manual and other documentation resources online at: <http://www.gnu.org/software/gdb/documentation/>. For help, type "help". Type "apropos word" to search for commands related to "word"... Reading symbols from rval-test... (gdb) b geteuid Breakpoint 1 at 0x960 (gdb) r Starting program: /root/src/rval-test [Thread debugging using libthread_db enabled] Using host libthread_db library "/lib/powerpc64le-linux-gnu/libthread_db.so.1". Breakpoint 1, 0x00007ffff7e12ea0 in __GI_geteuid () at ../sysdeps/unix/syscall-template.S:91 91 ../sysdeps/unix/syscall-template.S: No such file or directory. (gdb) c Continuing. geteuid returned 0 Breakpoint 1, 0x00007ffff7e12ea0 in __GI_geteuid () at ../sysdeps/unix/syscall-template.S:91 91 in ../sysdeps/unix/syscall-template.S (gdb) return 111111 Make __GI_geteuid return now? (y or n) y #0 0x00000001000008dc in main () at rval-test.c:6 6 printf("geteuid returned %u\n", (unsigned int)geteuid()); (gdb) c Continuing. geteuid returned 0 Breakpoint 1, 0x00007ffff7e12ea0 in __GI_geteuid () at ../sysdeps/unix/syscall-template.S:91 91 ../sysdeps/unix/syscall-template.S: No such file or directory. (gdb) return (uint32_t)111111 Make __GI_geteuid return now? (y or n) y #0 0x00000001000008dc in main () at rval-test.c:6 6 printf("geteuid returned %u\n", (unsigned int)geteuid()); (gdb) c Continuing. geteuid returned 0 As shown in this example, I'm trying to make this function to return 111111 instead, but this didn't work. Manually changing the register for return value (r3) worked: Breakpoint 1, 0x00007ffff7e12ea0 in __GI_geteuid () at ../sysdeps/unix/syscall-template.S:91 91 ../sysdeps/unix/syscall-template.S: No such file or directory. (gdb) p $r3 $1 = 0 (gdb) p $r3 = (uint32_t)111111 $2 = 111111 (gdb) return Make __GI_geteuid return now? (y or n) y #0 0x00000001000008dc in main () at rval-test.c:6 6 printf("geteuid returned %u\n", (unsigned int)geteuid()); (gdb) c Continuing. geteuid returned 111111 ... So this method could be used as a workaround. -- System Information: Debian Release: bookworm/sid APT prefers unstable APT policy: (500, 'unstable') Architecture: ppc64el (ppc64le) Kernel: Linux 5.4.0-113-generic (SMP w/128 CPU threads) Kernel taint flags: TAINT_PROPRIETARY_MODULE, TAINT_OOT_MODULE, TAINT_UNSIGNED_MODULE Locale: LANG=C, LC_CTYPE=C.UTF-8 (charmap=UTF-8), LANGUAGE=zh_TW:zh_CN:en_GB:en_US Shell: /bin/sh linked to /usr/bin/dash Init: unable to detect Versions of packages gdb depends on: ii libbabeltrace1 1.5.8-2+b2 ii libc6 2.35-3 ii libdebuginfod1 0.187-1 ii libexpat1 2.4.8-1 ii libgcc-s1 12.1.0-7 ii libgmp10 2:6.2.1+dfsg1-1 ii liblzma5 5.2.5-2.1 ii libmpfr6 4.1.0-3 ii libncursesw6 6.3+20220423-2 ii libpython3.10 3.10.5-1 ii libreadline8 8.1.2-1.2 ii libsource-highlight4v5 3.1.9-4.1+b1 ii libstdc++6 12.1.0-7 ii libtinfo6 6.3+20220423-2 ii libxxhash0 0.8.1-1 ii zlib1g 1:1.2.11.dfsg-4 Versions of packages gdb recommends: ii libc6-dbg [libc-dbg] 2.35-3 Versions of packages gdb suggests: pn gdb-doc <none> pn gdbserver <none> -- no debconf information