Bug ID 1203118
Summary glibc debuginfo makes inferior call difficult
Classification openSUSE
Product openSUSE Tumbleweed
Version Current
Hardware Other
OS Other
Status NEW
Severity Normal
Priority P5 - None
Component Development
Assignee screening-team-bugs@suse.de
Reporter tdevries@suse.com
QA Contact qa-bugs@suse.de
Found By ---
Blocker ---

[ Minimized from gdb test-case gdb.base/break-main-file-remove-fail.exp. ]

Consider test-case test.c:
...
#include <sys/mman.h>

int
main (void)
{
  int res = munmap (0, 0);

  return 0;
}
...

Compiled like this:
...
$ gcc -g test.c
...

Trying to do an inferior call to munmap has become complicated:
...
$ gdb -q -batch -iex "set debuginfod enabled on" a.out \
  -ex "set trace-commands on" \
  -ex start \
  -ex n \
  -ex "p res" \
  -ex "p munmap" \
  -ex "p munmap (0, 0)" \
  -ex "p (int) munmap (0, 0)" \
  -ex "p ((int (*) (void *, size_t)) munmap) (0, 0)"
+start
Temporary breakpoint 1 at 0x40113e: file test.c, line 6.
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib64/libthread_db.so.1".

Temporary breakpoint 1, main () at test.c:6
6         int res = munmap (0, 0);
+n
8         return 0;
+p res
$1 = -1
+p munmap
$2 = {void (void)} 0x7ffff7feb9a0 <__GI_munmap>
+p munmap (0, 0)
$3 = void
+p (int) munmap (0, 0)
Invalid cast.
+p ((int (*) (void *, size_t)) munmap) (0, 0)
$4 = -1
...

AFAICT, this is due to libc debuginfo:
...
 <0><189683>: Abbrev Number: 1 (DW_TAG_compile_unit)
    <189684>   DW_AT_stmt_list   : 0xeba4b
    <189688>   DW_AT_low_pc      : 0x10cad0
    <189690>   DW_AT_high_pc     : 37
    <189691>   DW_AT_name        : ../sysdeps/unix/syscall-template.S
    <189695>   DW_AT_comp_dir    : /usr/src/debug/glibc-2.36-1.3.x86_64/misc
    <189699>   DW_AT_producer    : GNU AS 2.39.0
    <18969d>   DW_AT_language    : 32769        (MIPS assembler)
 <1><18969f>: Abbrev Number: 2 (DW_TAG_subprogram)
    <1896a0>   DW_AT_name        : __munmap
    <1896a4>   DW_AT_external    : 1
    <1896a5>   DW_AT_low_pc      : 0x10cad0
    <1896ad>   DW_AT_high_pc     : 37
 <1><1896ae>: Abbrev Number: 2 (DW_TAG_subprogram)
    <1896af>   DW_AT_name        : __GI___munmap
    <1896b3>   DW_AT_external    : 1
    <1896b4>   DW_AT_low_pc      : 0x10cad0
    <1896bc>   DW_AT_high_pc     : 37
 <1><1896bd>: Abbrev Number: 2 (DW_TAG_subprogram)
    <1896be>   DW_AT_name        : munmap
    <1896c2>   DW_AT_external    : 0
    <1896c3>   DW_AT_low_pc      : 0x10cad0
    <1896cb>   DW_AT_high_pc     : 37
 <1><1896cc>: Abbrev Number: 2 (DW_TAG_subprogram)
    <1896cd>   DW_AT_name        : __GI_munmap
    <1896d1>   DW_AT_external    : 1
    <1896d2>   DW_AT_low_pc      : 0x10cad0
    <1896da>   DW_AT_high_pc     : 37
...

If we ignore the shared library info using nosharedlibrary, we get instead:
...
+nosharedlibrary
+p munmap
$2 = {<text variable, no debug info>} 0x401030 <munmap@plt>
+p munmap (0, 0)
'munmap@plt' has unknown return type; cast the call to its declared return type
+p (int) munmap (0, 0)
$3 = -1
+p ((int (*) (void *, size_t)) munmap) (0, 0)
$4 = -1
...


You are receiving this mail because: