2015-01-25 2 views
1

매우 이상한 문제를 파악하려고합니다.gdb가 CentOS에서 디버그 정보를 찾을 수 없습니다.

GNU gdb를 (GDB) 레드햇 엔터프라이즈 리눅스 (7.2-75.el6)

및 GCC :

GCC (GCC) 4.8 나는 GDB와에 CentOS 6.5 시스템을

,645 : 0.2 20131212 (레드햇 4.8.2-8)

나는이 파일이 이

GCC -OA 교류 -g -O0

파일이 잘 될 것 같다 : 내가 컴파일 83,210

$ file a 
a: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.18, not stripped 

하지만하려고 할 때 디버그하면 다음이 발생합니다.

$ gdb a 
GNU gdb (GDB) Red Hat Enterprise Linux (7.2-75.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 "x86_64-redhat-linux-gnu". 
For bug reporting instructions, please see: 
<http://www.gnu.org/software/gdb/bugs/>... 
Reading symbols from a...done. 
(gdb) b main 
Breakpoint 1 at 0x4004e4 
(gdb) r 
Starting program: a 

Breakpoint 1, 0x00000000004004e4 in main() 
(gdb) l 
1 /* Run time dynamic linker. 
2  Copyright (C) 1995-2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc. 
3  This file is part of the GNU C Library. 
4 
5  The GNU C Library is free software; you can redistribute it and/or 
6  modify it under the terms of the GNU Lesser General Public 
7  License as published by the Free Software Foundation; either 
8  version 2.1 of the License, or (at your option) any later version. 
9 
10  The GNU C Library is distributed in the hope that it will be useful, 
(gdb) l main 
No line number known for main. 

즉, gdb는 디버그 정보를 보지 않습니다. 아무도 여기에 문제가 될 수있는 아이디어가 있습니까?

+0

흥미롭게도 valgrind는 동일한 빌드의 기호 및 행 번호를 볼 수 있지만 gdb만이 그럴 수 없습니다. – StasM

답변

4

GDB가 꽤 오래되었습니다. 귀하의 GCC는 상당히 새롭습니다.

GCC가 인식하지 못하는 DWARF4 디버그 정보 (기본값은 release notes에 따른 gcc-4.8 기준)가 방출 된 것으로 의심됩니다.

-g 대신 -gdwarf-2을 사용하면 더 좋은 결과를 얻으실 수 있습니까?

GDB를 업그레이드하거나이 컴파일러로 -gdwarf-2을 사용하십시오.

+0

감사합니다. -gdwarf-2가 작동했습니다! – StasM