V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX 提问指南
Shiratsuyu
V2EX  ›  问与答

为什么使用 cgdb 打开的调试文件不显示源代码

  •  
  •   Shiratsuyu · 2016-12-15 00:37:24 +08:00 · 1599 次点击
    这是一个创建于 2756 天前的主题,其中的信息可能已经有所发展或是发生改变。
    • 使用 cgdb 调试一个编译好的文件,结果发现打开看到的并不是源代码,而是 LLVM 的编译输出:
       1│ // -*- C++ -*-
       2│ //===------------------------------ vector --------------------------------===//
       3│ //
       4│ //                     The LLVM Compiler Infrastructure
       5│ //
       6│ // This file is dual licensed under the MIT and the University of Illinois Open
       7│ // Source Licenses. See LICENSE.TXT for details.
       8│ //
       9│ //===----------------------------------------------------------------------===//
      10│
      11│ #ifndef _LIBCPP_VECTOR
      12│ #define _LIBCPP_VECTOR
      13│
      14│ /*
      15│     vector synopsis
      16│
      17│ namespace std
      18│ {
      19│
      20│ template <class T, class Allocator = allocator<T> >
    /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/vector                
    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 PartialOrdering...done.
    (gdb) l
    849                                           data() + size(), data() + capacity());
    850         }
    851         void __annotate_increase(size_type __n) const
    852         {
    853           __annotate_contiguous_container(data(), data() + capacity(),
    854                                           data() + size(), data() + size() + __n);
    855         }
    856         void __annotate_shrink(size_type __old_size) const
    857         {
    858           __annotate_contiguous_container(data(), data() + capacity(),
    (gdb) help
    
    • 吓得我赶紧又写了一个 helloworld 试了一下:
    
    
    
                                                                       _|  _|      
                                               _|_|_|    _|_|_|    _|_|_|  _|_|_|  
                                             _|        _|    _|  _|    _|  _|    _|
                                             _|        _|    _|  _|    _|  _|    _|
                                               _|_|_|    _|_|_|    _|_|_|  _|_|_|  
                                                             _|                    
                                                         _|_|                      
    
                                                       a curses debugger
                                                         version 0.6.8
    
                                            type  q<Enter>            to exit      
                                            type  help<Enter>         for GDB help 
                                            type  <ESC>:help<Enter>   for CGDB help
    
    
    
                                                                                                                            
    <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 hello...Reading symbols from /Users/Shiratsuyu/Documents/Codes/PartialOrdering/hello.dSYM/Contents/
    Resources/DWARF/hello...done.
    done.
    (gdb) list
    Line number 8 out of range; h.cpp has 7 lines.
    (gdb) list 1
    1       #include <iostream>
    2       using namespace std;
    3
    4       int main(){
    5               cout<<"Hello, World!"<<endl;
    6               return 0;
    7       }
    (gdb) 
    
    • 这都是什么鬼……
    • …真的是没脾气了,怎么样才能让它老老实实的显示和 main.cpp 里一样的代码啊
    目前尚无回复
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   3331 人在线   最高记录 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 26ms · UTC 10:44 · PVG 18:44 · LAX 03:44 · JFK 06:44
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.