2

I'm trying debug application using GNU gdb that built by icc (Intel C compiler). But gdb not see any line in file (but if I build app using gcc everything fine). I have never used before icc compiler so maybe I do something wrong. Please help :)

icc - Version 8.0

gdb - GNU gdb (GDB) Red Hat Enterprise Linux (7.2-90.el6)

OS - Red Hat Enterprise Linux Server release 6.8 (Santiago)

test.c:

1  #include<stdio.h>
2
3  int main(int argc, char **argv)
4  {
5          int count = 0;
6          while(1)
7          {
8                  printf("Work In %d \n",count);
9                  count++;
10                  sleep(2);
11          }
12  }

Run build: icc -g -inline_debug_info --gsplit-dwarf ./test.c -o test

And when I tryied to break line (8 line for example) in gdb, gdb shows: No line 8 in file "./test.c"

Output:

GNU gdb (GDB) Red Hat Enterprise Linux (7.2-90.el6)
Copyright (C) 2010 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 "i686-redhat-linux-gnu".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
Reading symbols from /tmp/test...done.

(gdb) break 8

No line 8 in file "./test.c".
Employed Russian
  • 199,314
  • 34
  • 295
  • 362
  • 1
    What if try to build without `--gsplit-dwarf`, just `icc -g ... ` ? There is potentially similar [question](https://stackoverflow.com/questions/47913199/gdb-cannot-find-symbols-when-debug-symbols-are-split-into-dwo-dwarf-file) where gcc with split-dwarf didn't work, so might be worth to try. – Renat Dec 29 '21 at 10:46
  • I tried: icc -g -inline_debug_info ./test.c -o test and icc -g ./test.c -o test Nothing changed. gdb still don't handle the line – Bohdan Kilchynskiy Dec 29 '21 at 11:05
  • Please do not post pictures of text. Especially with some blurry background. Please post text as text, into the question. Please post the output of `file ./test` and `objdump -drl ./a.out | grep -C20 '
    '`. Does `objdump -drl` ouptuts line numbers?
    – KamilCuk Dec 29 '21 at 11:21
  • `file ./test`: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.18, not stripped. `objdump` returned line numbers. Output: 080487e4
    : main(): /tmp/./test.c:4 ... 80487f0: 56 push %esi /tmp/./test.c:5 80487f1: c7 45 fc 00 00 00 00 movl $0x0,-0x4(%ebp) /tmp/./test.c:6 ... 80487ff: 74 33 je 8048834
    /tmp/./test.c:8 ... 8048812: e8 41 fe ff ff call 8048658
    – Bohdan Kilchynskiy Dec 29 '21 at 12:03
  • https://stackoverflow.com/questions/8971958/gdb-doesnt-find-line-numbers-objdump-does ? – KamilCuk Dec 29 '21 at 13:54
  • icc not contains options like -gstab. But I try figure out why my version of icc doesn't have options like [gdwarf](https://www.intel.com/content/www/us/en/develop/documentation/cpp-compiler-developer-guide-and-reference/top/compiler-reference/compiler-options/compiler-option-details/output-debug-and-precompiled-header-pch-options/gdwarf.html). If I undestood rihgt we should provide debug info to the gdb by DWARF format – Bohdan Kilchynskiy Dec 29 '21 at 16:06
  • 2
    All the tools you are using are _ancient_ and long past their end-of-life support. Consider using something more recent. – Employed Russian Dec 29 '21 at 17:41
  • Yes, you are right, but we can't use another version of compiler unfortunately because customer have enough big old project and can't switch to newest version. – Bohdan Kilchynskiy Dec 30 '21 at 10:55
  • Do you have the Intel debugger, `idb`? – Mark Plotnick Jan 05 '22 at 21:57

1 Answers1

0

Output:

080487e4 <main>: main(): /tmp/./test.c:4 ... 
80487f0: 56 push %esi /tmp/./test.c:5
80487f1: c7 45 fc 00 00 00 00 movl $0x0,-0x4(%ebp) /tmp/./test.c:6 ...
80487ff: 74 33 je 8048834 <main+0x50> /tmp/./test.c:8 ...
8048812: e8 41 fe ff ff call 8048658 <printf@plt> 

This might be a confusion between test.c and ./test.c.

Does the picture change if you use icc -g test.c -o test instead?
(Using ./test.c is quite unusual and completely unnecessary.)

Employed Russian
  • 199,314
  • 34
  • 295
  • 362