崩溃后检查gdb中的C ++对象回溯

时间:2015-02-08 20:31:03

标签: c++ gdb

我正在学习使用GDB进行调试,我不知道该怎么做。

我在GDB中运行一个程序,我需要工作,并且它与SEGFAULT崩溃了。当我在GDB中backtrace时,我看到了这一点。

(gdb) backtrace
#0  0x08200100 in boost::shared_ptr<boost::re_detail::basic_regex_implementation<char, boost::regex_traits<char, boost::cpp_regex_traits<char> > > >::get (this=0x2) at /usr/include/boost/smart_ptr/shared_ptr.hpp:668
#1  0x081f94c3 in boost::basic_regex<char, boost::regex_traits<char, boost::cpp_regex_traits<char> > >::get_traits (this=0x2) at /usr/include/boost/regex/v4/basic_regex.hpp:619
#2  0x081ef769 in boost::re_detail::perl_matcher<__gnu_cxx::__normal_iterator<char const*, std::string>, std::allocator<boost::sub_match<__gnu_cxx::__normal_iterator<char const*, std::string> > >, boost::regex_traits<char, boost::cpp_regex_traits<char> > >::perl_matcher (this=0xb60d3eb4, first=..., end=..., what=..., e=..., 
    f=boost::regex_constants::match_any, l_base=...) at /usr/include/boost/regex/v4/perl_matcher.hpp:372
#3  0x081e2214 in boost::regex_match<__gnu_cxx::__normal_iterator<char const*, std::string>, std::allocator<boost::sub_match<__gnu_cxx::__normal_iterator<char const*, std::string> > >, char, boost::regex_traits<char, boost::cpp_regex_traits<char> > > (first=..., last=..., m=..., e=..., flags=boost::regex_constants::match_any)
    at /usr/include/boost/regex/v4/regex_match.hpp:49
#4  0x081d43bf in boost::regex_match<std::char_traits<char>, std::allocator<char>, char, boost::regex_traits<char, boost::cpp_regex_traits<char> > > (s=..., e=..., flags=boost::regex_constants::match_default)
    at /usr/include/boost/regex/v4/regex_match.hpp:100
#5  0x081ca3c1 in [my project] (this=0x2, request=0xb5706630)
    at [source of my project]:127
[more calls here]

现在我想检查第{127}行request#5内的内容.Request是指向类request_data的C ++对象的C风格指针,它定义于我的项目。我的函数的定义是bool match_request(request_data *request) const

我应该在gdb写些什么来实际获取request的内容,就像程序发生之前一样?

2 个答案:

答案 0 :(得分:2)

嗯,#5的this指针看起来不太健康,但除此之外,我认为你需要一个GDB教程:

答案 1 :(得分:1)

就是这样。

(gdb) frame 5
(gdb) print *request