相关疑难解决方法(0)

在GDB中创建C++字符串

std::string在GDB中创建(或任何C++对象)时遇到了麻烦.我尝试了以下很多变化,但似乎没有任何变化:

(gdb) p std::string("hello")
A syntax error in expression, near `"hello")'.
Run Code Online (Sandbox Code Playgroud)

有办法吗?

(我很惊讶我在网上找不到任何相关内容.我开始认为我的GDB是错误的还是我做错了什么.)

c++ gdb

24
推荐指数
1
解决办法
4018
查看次数

在gdb中,我可以调用一些类函数,但其​​他函数"无法解析".为什么?

我还没有参与共享指针..我只知道这个概念.我正在尝试调试以下c ++类中的函数,该类存储XML文件的数据(通过xerces库读入).

// header file
class ParamNode;
typedef boost::shared_ptr<ParamNode> PtrParamNode;

class ParamNode : public boost::enable_shared_from_this<ParamNode> {
public:
   ...
   typedef enum { DEFAULT, EX, PASS, INSERT, APPEND } ActionType;
   bool hasChildren() const;
   PtrParamNode GetChildren();
   PtrParamNode Get(const std::string&  name, ActionType = DEFAULT );
protected:
   ....
   ActionType defaultAction_;
}
Run Code Online (Sandbox Code Playgroud)

现在,如果我正在调试一段代码,其中我有一个指向该类的指针的实例ParamNode,并且它被调用paramNode_

PtrParamNode paramNode_;
// read xml file with xerces
paramNode_ = xerces->CreateParamNodeInstance();
// now, the xml data is stored in paramNode_.
std::string probGeo;
// this works in the code, …
Run Code Online (Sandbox Code Playgroud)

c++ debugging boost gdb shared-ptr

23
推荐指数
4
解决办法
2万
查看次数

标签 统计

c++ ×2

gdb ×2

boost ×1

debugging ×1

shared-ptr ×1