annotate src/cli/gdbcli.d @ 1:4a9dcbd9e54f

-files of 0.13 beta -fixes so that it now compiles with the current dmd version
author marton@basel.hu
date Tue, 05 Apr 2011 20:44:01 +0200
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1 /* Ddbg - Win32 Debugger for the D programming language
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
2 * Copyright (c) 2007 Jascha Wetzel
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
3 * All rights reserved. See LICENSE.TXT for details.
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
4 */
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
5 module cli.gdbcli;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
6
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
7 import std.string;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
8 static import std.regexp;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
9 import std.c.stdio : sscanf;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
10 import std.c.string;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
11 import std.demangle;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
12
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
13 import util;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
14 import codeview.codeview;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
15 import breakpoint;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
16 import debugger;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
17 import disasm;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
18 import callstack;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
19 import dbgprocess;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
20 import dbgthread;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
21 import expression.expression_apd;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
22 import expression.datahandler : SymbolValue;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
23 import expression.evaluationcontext;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
24 import cli.userinterface;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
25
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
26 import win32.winbase;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
27 import win32.winuser;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
28 import win32.winnt;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
29
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
30 /**************************************************************************************************
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
31
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
32 **************************************************************************************************/
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
33 class GDBCLI : UserInterfaceBase
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
34 {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
35 string[] lastcmd;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
36
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
37 uint current_frame_level;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
38
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
39 string prompt,
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
40 command_line,
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
41 debuggee;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
42 bool fullname = false,
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
43 quit;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
44
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
45 /**********************************************************************************************
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
46
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
47 **********************************************************************************************/
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
48 this()
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
49 {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
50 prompt = "(gdb) ";
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
51 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
52
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
53 /**********************************************************************************************
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
54
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
55 **********************************************************************************************/
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
56 void init(string[] args)
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
57 {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
58 DbgIO.println(WELCOME_STRING);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
59 if ( args.length < 2 )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
60 throw new DebuggerException("Usage: ddbg -cli=gdb [-cmd=<commands>] [-fullname] -args <exe file> [arguments]");
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
61
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
62 bool read_args = false;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
63 Lfe: foreach ( int i, a; args )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
64 {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
65 switch ( a )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
66 {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
67 case "-fullname":
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
68 case "--fullname":
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
69 fullname = true;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
70 break;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
71 case "-args":
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
72 case "--args":
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
73 read_args=true;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
74 break;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
75 default:
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
76 debuggee = a;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
77 if ( read_args )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
78 {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
79 if ( find(a, ' ') >= 0 )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
80 command_line = "\""~a~"\"";
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
81 else
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
82 command_line = a;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
83 if ( args.length > i+1 )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
84 command_line ~= " "~join(args[i+1..$], " ");
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
85 break Lfe;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
86 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
87 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
88 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
89
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
90 dbg = new Debugger(debuggee, this);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
91 dbg.create_new_console = true;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
92 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
93
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
94 int start()
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
95 {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
96 while ( !quit )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
97 {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
98 try readCommand();
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
99 catch ( Exception e )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
100 DbgIO.println(e.msg);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
101 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
102 return 0;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
103 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
104
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
105 /**********************************************************************************************
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
106
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
107 **********************************************************************************************/
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
108 void singleStep()
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
109 {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
110 DbgIO.println(describeLocation(dbg.current_address));
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
111 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
112
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
113 /**********************************************************************************************
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
114
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
115 **********************************************************************************************/
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
116 void exitProcess()
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
117 {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
118 DbgIO.println("Program exited");
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
119 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
120
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
121 /**********************************************************************************************
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
122
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
123 **********************************************************************************************/
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
124 void loadedDLL(DLL dll)
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
125 {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
126 if( dll !is null && dll.image.name.length )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
127 DbgIO.writeln(dll.image.name~" loaded");
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
128 else
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
129 DbgIO.writeln("unknown DLL loaded");
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
130 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
131
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
132 /**********************************************************************************************
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
133
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
134 **********************************************************************************************/
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
135 void win32exception(uint threadId, EXCEPTION_RECORD* exrec)
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
136 {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
137 DbgIO.println(
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
138 "Program received signal SIG Unhandled Exception: %s(0x%x) at 0x%x",
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
139 getExceptionName(exrec.ExceptionCode), exrec.ExceptionCode, exrec.ExceptionAddress //describeLocation(dbg.current_address)
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
140 );
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
141 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
142
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
143 /**********************************************************************************************
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
144
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
145 **********************************************************************************************/
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
146 void exception(uint threadId, string class_name, string msg, size_t obj_ptr)
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
147 {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
148 DbgIO.println(
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
149 "Program received signal SIG Unhandled D Exception (%s%s) at %s",
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
150 class_name, msg.length>0?" \""~msg~"\"":"", describeLocation(dbg.current_address)
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
151 );
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
152 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
153
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
154 /**********************************************************************************************
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
155
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
156 **********************************************************************************************/
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
157 void userInterrupt()
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
158 {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
159 DbgIO.println("User interrupt at %s", describeLocation(dbg.current_address));
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
160 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
161
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
162 /**********************************************************************************************
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
163
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
164 **********************************************************************************************/
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
165 bool breakpoint(int index, Breakpoint bp, DbgThread thread)
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
166 {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
167 if ( bp.file is null || bp.line == 0 )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
168 DbgIO.println("Unknown breakpoint hit at %s", describeLocation(bp.address));
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
169 else
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
170 DbgIO.println("\032\032%s:%d:0:begmidl:0x%08x", fullname?dbg.getFullSourcePath(bp.file):bp.file, bp.line, bp.address);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
171 return true;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
172 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
173
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
174 /**********************************************************************************************
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
175
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
176 **********************************************************************************************/
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
177 void debugString(string str)
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
178 {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
179 printf("Error OUTPUT DEBUG STRING:\n%s\n", toStringz(str));
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
180 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
181
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
182 /**********************************************************************************************
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
183 Command line parser. Gets called when debuggee is suspended.
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
184 **********************************************************************************************/
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
185 bool parseCommand(string input)
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
186 {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
187 if ( strip(input).length > 0 )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
188 {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
189 auto r = std.regexp.RegExp("(([^\" \\t]+)|(\"[^\"]+\"))+");
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
190 lastcmd.length = 0;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
191 foreach ( m; r.search(strip(input)) )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
192 lastcmd ~= r.match(0);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
193 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
194 if ( lastcmd.length <= 0 )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
195 return false;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
196
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
197 int slash_pos = find(lastcmd[0], '/');
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
198 if ( slash_pos >= 0 ) {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
199 lastcmd ~= lastcmd[0];
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
200 lastcmd[0] = lastcmd[0][0..slash_pos];
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
201 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
202
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
203 switch ( lastcmd[0] )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
204 {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
205 case "help":
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
206 DbgIO.println("GDB emulation mode - no help available, yet");
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
207 break;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
208 case "delete":
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
209 if ( lastcmd.length < 2 )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
210 DbgIO.println("Warning: too few arguments for set");
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
211 else switch ( lastcmd[1] )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
212 {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
213 case "breakpoints":
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
214 if ( lastcmd.length < 3 )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
215 {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
216 foreach ( uint i; dbg.breakpoints.keys )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
217 dbg.removeBreakpoint(i);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
218 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
219 else if ( !isNumeric(lastcmd[2]) )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
220 DbgIO.println("Warning: invalid breakpoint index '%s'", lastcmd[2]);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
221 else
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
222 dbg.removeBreakpoint(cast(uint)atoi(lastcmd[2]));
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
223 break;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
224 default:
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
225 DbgIO.println("Warning: unknown argument %s", lastcmd[1]);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
226 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
227 break;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
228 case "set":
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
229 if ( lastcmd.length < 2 )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
230 DbgIO.println("Warning: too few arguments for set");
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
231 else switch ( lastcmd[1] )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
232 {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
233 case "prompt":
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
234 if ( lastcmd.length < 3 )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
235 DbgIO.println("Warning: too few arguments for set prompt");
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
236 else
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
237 prompt = lastcmd[2];
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
238 break;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
239 case "args":
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
240 if ( dbg.process_loaded )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
241 DbgIO.println("Warning: process already started");
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
242 command_line = debuggee~" "~join(lastcmd[2..$], " ");
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
243 break;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
244 default:
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
245 DbgIO.println("Warning: unknown variable %s", lastcmd[1]);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
246 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
247 break;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
248 case "info":
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
249 if ( lastcmd.length < 2 )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
250 DbgIO.println("Warning: too few arguments for info");
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
251 else
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
252 {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
253 switch ( lastcmd[1] )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
254 {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
255 case "locals":
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
256 if ( dbg.process_loaded )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
257 {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
258 uint scope_address = dbg.getScopeAddress(current_frame_level);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
259 ScopeSymbol scope_sym = dbg.images.findProcedureSymbol(scope_address);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
260 for ( ; scope_sym !is null; scope_sym = scope_sym.parent_scope )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
261 {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
262 if ( scope_sym is null )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
263 DbgIO.println("No valid scope active");
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
264 else
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
265 evalStackSymbols(scope_sym.symbols.stack_symbols);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
266 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
267 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
268 break;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
269 case "args":
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
270 if ( dbg.process_loaded )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
271 {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
272 uint scope_address = dbg.getScopeAddress(current_frame_level);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
273 ScopeSymbol scope_sym = dbg.images.findProcedureSymbol(scope_address);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
274 for ( ; scope_sym !is null; scope_sym = scope_sym.parent_scope )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
275 {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
276 if ( scope_sym is null )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
277 DbgIO.println("No valid scope active");
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
278 else
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
279 {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
280 auto psym = cast(ProcedureSymbol)scope_sym;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
281 if ( psym !is null )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
282 evalStackSymbols(psym.arguments.stack_symbols);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
283 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
284 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
285 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
286 break;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
287 case "registers":
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
288 printRegisterDump(dbg.process.threads[dbg.thread_id]);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
289 break;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
290 case "frame":
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
291 uint scope_address = dbg.getScopeAddress(current_frame_level);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
292 ubyte[] frame = dbg.stack.getFrame(current_frame_level);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
293 Location loc = dbg.images.findLocation(scope_address);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
294 DbgIO.print("Stack level %d, frame at ", current_frame_level);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
295 if ( loc.scope_sym !is null ) {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
296 ProcedureSymbol psym = cast(ProcedureSymbol)loc.scope_sym;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
297 DbgIO.println("0x%x:", loc.getCodeBase + psym.cvdata.offset + psym.cvdata.debug_start);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
298 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
299 else
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
300 DbgIO.println("0x%x:", dbg.current_address);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
301
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
302 DbgIO.print(" eip = 0x%x in %s (",
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
303 loc.address, loc.scope_sym is null?"??":loc.scope_sym.name_notype
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
304 );
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
305
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
306 if ( loc.codeblock !is null )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
307 DbgIO.print("%s:%d", loc.file, loc.line);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
308 else if ( loc.mod !is null )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
309 DbgIO.write(loc.mod.name);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
310 else
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
311 {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
312 DLL dll = dbg.process.findDLL(loc.address);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
313 if ( dll !is null )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
314 DbgIO.write(dll.image.name);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
315 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
316
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
317 DbgIO.println("); saved eip 0x%x", (cast(uint[])frame)[1]);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
318 break;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
319 default:
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
320 DbgIO.println("Warning: unknown argument %s", lastcmd[1]);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
321 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
322 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
323 break;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
324 // select frame
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
325 case "select-frame":
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
326 if ( lastcmd.length > 1 )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
327 current_frame_level = cast(uint)atoi(lastcmd[1]);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
328 DbgIO.println("Current frame level is %d", current_frame_level);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
329 break;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
330 // add breakpoint
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
331 case "tbreak":
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
332 case "clear":
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
333 case "break":
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
334 int index;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
335 if ( lastcmd.length < 2 ) {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
336 DbgIO.println("invalid syntax - see help for details");
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
337 break;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
338 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
339 Location loc = new Location(lastcmd[1]);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
340 loc.bind(dbg.images, dbg.source_search_paths);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
341 if ( loc is null )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
342 break;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
343 if ( lastcmd.length > 2 )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
344 index = cast(int)atoi(lastcmd[2]);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
345
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
346 if ( lastcmd[0] == "clear" )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
347 {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
348 Breakpoint bp = dbg.getBreakpoint(loc, index);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
349 dbg.removeBreakpoint(index);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
350 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
351 else
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
352 {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
353 Breakpoint bp;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
354 if ( lastcmd[0] == "tbreak" )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
355 index = -1;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
356 else if ( index <= 0 && dbg.breakpoints.length > 0 )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
357 index = dbg.breakpoints.keys.dup.sort[$-1]+1;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
358 bp = dbg.setBreakpoint(loc, index, 0);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
359 DbgIO.println("Breakpoint %d at 0x%08x", index, bp.address);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
360 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
361 break;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
362 // add source search path
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
363 case "directory":
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
364 if ( lastcmd.length > 1 )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
365 {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
366 string sp = lastcmd[1].dup;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
367 if ( find(sp, '/') >= 0 )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
368 sp = replace(sp, "/", "\\");
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
369 if ( sp[$-1] != '\\' )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
370 sp ~= '\\';
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
371 dbg.source_search_paths ~= sp;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
372 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
373 else
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
374 DbgIO.println("usage: ssp <search_path>");
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
375 break;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
376 // quit
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
377 case "quit":
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
378 case "q":
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
379 dbg.abort = true;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
380 quit = true;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
381 return true;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
382 // run/continue
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
383 case "cont":
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
384 case "run":
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
385 case "start":
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
386 if ( dbg.process_loaded ) {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
387 dbg.single_step = false;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
388 dbg.paused = false;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
389 return true;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
390 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
391 else {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
392 dbg.start(command_line);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
393 return true;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
394 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
395 // single-step
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
396 case "nexti":
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
397 dbg.single_step = true;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
398 dbg.activateSingleStep(true);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
399 return true;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
400 // step over
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
401 case "next":
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
402 if ( dbg.step(StepMode.e_over) )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
403 return true;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
404 break;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
405 // step into
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
406 case "step":
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
407 if ( dbg.step(StepMode.e_in) )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
408 return true;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
409 break;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
410 // step out
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
411 case "finish":
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
412 if ( dbg.step(StepMode.e_out) )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
413 return true;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
414 break;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
415 // unwind stack
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
416 case "bt":
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
417 unwindStack();
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
418 break;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
419 case "print":
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
420 case "output":
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
421 if ( dbg.process_loaded && lastcmd.length > 1 )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
422 {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
423 string expr;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
424 if ( lastcmd[1][0] == '/' )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
425 expr = lastcmd[2];
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
426 else
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
427 expr = lastcmd[1];
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
428 try DbgIO.println(symbolValueToString(dbg.handleData(dbg.evaluateExpression(expr), false)));
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
429 catch ( EvaluationException e ) {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
430 DbgIO.writeln(e.toString);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
431 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
432 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
433 break;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
434 case "disassemble":
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
435 if ( !dbg.process_loaded )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
436 break;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
437
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
438 uint start_address = dbg.current_address;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
439 if ( lastcmd.length > 1 )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
440 sscanf(toStringz(lastcmd[1]), "%x", &start_address);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
441 else
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
442 {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
443 Location loc = dbg.images.findLocation(dbg.current_address);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
444 if ( loc.scope_sym !is null ) {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
445 ProcedureSymbol psym = cast(ProcedureSymbol)loc.scope_sym;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
446 start_address = loc.getCodeBase + psym.cvdata.offset;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
447 DisAsm.disasm(dbg.process, start_address, start_address+psym.cvdata.proc_length, &printDisassembly);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
448 break;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
449 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
450 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
451 DisAsm.disasm(dbg.process, start_address, 0, &printDisassembly);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
452 break;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
453 case "x":
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
454 uint start_address;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
455 if ( lastcmd.length > 2 )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
456 {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
457 if ( lastcmd[1].length > 2 && lastcmd[1][0..2] == "0x" )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
458 lastcmd[1] = lastcmd[1][2..$];
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
459 sscanf(toStringz(lastcmd[1]), "%x", &start_address);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
460 string count_str = lastcmd[$-1][2..$-2];
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
461 uint count = cast(uint)atoi(count_str);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
462
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
463 dumpMemory(start_address, count);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
464 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
465 else
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
466 DbgIO.println("Warning: too few arguments for x");
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
467 break;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
468 case "whatis":
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
469 if ( dbg.process_loaded && lastcmd.length > 1 )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
470 {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
471 SymbolData sd = dbg.evaluateExpression(lastcmd[1], current_frame_level);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
472 string type = demangle("_D0"~sd.type);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
473 try DbgIO.println("type = %s", type);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
474 catch ( EvaluationException e ) {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
475 DbgIO.writeln(e.toString);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
476 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
477 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
478 break;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
479
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
480
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
481 // list source search paths
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
482 case "lsp":
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
483 foreach ( s; dbg.source_search_paths )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
484 DbgIO.writeln(s);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
485 break;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
486 // list breakpoints
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
487 case "lbp":
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
488 if ( dbg.breakpoints.length <= 0 )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
489 DbgIO.println("no breakpoints set");
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
490 foreach ( uint i, bp; dbg.breakpoints )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
491 DbgIO.println("%d %s", i, bp.toString);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
492 break;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
493 // list temporary breakpoints
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
494 case "ltbp":
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
495 if ( dbg.temp_breakpoints.empty )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
496 DbgIO.println("no temporary breakpoints set");
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
497 foreach ( bp; dbg.temp_breakpoints )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
498 DbgIO.writeln(bp.value.toString);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
499 break;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
500 // list debug modules
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
501 case "lm":
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
502 string[] modules_noinfo;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
503 foreach ( img; dbg.images.images )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
504 {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
505 if ( img.codeView is null )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
506 continue;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
507 foreach ( m; img.codeView.modulesByIndex )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
508 {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
509 string name = m.name;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
510
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
511 if ( m.header.iLib > 0 )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
512 name ~= " from "~img.codeView.libraries[m.header.iLib];
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
513
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
514 if ( lastcmd.length > 1 && find(name, lastcmd[1]) < 0 )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
515 continue;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
516
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
517 bool has_info = false;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
518 with ( m.symbols ) if ( proc_symbols.length+stack_symbols.length+data_symbols.length > 0 )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
519 {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
520 DbgIO.println(
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
521 "%s\n\tSymbols: %d proc %d stack %d data",
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
522 name, proc_symbols.length, stack_symbols.length, data_symbols.length
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
523 );
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
524 has_info = true;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
525 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
526 if ( m.source_module !is null )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
527 {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
528 DbgIO.println("\tSource files:");
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
529 has_info = true;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
530 foreach ( sf; m.source_module.files )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
531 DbgIO.println("\t\t%s", sf.name);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
532 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
533 if ( !has_info )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
534 modules_noinfo ~= name;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
535 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
536 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
537 if ( modules_noinfo.length > 0 )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
538 {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
539 DbgIO.println("Modules without debug information:");
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
540 foreach ( m; modules_noinfo )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
541 DbgIO.println("%s ", m);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
542 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
543 break;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
544 // list source modules
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
545 case "lsm":
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
546 foreach ( img; dbg.images.images )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
547 {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
548 if ( img.codeView is null )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
549 continue;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
550 foreach ( m; img.codeView.modulesByIndex )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
551 {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
552 if ( m.source_module !is null )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
553 {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
554 foreach ( sf; m.source_module.files )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
555 {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
556 if ( lastcmd.length > 1 && find(sf.name, lastcmd[1]) < 0 )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
557 continue;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
558 DbgIO.writeln(sf.name);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
559 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
560 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
561 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
562 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
563 break;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
564 // list all symbols
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
565 case "ls":
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
566 foreach ( img; dbg.images.images )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
567 {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
568 if ( img.codeView is null )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
569 continue;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
570 printSymbols(img.codeView, img.codeView.global_pub.named_symbols, lastcmd.length>1?lastcmd[1]:null);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
571 printSymbols(img.codeView, img.codeView.global_sym.named_symbols, lastcmd.length>1?lastcmd[1]:null);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
572 printSymbols(img.codeView, img.codeView.static_sym.named_symbols, lastcmd.length>1?lastcmd[1]:null);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
573 foreach ( m; img.codeView.modulesByIndex )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
574 printSymbols(img.codeView, m.symbols.named_symbols, lastcmd.length>1?lastcmd[1]:null);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
575 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
576 break;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
577 // list function symbols
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
578 case "lf":
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
579 foreach ( img; dbg.images.images )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
580 {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
581 if ( img.codeView is null )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
582 continue;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
583 printSymbols(img.codeView, img.codeView.global_pub.proc_symbols, lastcmd.length>1?lastcmd[1]:null);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
584 printSymbols(img.codeView, img.codeView.global_sym.proc_symbols, lastcmd.length>1?lastcmd[1]:null);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
585 printSymbols(img.codeView, img.codeView.static_sym.proc_symbols, lastcmd.length>1?lastcmd[1]:null);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
586 foreach ( m; img.codeView.modulesByIndex )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
587 printSymbols(img.codeView, m.symbols.proc_symbols, lastcmd.length>1?lastcmd[1]:null);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
588 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
589 break;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
590 // list data symbols
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
591 case "ld":
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
592 foreach ( img; dbg.images.images )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
593 {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
594 if ( img.codeView is null )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
595 continue;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
596 printSymbols(img.codeView, img.codeView.global_pub.data_symbols, lastcmd.length>1?lastcmd[1]:null);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
597 printSymbols(img.codeView, img.codeView.global_sym.data_symbols, lastcmd.length>1?lastcmd[1]:null);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
598 printSymbols(img.codeView, img.codeView.static_sym.data_symbols, lastcmd.length>1?lastcmd[1]:null);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
599 foreach ( m; img.codeView.modulesByIndex )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
600 printSymbols(img.codeView, m.symbols.data_symbols, lastcmd.length>1?lastcmd[1]:null);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
601 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
602 break;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
603 // list global symbols
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
604 case "lg":
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
605 foreach ( img; dbg.images.images )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
606 {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
607 if ( img.codeView is null )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
608 continue;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
609 printSymbols(img.codeView, img.codeView.global_pub.named_symbols, lastcmd.length>1?lastcmd[1]:null);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
610 printSymbols(img.codeView, img.codeView.global_sym.named_symbols, lastcmd.length>1?lastcmd[1]:null);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
611 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
612 break;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
613 // list global publics
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
614 case "lp":
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
615 foreach ( img; dbg.images.images )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
616 {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
617 if ( img.codeView is null )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
618 continue;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
619 printSymbols(img.codeView, img.codeView.global_pub.named_symbols, lastcmd.length>1?lastcmd[1]:null);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
620 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
621 break;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
622 // delete breakpoint
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
623 case "dbp":
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
624 if ( lastcmd.length > 1 )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
625 {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
626 if ( lastcmd[1] == "*" )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
627 {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
628 foreach ( uint i, bp; dbg.breakpoints )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
629 {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
630 bp.deactivate(dbg.process);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
631 dbg.breakpoints.remove(i);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
632 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
633 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
634 else if ( isNumeric(lastcmd[1]) )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
635 {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
636 if ( !dbg.removeBreakpoint(cast(uint)atoi(lastcmd[1])) )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
637 DbgIO.println("invalid breakpoint index: %s",lastcmd[1]);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
638 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
639 else
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
640 {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
641 Location loc = new Location(lastcmd[1]);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
642 loc.bind(dbg.images, dbg.source_search_paths);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
643 if ( loc !is null )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
644 {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
645 int bp_index;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
646 dbg.getBreakpoint(loc, bp_index);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
647 if ( bp_index >= 0 && !dbg.removeBreakpoint(bp_index) )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
648 DbgIO.println("No breakpoint set at "~lastcmd[1]);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
649 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
650 else
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
651 DbgIO.println("Usage: dbp [<bp index>|<file:line>]");
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
652 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
653 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
654 else
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
655 DbgIO.println("Usage: bp <sourc file>:<line>");
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
656 break;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
657 // dump stack
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
658 case "ds":
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
659 int dump_length;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
660 if ( lastcmd.length > 1 )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
661 dump_length = cast(int)atoi(lastcmd[1])*4;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
662 else
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
663 {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
664 CONTEXT ctx;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
665 if ( dbg.process.threads[dbg.thread_id].getContext(ctx, CONTEXT_CONTROL) )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
666 dump_length = ctx.Ebp-ctx.Esp+8;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
667 if ( dump_length <= 0 )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
668 dump_length = 16*4;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
669 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
670 int top = dbg.stack.data.length>dump_length?dump_length:dbg.stack.data.length;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
671 dumpMemory(dbg.stack.top_ptr, top, dbg.stack.data);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
672 break;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
673 case "dm":
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
674 if ( lastcmd.length < 3 ) {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
675 DbgIO.println("usage: dm <start> <length>");
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
676 break;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
677 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
678 uint start;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
679 sscanf(toStringz(lastcmd[1]), "%x", &start);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
680 dumpMemory(start, cast(uint)atoi(lastcmd[2]));
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
681 break;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
682
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
683 // unknown command
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
684 default:
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
685 DbgIO.println("Warning: Unknown command '%s' ignored!", lastcmd[0]);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
686 break;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
687 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
688
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
689 return false;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
690 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
691
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
692 /**********************************************************************************************
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
693
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
694 **********************************************************************************************/
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
695 void dumpMemory(uint start, uint length, ubyte[] _data=null)
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
696 {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
697 ubyte[] data;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
698 if ( _data is null )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
699 {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
700 data.length = length;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
701 if ( !dbg.process.readProcessMemory(start, data.ptr, data.length) )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
702 return;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
703 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
704 else
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
705 data = _data;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
706 for ( uint i = 0; i < length; ++i )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
707 {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
708 if ( i % (8*4) == 0 )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
709 {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
710 if ( i > 0 )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
711 DbgIO.println("");
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
712 DbgIO.print("0x%08x:", start+i);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
713 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
714 DbgIO.print(" 0x%02x", data[i]);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
715 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
716 DbgIO.println("");
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
717 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
718
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
719 /**********************************************************************************************
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
720
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
721 **********************************************************************************************/
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
722 void evalStackSymbols(StackSymbol[] symbols)
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
723 {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
724 foreach ( sym; symbols )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
725 {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
726 string name = sym.mangled_name;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
727 DbgIO.print("%s = ", name);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
728 try DbgIO.writeln(symbolValueToString(dbg.handleData(dbg.evaluateExpression(name, current_frame_level, sym), true)));
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
729 catch ( EvaluationException e ) {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
730 DbgIO.println(e.msg);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
731 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
732 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
733 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
734
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
735 /**********************************************************************************************
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
736
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
737 **********************************************************************************************/
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
738 void printAsmLine(uint address, string bytes, string asmsource, string symbol, string location, string source)
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
739 {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
740 bool nl = false;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
741 if ( location !is null ) {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
742 DbgIO.print("0x%08x <??>: // ", address);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
743 DbgIO.write(location);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
744 nl = true;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
745 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
746 if ( source !is null )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
747 {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
748 if ( !nl )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
749 DbgIO.print("0x%08x <??>: // ", address);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
750 DbgIO.write(source);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
751 nl = true;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
752 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
753 if ( nl )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
754 DbgIO.println;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
755
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
756 assert(asmsource !is null);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
757 DbgIO.print("0x%08x <??>: ", address, asmsource);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
758
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
759 if ( symbol !is null )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
760 DbgIO.write(symbol);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
761 DbgIO.println;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
762 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
763
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
764 /**********************************************************************************************
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
765 Prints the register contents of the given thread's context.
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
766 **********************************************************************************************/
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
767 void printRegisterDump(DbgThread thread)
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
768 {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
769 CONTEXT ctx;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
770 if ( thread.getContext(ctx) )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
771 {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
772 DbgIO.println("eax\t0x%x -\nebx\t0x%x -\necx\t0x%x -\nedx\t0x%x -", ctx.Eax, ctx.Ebx, ctx.Ecx, ctx.Edx);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
773 DbgIO.println("cs\t0x%x -\nds\t0x%x -\nes\t0x%x -\nfs\t0x%x -", ctx.SegCs, ctx.SegDs, ctx.SegEs, ctx.SegFs);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
774 DbgIO.println("gs\t0x%x -\nss\t0x%x -\nedi\t0x%x -\nesi\t0x%x -", ctx.SegGs, ctx.SegSs, ctx.Edi, ctx.Esi);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
775 DbgIO.println("ebp\t0x%x -\nesp\t0x%x -\neip\t0x%x -\neflags\t0x%x -", ctx.Ebp, ctx.Esp, ctx.Eip, ctx.EFlags);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
776 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
777 else
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
778 DbgIO.println("Warning: Couldn't get main thread's context");
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
779 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
780
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
781 /**********************************************************************************************
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
782
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
783 **********************************************************************************************/
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
784 string symbolValueToString(SymbolValue val)
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
785 {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
786 string str;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
787 if ( val.name !is null )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
788 str = val.name~" = ";
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
789 if ( val.value !is null )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
790 str ~= val.value;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
791 else
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
792 {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
793 if ( val.children.length > 0 )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
794 {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
795 str ~= "{";
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
796 bool first = true;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
797 foreach ( c; val.children )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
798 {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
799 if ( first )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
800 first = false;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
801 else
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
802 str ~= ",";
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
803 str ~= symbolValueToString(c);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
804 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
805 str ~= "}";
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
806 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
807 else
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
808 str ~= "{}";
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
809 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
810 return str;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
811 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
812
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
813 /**********************************************************************************************
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
814 Read command and call CLI supplied parser function.
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
815 Gets called when debuggee is suspended.
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
816 **********************************************************************************************/
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
817 bool readCommand()
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
818 {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
819 if ( cmdQueue.length > 0 )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
820 {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
821 string cmd = strip(cmdQueue[0]);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
822 cmdQueue = cmdQueue[1..$];
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
823 DbgIO.writeln(prompt~cmd);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
824 return parseCommand(cmd);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
825 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
826 else {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
827 DbgIO.write(prompt);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
828 string input = DbgIO.readln();
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
829 return parseCommand(input);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
830 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
831 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
832 }