简体   繁体   English

在basic_string中查找STL :: Exception的来源

[英]Find Source of STL::Exception in basic_string

I am trying to track the source of a std::exception, in basic_string::erase, I wrapped all the locations where I am calling erase directly in try/catch and am not seeing any of these catch blocks be hit, so it must be being called internally from another basic_string method. 我正在尝试在basic_string :: erase中跟踪std :: exception的来源,将所有我要调用擦除的位置都直接包裹在try / catch中,并且没有看到任何这些catch块被击中,因此必须从另一个basic_string方法内部调用。 The exception appears to be the result of a race condition in the code i am working with, so it is very difficult to reproduce, any thoughts on how I could detect and or get a stack trace from this exception? 异常似乎是我正在使用的代码中竞争条件的结果,因此很难重现,关于如何从该异常中检测和/或获取堆栈跟踪的任何想法? btw this is c++ code on an x86 linux box. 顺便说一句,这是x86 linux机器上的c ++代码。

Thank you 谢谢

You should try 你应该试试

(gdb) catch throw (gdb)抓投掷

Then gdb will trigger breakpoint each time exception is thrown. 然后,每次抛出异常时,gdb都会触发断点。 You'll see a callstack. 您会看到一个调用栈。

EDIT: This post is a good bunch of tricks for debugging exceptions: GDB: How to break when a specific exception type is thrown? 编辑:这篇文章是调试异常的很多技巧: GDB:如何在抛出特定异常类型时中断?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM