Opened 10 years ago

Closed 10 years ago

#13881 closed enhancement (fixed)

Enhanced debugging: cygdb and better backtraces

Reported by: Volker Braun Owned by: Georg S. Weber
Priority: major Milestone: sage-5.6
Component: build Keywords:
Cc: Merged in: sage-5.6.beta3
Authors: Volker Braun Reviewers: Jeroen Demeyer
Report Upstream: N/A Work issues:
Branch: Commit:
Dependencies: #13669 Stopgaps:

Status badges

Description (last modified by Simon King)

The purpose of these patches is to make cython emit debugging output (unless SAGE_DEBUG=no since it only costs some disk space) and run cygdb instead of gdb for sage --gdb (unless SAGE_DEBUG=no, in which case you get the plain gdb). cydbg can be a bit slow to start up, but gives cython source-level debugging. For example:

[vbraun@volker-desktop sage-5.6.beta1]$ SAGE_DEBUG=yes ./sage -gdb
----------------------------------------------------------------------
| Sage Version 5.6.beta1, Release Date: 2012-12-27                   |
| Type "notebook()" for the browser-based notebook interface.        |
| Type "help()" for help.                                            |
----------------------------------------------------------------------
**********************************************************************
*                                                                    *
* Warning: this is a prerelease version, and it may be unstable.     *
*                                                                    *
**********************************************************************
GNU gdb (GDB) 7.5.1
Copyright (C) 2012 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-unknown-linux-gnu".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
Reading symbols from /home/vbraun/opt/sage-5.6.beta1/local/bin/python...done.
Python was not compiled with debug symbols (or it was stripped). Some functionality may not work (properly).
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib64/libthread_db.so.1".

sage: from sage.tests.interrupt import unguarded_dereference_null_pointer
sage: unguarded_dereference_null_pointer()

Program received signal SIGSEGV, Segmentation fault.
0x00007fffc1f9d04a in __pyx_f_4sage_5tests_9interrupt_dereference_null_pointer ()
    at sage/tests/interrupt.c:894
894	  (__pyx_v_ptr[__pyx_t_1]) = ((__pyx_v_ptr[__pyx_t_1]) + 1);
(gdb) cy list
    59    # Dereference a NULL pointer on purpose. This signals a SIGSEGV on most
    60    # systems, but on older Mac OS X and possibly other systems, this
    61    # signals a SIGBUS instead. In any case, this should give some signal.
    62    cdef void dereference_null_pointer():
    63        cdef long* ptr = <long*>(0)
>   64        ptr[0] += 1
    65    
    66    
    67    ########################################################################
    68    # Python helper functions                                              #

Apply

and then rebuild the sage libarary.

Attachments (2)

trac_13881_cython_debug_symbols.patch (1.1 KB) - added by Volker Braun 10 years ago.
Updated patch
trac_13881_launch_cygdb.patch (925 bytes) - added by Jeroen Demeyer 10 years ago.
Updated patch

Download all attachments as: .zip

Change History (19)

comment:1 Changed 10 years ago by Volker Braun

  • Make Cython emit debugging information (unless SAGE_DEBUG=no). This costs only a bit of disk space.

comment:2 Changed 10 years ago by Volker Braun

Dependencies: #13669
Description: modified (diff)
Status: newneeds_review

comment:3 Changed 10 years ago by Volker Braun

Rediffed, was accidentally based on an old version of #13669

comment:4 Changed 10 years ago by Volker Braun

Authors: Volker Braun

comment:5 Changed 10 years ago by Jeroen Demeyer

Any reason why you don't always use cygdb instead of gdb?

Also, while you're at it, can you change

python `which cython`

by

cython

comment:6 Changed 10 years ago by Volker Braun

I wouldn't mind always using cygdb, but there might be compatibility issues with gdb versions as the Python support needs a relatively new version. How about we default to cygdb unless SAGE_DEBUG=no?

Changed 10 years ago by Volker Braun

Updated patch

comment:7 Changed 10 years ago by Volker Braun

Description: modified (diff)

comment:8 Changed 10 years ago by Simon King

trac_13881_launch_cygdb.patch doesn't apply for me. Even though I have #13669 applied on top of sage-5.6.b1.

comment:9 Changed 10 years ago by Simon King

Got it!

I did not have the latest version of #13669 applied, but only a preliminary version with improper quotation marks. So, it should work(T) now.

comment:10 Changed 10 years ago by Simon King

What needs to be done in order to make it work?

I have now both patches applied, did sage -b, but sage -gdb gives me

----------------------------------------------------------------------
| Sage Version 5.6.beta1, Release Date: 2012-12-27                   |
| Type "notebook()" for the browser-based notebook interface.        |
| Type "help()" for help.                                            |
----------------------------------------------------------------------
**********************************************************************
*                                                                    *
* Warning: this is a prerelease version, and it may be unstable.     *
*                                                                    *
**********************************************************************
Usage: cygdb [PATH [GDB_ARGUMENTS]].
No debug files were found in /home/simon/SAGE/debug/sage-5.6.beta1/devel/sage. Aborting.

comment:11 Changed 10 years ago by Volker Braun

You need to rebuild the Sage library once (sage -ba)

comment:12 Changed 10 years ago by Simon King

Description: modified (diff)

comment:13 Changed 10 years ago by Jeroen Demeyer

You should use spaces instead of TABs for indentation in trac_13881_launch_cygdb.patch

comment:14 Changed 10 years ago by Volker Braun

There was another place where tabs where used for indentation, fixed that as well.

comment:15 Changed 10 years ago by Jeroen Demeyer

Those other TABs are already fixed by #13899, so I'm removing that hunk.

Changed 10 years ago by Jeroen Demeyer

Updated patch

comment:16 Changed 10 years ago by Jeroen Demeyer

Reviewers: Jeroen Demeyer
Status: needs_reviewpositive_review

comment:17 Changed 10 years ago by Jeroen Demeyer

Merged in: sage-5.6.beta3
Resolution: fixed
Status: positive_reviewclosed
Note: See TracTickets for help on using tickets.