代码之家  ›  专栏  ›  技术社区  ›  Jason

在c的fstream上使用gdb++

  •  4
  • Jason  · 技术社区  · 7 年前

    我有一个 std::fstream std::fstream input 用于从文件中读取值。如何检查gdb调试器内输入的状态?我试过了 print input.fail() ,但它说:

    couldn't find method std::ifstream::fail
    
    1 回复  |  直到 7 年前
        1
  •  1
  •   ks1322    7 年前

    这很可能是因为您尚未安装libstdc++的调试符号(这里是 std::fstream

    如果你想打印 input 变量在没有libstdc++调试符号的情况下,您将得到如下结果:

    (gdb) p input
    $1 = <incomplete type>
    

    输入 input.fail() 调用)在我使用此命令安装调试信息后:

    sudo debuginfo-install libstdc++
    

    另请参见类似问题 std::stringstream
    https://www.reddit.com/r/learnprogramming/comments/5dwtbb/gdb_looking_into_streams/