我通常手动调试代码,但是我试图使用lldb调试CGAL项目。因此,这是一个新手lldb问题。以下代码导致异常(这是预期的行为)。当我在Xcode中编译并运行以下代码时(使用os-x的内置clang编译器)
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/Polygon_with_holes_2.h>
#include <CGAL/Boolean_set_operations_2.h>
typedef CGAL::Exact_predicates_inexact_constructions_kernel K;
typedef CGAL::Point_2<K> Point;
typedef CGAL::Polygon_2<K> Polygon_2;
typedef CGAL::Polygon_with_holes_2<K> Polygon_with_holes_2;
int main(){
Polygon_2 p,q;
Polygon_with_holes_2 r;
p.push_back(Point(0,0));
p.push_back(Point(1,0));
p.push_back(Point(1,1));
q.push_back(Point(0,0));
q.push_back(Point(0,1));
q.push_back(Point(1,1));
CGAL::join(p,q,r);
return 0;
}
我得到以下信息:
CGAL warning: check violation!
Expression : valid_orientation
File : /opt/local/include/CGAL/Boolean_set_operations_2/Gps_polygon_validation.h
Line : 310
Explanation: The polygon has a wrong orientation.
Refer to the bug-reporting instructions at http://www.cgal.org/bug_report.html
CGAL error: precondition violation!
Expression : is_valid_unknown_polygon(p, t)
File : /opt/local/include/CGAL/General_polygon_set_on_surface_2.h
Line : 45
Explanation:
Refer to the bug-reporting instructions at http://www.cgal.org/bug_report.html
libc++abi.dylib: terminating with uncaught exception of type CGAL::Precondition_exception: CGAL ERROR: precondition violation!
Expr: is_valid_unknown_polygon(p, t)
File: /opt/local/include/CGAL/General_polygon_set_on_surface_2.h
Line: 45
(lldb)
我想知道如何在命令行上从lldb获取相同的信息。
我不知道你想得到什么。通过在异常引发上设置断点,可以使lldb停止在将要引发异常的位置:
(lldb) break set -n __cxa_throw
然后,您将在调试器中将要交付异常的位置停止。查看异常的上下文通常会很有帮助。请注意,如果您正在使用的库或您自己的代码使用了很多异常,则遍历所有不相关的匹配项可能会很乏味……如果您只想查看回溯,可以在打印断点的地方放置命令回溯并继续。最后打印的将是有趣的一个。
(lldb) br comm add
Enter your debugger command(s). Type 'DONE' to end.
> bt
> continue
> DONE
这会将命令添加到最后一个设置的断点(如果断点号不是最后一个,则将其指定为命令的参数)。
请注意,最有可能在抛出错误之前,错误代码只是被错误代码检查并打印出来。调试器无法知道这是一件特殊的事情,它能做的最好的事情就是将它与其他所有要发送到stderr的文本一起打印到控制台上。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句