我通常手动调试代码,但我试图使用lldb来调试CGAL项目。因此,这是一个新出现的问题。下面的代码会导致异常(即预期的行为)。在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获取相同的信息。
发布于 2015-02-25 21:53:35
我不知道你想要什么。您可以通过在异常抛出上设置一个断点,使lldb在抛出异常时停止:
(lldb) break set -n __cxa_throw然后,您将在异常即将交付的位置停止调试器。查看异常的上下文通常是有帮助的。请注意,如果您正在使用的库或您自己的代码经常使用异常,那么在所有不相关的点击中涉水可能会变得乏味.如果你只想看到回溯,你可以在断点上放一个命令,打印回溯并继续。最后一本会是有趣的..。这样做:
(lldb) br comm add
Enter your debugger command(s). Type 'DONE' to end.
> bt
> continue
> DONE这将向最后一个设置断点添加一个命令(如果不是最后一个断点,则将断点号指定为参数)。
注意,在抛出错误之前,错误文本很可能是由检查程序代码对其进行过滤和打印出来的。调试器没有办法知道这是一件特殊的事情,它能做的最好是将它和所有其他文本一起打印到控制台。
https://stackoverflow.com/questions/28727637
复制相似问题