/
debug.ops
145 lines (93 loc) · 2.42 KB
/
debug.ops
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
139
140
141
142
143
144
145
/*
* Copyright (C) 2002-2011, Parrot Foundation.
*/
/*
** debug.ops
*/
=head1 NAME
debug.ops - Debugging Opcodes
=cut
=head1 DESCRIPTION
Parrot debugger
=cut
=head1 HISTORY
Initial version by Daniel Grunblatt on 2002.5.19
=cut
###############################################################################
=head2 Parrot debug operations
=over 4
=cut
########################################
=item B<debug_init>()
Init the Parrot debugger, must be called before any other debug op.
=cut
op debug_init() :base_debug {
Parrot_debugger_init(interp);
}
########################################
=item B<debug_load>(inconst STR)
Load a Parrot source file for the current program.
=cut
op debug_load(inconst STR) :base_debug {
Parrot_debugger_load(interp, $1);
}
########################################
=item B<debug_break>()
Break execution and drop into the debugger.
If we are already into the debugger and is the first time we are
called set a breakpoint.
When you re run/continue the program begin debugged it will pay
no attention to the debug ops.
=cut
op debug_break() :base_debug {
Parrot_debugger_break(interp, cur_opcode);
}
########################################
=item B<debug_print>()
Print all the Parrot registers at once.
=cut
op debug_print() :base_debug {
if (!interp->pdb) {
opcode_t * const handler = Parrot_ex_throw_from_op_args(interp, expr NEXT(),
EXCEPTION_INVALID_OPERATION,
"Initialize debugger with debug_init before using debug_print");
goto ADDRESS(handler);
}
if (!(interp->pdb->state & PDB_BREAK)) {
PDB_print(interp, "I");
PDB_print(interp, "N");
PDB_print(interp, "S");
PDB_print(interp, "P");
}
}
=item B<backtrace>()
Print a backtrace.
=cut
op backtrace() :base_debug {
PDB_backtrace(interp);
}
#######################################
=item B<getline>(out INT)
Get the current line number.
=cut
inline op getline(out INT) {
Parrot_Context_info info;
Parrot_sub_context_get_info(interp, CURRENT_CONTEXT(interp), &info);
$1 = info.line;
}
=item B<getfile>(out STR)
Get the name of the current file.
=cut
inline op getfile(out STR) {
Parrot_Context_info info;
Parrot_sub_context_get_info(interp, CURRENT_CONTEXT(interp), &info);
$1 = info.file;
}
=back
=cut
/*
* Local variables:
* c-file-style: "parrot"
* End:
* vim: expandtab shiftwidth=4 cinoptions='\:2=2' :
*/