Gdb调试c ++,对象打印

时间:2011-03-09 11:56:38

标签: c++ linux gdb

例如,我可以使用命令打印这段代码:

print *hostx

我得到了结果:

    $22 = (Adaptation::Ecap::XactionRep) {<Adaptation::Initiate> = {<AsyncJob> = {_vptr.AsyncJob = 0x8beac8, stopReason = 0x0, 
      typeName = 0x662553 "Adaptation::Ecap::XactionRep", inCall = {p_ = 0xc8a440}, id = {static Prefix = 0x65800f "job", value = 50, static Last = 50}}, 
    _vptr.Initiate = 0x8be858, theInitiator = {cbc = 0xc712a0, lock = 0xc71288}}, <libecap::host::Xaction> = {<libecap::Callable> = {
      _vptr.Callable = 0x8be958}, <No data fields>}, <BodyConsumer> = {_vptr.BodyConsumer = 0x8bea18}, <BodyProducer> = {_vptr.BodyProducer = 0x8bea58}, 
  theMaster = {<std::tr1::__shared_ptr<libecap::adapter::Xaction, (__gnu_cxx::_Lock_policy)2>> = {_M_ptr = 0xc93c00, _M_refcount = {
        _M_pi = 0xc7d520}}, <No data fields>}, theService = {p_ = 0xc56b70}, theVirginRep = {<libecap::Message> = {_vptr.Message = 0x8befd0}, theMessage = {
      header = 0xc8be10, body_pipe = {p_ = 0x0}}, theFirstLineRep = 0xca4880, theHeaderRep = 0xcac1f0, theBodyRep = 0x0}, theCauseRep = 0x0, 
  theAnswerRep = {<std::tr1::__shared_ptr<libecap::Message, (__gnu_cxx::_Lock_policy)2>> = {_M_ptr = 0x0, _M_refcount = {_M_pi = 0x0}}, <No data fields>}, 
  makingVb = Adaptation::Ecap::XactionRep::opNever, proxyingAb = Adaptation::Ecap::XactionRep::opUndecided, adaptHistoryId = -1, vbProductionFinished = false, 
  abProductionFinished = false, abProductionAtEnd = false, static CBDATA_XactionRep = 22}

问题是如何在gdb中的hostx中打印这些对象值?

1 个答案:

答案 0 :(得分:4)

使用标准C / C ++语法,例如print hostx->id