簡體   English   中英

崩潰后在gdb backtrace中檢查C ++對象

[英]Examining C++ objects in gdb backtrace after crash

我正在學習使用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]

現在,我想在#5行的第127行中檢查request 。請求是指向request_data類的C ++對象的C風格指針,該指針在我的項目中定義。 我函數的定義是bool match_request(request_data *request) const

我應該在gdb寫些什么才能真正獲得request的內容,就像程序斷電之前一樣?

那么,你的this指針在#5看起來不太健康,但除此之外,我認為你需要一個GDB教程:

做到了。

(gdb) frame 5
(gdb) print *request

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM