首页 > 其他分享 >如何在gdb中打印<incomplete type>变量 gdb

如何在gdb中打印<incomplete type>变量 gdb

时间:2023-05-22 15:31:28浏览次数:43  
标签:show main1 gdb cpp main type inFile incomplete


link

vi main1.cpp
#include <iostream>
#include <fstream>
#include <stdio.h>

using namespace std;
int main()
{
    ifstream inFile("test.txt", ios::in);


    //printf("%p",inFile);
    cout<<"inFile="<< !inFile<<endl;
    if (inFile)
        inFile.close();
    else
        cout << "test.txt doesn't exist" << endl;
    ofstream oFile("test1.txt", ios::out);
    if (!oFile)
        cout << "error 1";
    else
        oFile.close();
    fstream oFile2("./test2.txt", ios::out | ios::in);
    if (!oFile2)
        cout << "error 2";
    else
        oFile.close();
    return 0;
}
g++ -g main1.cpp -o main
gdb main
b 8
r 
n
p inFile 
print (void *)inFile
GNU gdb (Ubuntu 8.1.1-0ubuntu1) 8.1.1
Copyright (C) 2018 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-linux-gnu".
Type "show configuration" for configuration details.
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 main...done.
(gdb) b 8
Breakpoint 1 at 0xef5: file main1.cpp, line 8.
(gdb) r 
Starting program: /home/ledi/cc/4/main 

Breakpoint 1, main () at main1.cpp:8
8	    ifstream inFile("test.txt", ios::in);
(gdb) n
13	    if (inFile)
(gdb) p inFile 
$1 = <incomplete type>
(gdb) print (void *)inFile
$2 = (void *) 0x7ffff7dc9410 <vtable for std::basic_ifstream<char, std::char_traits<char> >+24>


标签:show,main1,gdb,cpp,main,type,inFile,incomplete
From: https://blog.51cto.com/u_15202985/6324825

相关文章

  • [React Typescript] Overriding and Removing Component Props
    UsingOmitimport{ComponentProps}from'react';import{Equal,Expect}from'../helpers/type-utils';exportconstInput=(props:Omit<ComponentProps<'input'>,'onChange'>&{onChange:......
  • [React Typescript] Useful React Prop Type Examples
    RelevantforcomponentsthatacceptotherReactcomponentsasprops.exportdeclareinterfaceAppProps{children?:React.ReactNode;//best,acceptseverythingReactcanrenderchildrenElement:JSX.Element;//AsingleReactelementstyle?:React.C......
  • csproj OutputType
    csproj<?xmlversion="1.0"encoding="utf-8"?><ProjectToolsVersion="4.0"DefaultTargets="Build"xmlns="http://schemas.microsoft.com/developer/msbuild/2003"><PropertyGroup><C......
  • 原型模式(Prototype Pattern)
    原型模式(PrototypePattern)一、意图用原型实例指定创建对象的种类,并且通过拷贝这些原型创建新的对象。二、优缺点优点:1、性能提高。2、逃避构造函数的约束。缺点:1、配备克隆方法需要对类的功能进行通盘考虑,这对于全新的类不是很难,但对于已有的类不一定很容易,特别当一个......
  • AngularJS2 教程 -- TypeScript环境配置
    AngularJS2TypeScript环境配置这开始前,你需要确保你已经安装了npm,如果你还没安装npm或者不了解npm可以查看我们的教程:NPM使用介绍。由于npm官网镜像国内访问太慢,这里我使用了淘宝的npm镜像,安装方法如下:$npminstall-gcnpm--registry=https://registry.npm.taobao.org......
  • Field userClient in com.demo.order.service.OrderService required a bean of type'
    在SpringCloud项目中使用Feign进行远程调用遇到的错误。原因是因为UserClient在com.demo.feign.clients包下面,而order-service的@EnableFeignClientd注解却在com.demo.order包下面,这两个不在同一个包下,无法扫描到UserClient。解决方法有两种1.指定Feign应该扫描的包@EnableFeig......
  • TypeError: Cannot read properties of null (reading 'name')
    报错如下:错误代码:searchList(){this.entity={}this.edit=nullletquery={}query.traceCode=this.codethis.loading=truecodeApi.queryTraceCode(query).then(res=>{...},err=>{......
  • QObject::connect: Cannot queue arguments of type 'QByteArray&' (Make sure 'QByte
    在写功能时,一次从子线程串口读取数据发回给主线程。使用信号槽,QByteArray作为参数,在linux开发板系统下一运行没有任何提示,也没数据。而测试一下使用QString作参数确可以触发槽函数,想不明白为什么,也没查到原因。不得已,只好把相关代码移植到windows下模拟一下慢慢调式。if......
  • 08_TypeScript 循环
    08_TypeScript循环有的时候,我们可能需要多次执行同一块代码。一般情况下,语句是按顺序执行的:函数中的第一个语句先执行,接着是第二个语句,依此类推。编程语言提供了更为复杂执行路径的多种控制结构。for循环TypeScriptfor循环用于多次执行一个语句序列,简化管理循环变量的代码......
  • fastapi报错TypeError("'numpy.int64' object is not iterable"解决
     目录1.代码1.1main.py1.2start.sh?bug1------[TypeError("'numpy.int64'objectisnotiterable")bug2------"msg":"valueisnotavaliddict",1.代码1.1main.py?12345678910111213141516171819......