This file is indexed.

/usr/share/vile/perl/gdb.pm is in vile-common 9.8o-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
package gdb;

use strict;
use shell;

require Vile::Exporter;

use vars qw(@ISA %REGISTRY);

@ISA      = 'Vile::Exporter';
%REGISTRY = (
    'gdb' => [ \&gdb_session, 'start or rejoin an interactive gdb session' ],
    'gdb-break' => [ \&gdb_break, 'set a breakpoint in gdb' ],
    'gdb-step'  => [ \&gdb_step,  'single step in gdb' ],
    'gdb-next'  => [ \&gdb_next,  'next in gdb' ],
    'gdb-cont'  => [ \&gdb_cont,  'continue in gdb' ],
);

{
    my $gdbid;
    my $old_gdb_cmd = "gdb --fullname ";

    sub find_gdb_session {
        return $gdbid if !shell::dead($gdbid);
        for ( my $i = 0 ; my $w = Vile::window_at($i) ; $i++ ) {
            if ( !shell::dead( shell::buffer_name_internal( $w->buffer ) ) ) {
                my $buffername = $w->buffer->buffername;
                print "Join $buffername as a gdb session? ";
                my $c = Vile::keystroke;
                if ( $c == ord('y') || $c == ord('Y') ) {
                    $gdbid = shell::buffer_name_internal( $w->buffer );
                    return $gdbid;
                }
            }
        }
        my $gdb_cmd = Vile::mlreply_shell( "gdb command line: ", $old_gdb_cmd );
        return undef if !defined($gdb_cmd);
        if ( $gdb_cmd !~ /\s--fullname\b/ ) {
            print "``--fullname'' option missing.  Shall I add it? ";
            my $c = Vile::keystroke;
            if ( $c == ord('y') || $c == ord('Y') ) {
                $gdb_cmd =~ s/^(\s*\S+)(.*)$/$1 --fullname$2/;
            }
        }
        $old_gdb_cmd = $gdb_cmd;
        $gdbid       = shell::shell($gdb_cmd);
    }
}

sub gdb_session {
    my $gdbid = find_gdb_session() or return;
    my $curwin = Vile::current_window;
    shell::resume_shell($gdbid);
    $curwin->current_window;
}

sub gdb_break {
    my $b        = Vile::current_buffer;
    my $filename = $b->filename;
    $filename =~ s#.*/##;    # Better chance of working with
                             # just the filename.
    my $lineno = $b->dotq;
    my $gdbid = find_gdb_session() or return;
    shell::send_chars( $gdbid, "break $filename:$lineno\n" );
}

sub gdb_step {
    my $gdbid = find_gdb_session() or return;
    shell::send_chars( $gdbid, "step\n" );
}

sub gdb_next {
    my $gdbid = find_gdb_session() or return;
    shell::send_chars( $gdbid, "next\n" );
}

sub gdb_cont {
    my $gdbid = find_gdb_session() or return;
    shell::send_chars( $gdbid, "continue\n" );
}

sub gdb_interrupt {
    my $gdbid = find_gdb_session() or return;
    shell::send_chars( $gdbid, "\003" );
}

1;

__DATA__

=head1 NAME

gdb - run gdb in a vile window

=head1 SYNOPSIS

In .vilerc:

    perl "use gdb"

In [x]vile:

    :gdb
    :gdb-break
    :gdb-step
    :gdb-next
    :gdb-cont

=head1 DESCRIPTION

The B<gdb> module runs C<gdb> in a vile window and tracks changes in the editor.
This must be used with the C<shell.pm> module.

=head2 gdb

Start or rejoin an interactive gdb session.

=head2 gdb-break

Set a breakpoint in gdb.

=head2 gdb-step

Single step in gdb.

=head2 gdb-next

Next in gdb.

=head2 gdb-cont

Continue in gdb.

=head1 AUTHOR

Kevin Buettner

=cut