The debugger plugin closes the debugging section if you try to do a [Step in] to any **glibc** sys function. **GDB** throws an exception with "No such file or directory." and the debugging section is then stopped or closed.
We need a way to pass to the debugger plugin where the source code of **glibc** is, so no exception is raised.
**Example:**
``` GNU gdb (Ubuntu 8.1.1-0ubuntu1) 8.1.1 Copyright (C) 2018 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 "x86_64-linux-gnu". Type "show configuration" for configuration details. For bug reporting instructions, please see: http://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 ./minicom...done. (gdb) b 77 Breakpoint 1 at 0x5365: file minicom.c, line 77. (gdb) s The program is not being run. (gdb) run Starting program: /apps/minicom-2.7.1/debian/minicom/usr/bin/minicom -D /dev/ttyUSB1 Lockfile is stale. Overriding it..
Breakpoint 1, port_init () at minicom.c:77 77 m_setparms(portfd, P_BAUDRATE, P_PARITY, P_BITS, P_STOPB, (gdb) s 78 P_HASRTS[0] == 'Y', P_HASXON[0] == 'Y'); (gdb) s 77 m_setparms(portfd, P_BAUDRATE, P_PARITY, P_BITS, P_STOPB, (gdb) s m_setparms (fd=3, baudr=0x5555557866e0 <mpars+4032> "1500000", par=0x555555786800 <mpars+4320> "N", bits=0x555555786770 <mpars+4176> "8", stopb=0x555555786890 <mpars+4464> "1", hwf=1, swf=0) at sysdep1.c:396 396 { (gdb) s 397 int spd = -1; (gdb) s 399 int bit = bits[0]; (gdb) s 408 if (portfd_is_socket) (gdb) s 413 tcgetattr(fd, &tty); (gdb) s __GI___tcgetattr (fd=3, termios_p=0x7fffffffde30) at ../sysdeps/unix/sysv/linux/tcgetattr.c:34 34 ../sysdeps/unix/sysv/linux/tcgetattr.c: No such file or directory. (gdb) s 38 in ../sysdeps/unix/sysv/linux/tcgetattr.c (gdb) s 34 in ../sysdeps/unix/sysv/linux/tcgetattr.c (gdb) s 38 in ../sysdeps/unix/sysv/linux/tcgetattr.c (gdb) s 40 in ../sysdeps/unix/sysv/linux/tcgetattr.c (gdb) s 46 in ../sysdeps/unix/sysv/linux/tcgetattr.c (gdb) s 63 in ../sysdeps/unix/sysv/linux/tcgetattr.c (gdb) s 42 in ../sysdeps/unix/sysv/linux/tcgetattr.c (gdb) s 63 in ../sysdeps/unix/sysv/linux/tcgetattr.c (gdb) s 42 in ../sysdeps/unix/sysv/linux/tcgetattr.c (gdb) n Warning: Cannot insert breakpoint 0. Cannot access memory at address 0x1ec4635941ad2a3e
__longjmp () at ../sysdeps/x86_64/__longjmp.S:45 45 ../sysdeps/x86_64/__longjmp.S: No such file or directory. (gdb) ```
With **GDB** you can pass a parameter informing where to search for glibc source code, here is how:
_-d "directory to search"_
**sudo gdb -d /apps/libc6/glibc-2.27/stamp-dir --args ./minicom -D /dev/ttyUSB1** ``` GNU gdb (Ubuntu 8.1.1-0ubuntu1) 8.1.1 Copyright (C) 2018 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 "x86_64-linux-gnu". Type "show configuration" for configuration details. For bug reporting instructions, please see: http://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 ./minicom...done. (gdb) show directories Source directories searched: /apps/libc6/glibc-2.27/stamp-dir:$cdir:$cwd (gdb) b 77 Breakpoint 1 at 0x5365: file minicom.c, line 77. (gdb) run Starting program: /apps/minicom-2.7.1/debian/minicom/usr/bin/minicom -D /dev/ttyUSB1 Lockfile is stale. Overriding it..
Breakpoint 1, port_init () at minicom.c:77 77 m_setparms(portfd, P_BAUDRATE, P_PARITY, P_BITS, P_STOPB, (gdb) s 78 P_HASRTS[0] == 'Y', P_HASXON[0] == 'Y'); (gdb) s 77 m_setparms(portfd, P_BAUDRATE, P_PARITY, P_BITS, P_STOPB, (gdb) s m_setparms (fd=3, baudr=0x5555557866e0 <mpars+4032> "1500000", par=0x555555786800 <mpars+4320> "N", bits=0x555555786770 <mpars+4176> "8", stopb=0x555555786890 <mpars+4464> "1", hwf=1, swf=0) at sysdep1.c:396 396 { (gdb) s 397 int spd = -1; (gdb) s 399 int bit = bits[0]; (gdb) s 408 if (portfd_is_socket) (gdb) s 413 tcgetattr(fd, &tty); (gdb) s __GI___tcgetattr (fd=3, termios_p=0x7fffffffde10) at ../sysdeps/unix/sysv/linux/tcgetattr.c:34 34 { (gdb) s 38 retval = INLINE_SYSCALL (ioctl, 3, fd, TCGETS, &k_termios); (gdb) s 34 { (gdb) info source Current source file is ../sysdeps/unix/sysv/linux/tcgetattr.c Compilation directory is /build/glibc-CVJwZb/glibc-2.27/termios Located in /apps/libc6/glibc-2.27/sysdeps/unix/sysv/linux/tcgetattr.c Contains 80 lines. Source language is c. Producer is GNU C11 7.5.0 -mtune=generic -march=x86-64 -g -O2 -O3 -std=gnu11 -fgnu89-inline -fmerge-all-constants -frounding-math -fstack-protector-strong -fPIC -ftls-model=initial-exec -fstack-protector-strong. Compiled with DWARF 2 debugging format. Does not include preprocessor macro info. (gdb)
```
I think there must be a way to tell **the debugger plugin** to pass the directory to search, so the debugging section is not closed. I am still searching if is not possible to export a variable previous to debug with Geany to bypass the error.
Still have a problem with **GDB**:
``` (gdb) s Warning: Cannot insert breakpoint 0. Cannot access memory at address 0x65b6610c33ccef17
__longjmp () at ../sysdeps/x86_64/__longjmp.S:45 45 LIBC_PROBE (longjmp, 3, LP_SIZE@%RDI_LP, -4@%esi, LP_SIZE@%RDX_LP) (gdb) s __longjmp () at ../sysdeps/x86_64/__longjmp.S:56 56 movq (JB_RBX*8)(%rdi),%rbx (gdb) s 57 movq (JB_R12*8)(%rdi),%r12 (gdb) s 58 movq (JB_R13*8)(%rdi),%r13 (gdb) s 59 movq (JB_R14*8)(%rdi),%r14 (gdb) s 60 movq (JB_R15*8)(%rdi),%r15 (gdb) s 62 mov %esi, %eax (gdb) s 63 mov %R8_LP,%RSP_LP (gdb) s 64 movq %r9,%rbp (gdb) s 65 LIBC_PROBE (longjmp_target, 3, (gdb) s 67 jmpq *%rdx (gdb) s
Program received signal SIGSEGV, Segmentation fault. __longjmp () at ../sysdeps/x86_64/__longjmp.S:67 67 jmpq *%rdx (gdb) s
Program terminated with signal SIGSEGV, Segmentation fault. The program no longer exists.
```
The breakpoint is set to line 77, file minicom.c. excerpt:
/* Initialize modem port. */ void port_init(void) { **<line 77 >** m_setparms(portfd, P_BAUDRATE, P_PARITY, P_BITS, P_STOPB, **<line 78 >** P_HASRTS[0] == 'Y', P_HASXON[0] == 'Y'); }
**Complete debug session:**
sudo gdb -d /apps/libc6/glibc-2.27/stamp-dir --args . ./minicom -D /dev/ttyUSB1 ``` [sudo] password for alex: GNU gdb (Ubuntu 8.1.1-0ubuntu1) 8.1.1 Copyright (C) 2018 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 "x86_64-linux-gnu". Type "show configuration" for configuration details. For bug reporting instructions, please see: http://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 ./minicom...done. (gdb) b 77 Breakpoint 1 at 0x5365: file minicom.c, line 77. (gdb) run Starting program: /apps/minicom-2.7.1/debian/minicom/usr/bin/minicom -D /dev/ttyUSB1 Lockfile is stale. Overriding it..
Breakpoint 1, port_init () at minicom.c:77 77 m_setparms(portfd, P_BAUDRATE, P_PARITY, P_BITS, P_STOPB, (gdb) s 78 P_HASRTS[0] == 'Y', P_HASXON[0] == 'Y'); (gdb) s 77 m_setparms(portfd, P_BAUDRATE, P_PARITY, P_BITS, P_STOPB, (gdb) s m_setparms (fd=3, baudr=0x5555557866e0 <mpars+4032> "1500000", par=0x555555786800 <mpars+4320> "N", bits=0x555555786770 <mpars+4176> "8", stopb=0x555555786890 <mpars+4464> "1", hwf=1, swf=0) at sysdep1.c:396 396 { (gdb) s 397 int spd = -1; (gdb) s 399 int bit = bits[0]; (gdb) s 408 if (portfd_is_socket) (gdb) s 413 tcgetattr(fd, &tty); (gdb) s __GI___tcgetattr (fd=3, termios_p=0x7fffffffde10) at ../sysdeps/unix/sysv/linux/tcgetattr.c:34 34 { (gdb) s 38 retval = INLINE_SYSCALL (ioctl, 3, fd, TCGETS, &k_termios); (gdb) s 34 { (gdb) s 38 retval = INLINE_SYSCALL (ioctl, 3, fd, TCGETS, &k_termios); (gdb) s 40 if (__glibc_likely (retval == 0)) (gdb) s 46 termios_p->c_line = k_termios.c_line; (gdb) s 63 memset (__mempcpy (&termios_p->c_cc[0], &k_termios.c_cc[0], (gdb) s 42 termios_p->c_iflag = k_termios.c_iflag; (gdb) s 63 memset (__mempcpy (&termios_p->c_cc[0], &k_termios.c_cc[0], (gdb) s 42 termios_p->c_iflag = k_termios.c_iflag; (gdb) s 46 termios_p->c_line = k_termios.c_line; (gdb) s 51 termios_p->c_ispeed = k_termios.c_cflag & (CBAUD | CBAUDEX); (gdb) s 63 memset (__mempcpy (&termios_p->c_cc[0], &k_termios.c_cc[0], (gdb) s 51 termios_p->c_ispeed = k_termios.c_cflag & (CBAUD | CBAUDEX); (gdb) s 58 termios_p->c_ospeed = k_termios.c_cflag & (CBAUD | CBAUDEX); (gdb) s 63 memset (__mempcpy (&termios_p->c_cc[0], &k_termios.c_cc[0], (gdb) s 77 } (gdb) s m_setparms (fd=3, baudr=0x5555557866e0 <mpars+4032> "1500000", par=0x555555786800 <mpars+4320> "N", bits=0x555555786770 <mpars+4176> "8", stopb=0x555555786890 <mpars+4464> "1", hwf=1, swf=0) at sysdep1.c:420 420 if (bit == '7' && (par[0] == 'M' || par[0] == 'S')) (gdb) s Warning: Cannot insert breakpoint 0. Cannot access memory at address 0x584724c9a6077db8
__longjmp () at ../sysdeps/x86_64/__longjmp.S:45 45 LIBC_PROBE (longjmp, 3, LP_SIZE@%RDI_LP, -4@%esi, LP_SIZE@%RDX_LP) (gdb) s __longjmp () at ../sysdeps/x86_64/__longjmp.S:56 56 movq (JB_RBX*8)(%rdi),%rbx (gdb) s 57 movq (JB_R12*8)(%rdi),%r12 (gdb) s 58 movq (JB_R13*8)(%rdi),%r13 (gdb) s 59 movq (JB_R14*8)(%rdi),%r14 (gdb) s 60 movq (JB_R15*8)(%rdi),%r15 (gdb) s 62 mov %esi, %eax (gdb) s 63 mov %R8_LP,%RSP_LP (gdb) s 64 movq %r9,%rbp (gdb) s 65 LIBC_PROBE (longjmp_target, 3, (gdb) s 67 jmpq *%rdx (gdb) s
Program received signal SIGSEGV, Segmentation fault. __longjmp () at ../sysdeps/x86_64/__longjmp.S:67 67 jmpq *%rdx (gdb) s
Program terminated with signal SIGSEGV, Segmentation fault. The program no longer exists. (gdb)
``` What is odd is the return from tcgetattr function:
``` (gdb) s m_setparms (fd=3, baudr=0x5555557866e0 <mpars+4032> "1500000", par=0x555555786800 <mpars+4320> "N", bits=0x555555786770 <mpars+4176> "8", stopb=0x555555786890 <mpars+4464> "1", hwf=1, swf=0) **at sysdep1.c:420** **420** if (bit == '7' && (par[0] == 'M' || par[0] == 'S')) (gdb) s Warning: Cannot insert breakpoint 0. Cannot access memory at address 0x584724c9a6077db8
```
sysdep1.c (minicom program)
``` /* * Set baudrate, parity and number of bits. */ void m_setparms(int fd, char *baudr, char *par, char *bits, char *stopb, int hwf, int swf) { int spd = -1; int newbaud; int bit = bits[0];
#ifdef POSIX_TERMIOS struct termios tty; #else /* POSIX_TERMIOS */ struct sgttyb tty; #endif /* POSIX_TERMIOS */
#ifdef USE_SOCKET if (portfd_is_socket) return; #endif
#ifdef POSIX_TERMIOS tcgetattr(fd, &tty); #else /* POSIX_TERMIOS */ ioctl(fd, TIOCGETP, &tty); #endif /* POSIX_TERMIOS */
/* We generate mark and space parity ourself. */ if (bit == '7' && (par[0] == 'M' || par[0] == 'S')) bit = '8';
/* Check if 'baudr' is really a number */ if ((newbaud = (atol(baudr) / 100)) == 0 && baudr[0] != '0') newbaud = -1;
switch (newbaud) { case 0: #ifdef B0 spd = B0; #else spd = 0; #endif break; case 3: spd = B300; break; case 6: spd = B600; break; case 12: spd = B1200; break; case 24: spd = B2400; break; case 48: spd = B4800; break; case 96: spd = B9600; break; #ifdef B19200 case 192: spd = B19200; break; #else /* B19200 */ # ifdef EXTA case 192: spd = EXTA; break; # else /* EXTA */ case 192: spd = B9600; break; # endif /* EXTA */ #endif /* B19200 */ #ifdef B38400 case 384: spd = B38400; break; #else /* B38400 */ # ifdef EXTB case 384: spd = EXTB; break; # else /* EXTB */ case 384: spd = B9600; break; # endif /* EXTB */ #endif /* B38400 */ #ifdef B57600 case 576: spd = B57600; break; #endif #ifdef B115200 case 1152: spd = B115200; break; #endif #ifdef B230400 case 2304: spd = B230400; break; #endif #ifdef B460800 case 4608: spd = B460800; break; #endif #ifdef B500000 case 5000: spd = B500000; break; #endif #ifdef B576000 case 5760: spd = B576000; break; #endif #ifdef B921600 case 9216: spd = B921600; break; #endif #ifdef B1000000 case 10000: spd = B1000000; break; #endif #ifdef B1152000 case 11520: spd = B1152000; break; #endif #ifdef B1500000 case 15000: spd = B1500000; break; #endif #ifdef B2000000 case 20000: spd = B2000000; break; #endif #ifdef B2500000 case 25000: spd = B2500000; break; #endif #ifdef B3000000 case 30000: spd = B3000000; break; #endif #ifdef B3500000 case 35000: spd = B3500000; break; #endif #ifdef B4000000 case 40000: spd = B4000000; break; #endif }
#if defined (_BSD43) && !defined(POSIX_TERMIOS) if (spd != -1) tty.sg_ispeed = tty.sg_ospeed = spd; /* Number of bits is ignored */
tty.sg_flags = RAW | TANDEM; if (par[0] == 'E') tty.sg_flags |= EVENP; else if (par[0] == 'O') tty.sg_flags |= ODDP; else tty.sg_flags |= PASS8 | ANYP;
ioctl(fd, TIOCSETP, &tty);
# ifdef TIOCSDTR /* FIXME: huh? - MvS */ ioctl(fd, TIOCSDTR, 0); # endif #endif /* _BSD43 && !POSIX_TERMIOS */
#if defined (_V7) && !defined(POSIX_TERMIOS) if (spd != -1) tty.sg_ispeed = tty.sg_ospeed = spd; tty.sg_flags = RAW; if (par[0] == 'E') tty.sg_flags |= EVENP; else if (par[0] == 'O') tty.sg_flags |= ODDP;
ioctl(fd, TIOCSETP, &tty); #endif /* _V7 && !POSIX */
#ifdef POSIX_TERMIOS
if (spd != -1) { cfsetospeed(&tty, (speed_t)spd); cfsetispeed(&tty, (speed_t)spd); }
switch (bit) { case '5': tty.c_cflag = (tty.c_cflag & ~CSIZE) | CS5; break; case '6': tty.c_cflag = (tty.c_cflag & ~CSIZE) | CS6; break; case '7': tty.c_cflag = (tty.c_cflag & ~CSIZE) | CS7; break; case '8': default: tty.c_cflag = (tty.c_cflag & ~CSIZE) | CS8; break; } /* Set into raw, no echo mode */ tty.c_iflag = IGNBRK; tty.c_lflag = 0; tty.c_oflag = 0; tty.c_cflag |= CLOCAL | CREAD; #ifdef _DCDFLOW tty.c_cflag &= ~CRTSCTS; #endif tty.c_cc[VMIN] = 1; tty.c_cc[VTIME] = 5;
if (swf) tty.c_iflag |= IXON | IXOFF; else tty.c_iflag &= ~(IXON|IXOFF|IXANY);
tty.c_cflag &= ~(PARENB | PARODD); if (par[0] == 'E') tty.c_cflag |= PARENB; else if (par[0] == 'O') tty.c_cflag |= (PARENB | PARODD);
if (stopb[0] == '2') tty.c_cflag |= CSTOPB; else tty.c_cflag &= ~CSTOPB;
tcsetattr(fd, TCSANOW, &tty);
m_setrts(fd); #endif /* POSIX_TERMIOS */
#ifndef _DCDFLOW m_sethwf(fd, hwf); #endif }
```
More info, if i do an 'n' and not an 's' in GDB there is no problem.
file: /apps/libc6/glibc-2.27/sysdeps/unix/sysv/linux/tcgetattr.c
``` /* Put the state of FD into *TERMIOS_P. */ int __tcgetattr (int fd, struct termios *termios_p) { struct __kernel_termios k_termios; int retval;
retval = INLINE_SYSCALL (ioctl, 3, fd, TCGETS, &k_termios);
if (__glibc_likely (retval == 0)) { termios_p->c_iflag = k_termios.c_iflag; termios_p->c_oflag = k_termios.c_oflag; termios_p->c_cflag = k_termios.c_cflag; termios_p->c_lflag = k_termios.c_lflag; termios_p->c_line = k_termios.c_line; #ifdef _HAVE_STRUCT_TERMIOS_C_ISPEED # ifdef _HAVE_C_ISPEED termios_p->c_ispeed = k_termios.c_ispeed; # else termios_p->c_ispeed = k_termios.c_cflag & (CBAUD | CBAUDEX); # endif #endif #ifdef _HAVE_STRUCT_TERMIOS_C_OSPEED # ifdef _HAVE_C_OSPEED termios_p->c_ospeed = k_termios.c_ospeed; # else termios_p->c_ospeed = k_termios.c_cflag & (CBAUD | CBAUDEX); # endif #endif if (sizeof (cc_t) == 1 || _POSIX_VDISABLE == 0 || (unsigned char) _POSIX_VDISABLE == (unsigned char) -1) memset (__mempcpy (&termios_p->c_cc[0], &k_termios.c_cc[0], __KERNEL_NCCS * sizeof (cc_t)), _POSIX_VDISABLE, (NCCS - __KERNEL_NCCS) * sizeof (cc_t)); else { memcpy (&termios_p->c_cc[0], &k_termios.c_cc[0], __KERNEL_NCCS * sizeof (cc_t));
for (size_t cnt = __KERNEL_NCCS; cnt < NCCS; ++cnt) termios_p->c_cc[cnt] = _POSIX_VDISABLE; } }
return retval; } ```
@avafinger you got the same results with command line GDB, its nothing to do with the debugger plugin. As @nomadbyte asked please discuss that on a GDB forum, its not a Geany/Debugger problem.
I changed the title to reflect this.
Closed #1179 as completed.
github-comments@lists.geany.org