diff --git a/Constrained_triangulation_3/test/Constrained_triangulation_3/cdt_3_from_off.cpp b/Constrained_triangulation_3/test/Constrained_triangulation_3/cdt_3_from_off.cpp index 2ad62d47837..6752c673fae 100644 --- a/Constrained_triangulation_3/test/Constrained_triangulation_3/cdt_3_from_off.cpp +++ b/Constrained_triangulation_3/test/Constrained_triangulation_3/cdt_3_from_off.cpp @@ -163,8 +163,8 @@ struct CDT_options bool debug_geometric_errors = false; bool debug_polygon_insertion = false; bool use_finite_edges_map = false; - bool use_epeck_for_normals = false; - bool use_epeck_for_Steiner_points = false; + bool use_epeck_for_normals = true; + bool use_epeck_for_Steiner_points = true; bool call_is_valid = true; bool bisect_failures = false; double vertex_vertex_epsilon = 0.; // 1e-14; diff --git a/Installation/include/CGAL/gdb_autoload.h b/Installation/include/CGAL/gdb_autoload.h new file mode 100644 index 00000000000..9e793456532 --- /dev/null +++ b/Installation/include/CGAL/gdb_autoload.h @@ -0,0 +1,36 @@ +// Copyright (c) 2025 GeometryFactory Sarl (France) +// +// This file is part of CGAL (www.cgal.org) +// +// $URL$ +// $Id$ +// SPDX-License-Identifier: LGPL-3.0-or-later OR LicenseRef-Commercial +// +// Author(s) : Laurent Rineau +// +// +// GDB Pretty Printer Auto-load Header +// +// This header embeds a .debug_gdb_scripts section that tells GDB to +// automatically load CGAL pretty printers when debugging. +// +// Include this file in any CGAL executable or library to enable +// auto-loading of the gdb pretty printers. + +#ifndef CGAL_GDB_AUTOLOAD_H +#define CGAL_GDB_AUTOLOAD_H + +#if defined(__ELF__) && (defined(__GNUC__) || defined(__clang__)) +// ELF format (Linux, BSD) with GCC or Clang + +// Use inline assembly to embed the .debug_gdb_scripts section +__asm__( + ".pushsection \".debug_gdb_scripts\", \"MS\",@progbits,1\n" + ".byte 1\n" // Python script marker + ".asciz \"share/gdb/auto-load/cgal_printers.py\"\n" + ".popsection\n" +); + +#endif // __ELF__ + +#endif // CGAL_GDB_AUTOLOAD_H diff --git a/Installation/share/gdb/auto-load/cgal_printers.py b/Installation/share/gdb/auto-load/cgal_printers.py new file mode 100644 index 00000000000..0d3b83fa39c --- /dev/null +++ b/Installation/share/gdb/auto-load/cgal_printers.py @@ -0,0 +1,83 @@ +""" +CGAL GDB Pretty Printers + +This module provides pretty printers for common CGAL types to make +debugging more convenient. + +Auto-loaded via .debug_gdb_scripts section. +""" + +import gdb +import re + + +class PointC3Printer: + """Pretty printer for CGAL::PointC3<*> types""" + + def __init__(self, val): + self.val = val + + def to_string(self): + try: + # Navigate through the nested structure: + # ((((pa).base).base)._M_elems)[0] + base1 = self.val['base'] + base2 = base1['base'] + elems = base2['_M_elems'] + + # Extract coordinates + x = float(elems[0]) + y = float(elems[1]) + z = float(elems[2]) + + return f"PointC3({x}, {y}, {z})" + except (AttributeError, gdb.MemoryError, RuntimeError) as e: + return f"PointC3()" + + def children(self): + """Show individual coordinates""" + try: + base1 = self.val['base'] + base2 = base1['base'] + elems = base2['_M_elems'] + + yield 'x', elems[0] + yield 'y', elems[1] + yield 'z', elems[2] + except (AttributeError, gdb.MemoryError, RuntimeError): + pass + + def display_hint(self): + return 'array' + + +def cgal_lookup_function(val): + """Lookup function to register CGAL pretty printers""" + typename = str(val.type.strip_typedefs()) + + # Match CGAL::PointC3 + if re.match(r'^CGAL::PointC3<.*>$', typename): + return PointC3Printer(val) + + return None + + +# Register the pretty printer globally +# When auto-loaded via .debug_gdb_scripts, use global registration +objfile = gdb.current_objfile() +if objfile: + # Loaded for specific objfile + gdb.printing.register_pretty_printer( + objfile, + cgal_lookup_function, + replace=True + ) +else: + # Loaded globally (e.g., via source command) + gdb.printing.register_pretty_printer( + gdb, + cgal_lookup_function, + replace=True + ) + +print(f"CGAL pretty printers loaded (objfile: {objfile})")