annotate src/cli/ddbgcli.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 a5fb1bc967e6
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.ddbgcli;
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 minidump;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
14 import container;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
15 import util;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
16 import codeview.codeview;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
17 import breakpoint;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
18 import debugger;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
19 import disasm;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
20 import callstack;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
21 import dbgprocess;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
22 import dbgthread;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
23 import expression.expression_apd;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
24 import expression.datahandler : SymbolValue, DataHandler;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
25 import expression.evaluationcontext;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
26 import cli.userinterface;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
27
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
28 import win32.winbase;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
29 import win32.winuser;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
30 import win32.winnt;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
31 import win32.dbghelp;
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 /**************************************************************************************************
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 **************************************************************************************************/
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
36 class DdbgCLI : UserInterfaceBase
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
37 {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
38 const int PRINT_SOURCE_LINES = 3;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
39
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
40 string[] lastcmd,
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
41 onexCommands,
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
42 ontermCommands;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
43 string debuggee,
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
44 command_line;
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 uint current_frame_level;
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 bool quit;
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 const ubyte CPU_REGISTERS = 1,
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
51 FPU_REGISTERS = 2,
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
52 MMX_REGISTERS = 4,
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
53 SSE_REGISTERS = 8;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
54 ubyte dump_registers = CPU_REGISTERS;
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 uint lastEvaluationDepth = 1;
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 bool auto_find_scope_frame, /// find frame of last active scope if current frame has no source/symbols
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
59 jump_to_last_known_location_on_exception = true;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
60
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
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
63 **********************************************************************************************/
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
64 void init(string[] args)
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
65 {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
66 DbgIO.println(WELCOME_STRING);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
67 if ( args.length < 2 )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
68 throw new DebuggerException("Usage: ddbg [-cli=<mode>] [-cmd=<commands>] <exe file> [arguments]");
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
69
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
70 debuggee = args[1];
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
71 foreach ( inout arg; args )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
72 {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
73 if ( find(arg, ' ') >= 0 )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
74 arg = "\""~arg~"\"";
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
75 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
76 command_line = join(args[1..$], " ");
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
77
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
78 dbg = new Debugger(debuggee, this);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
79 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
80
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
81 int start()
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
82 {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
83 while ( !quit )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
84 {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
85 debug
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
86 readCommand();
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
87 else
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 try readCommand();
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
90 catch ( Exception e )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
91 DbgIO.println(e.msg);
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 return 0;
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
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
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
99 **********************************************************************************************/
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
100 void singleStep()
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 DbgIO.println(describeLocation(dbg.current_address));
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 exitProcess()
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("Process terminated");
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
111 cmdQueue ~= ontermCommands;
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 **********************************************************************************************/
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
117 void loadedDLL(DLL dll)
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
118 {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
119 if( dll !is null && dll.image.name.length ) {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
120 DbgIO.write(dll.image.name);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
121 DbgIO.println(" loaded at 0x%08x", dll.base);
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 else
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
124 DbgIO.writeln("unknown DLL loaded");
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
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
127 /**********************************************************************************************
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
128
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
129 **********************************************************************************************/
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
130 void win32exception(uint threadId, EXCEPTION_RECORD* exrec)
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 DbgIO.println(
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
133 "Unhandled Exception: %s(0x%x) at %s thread(%d)",
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
134 getExceptionName(exrec.ExceptionCode), exrec.ExceptionCode, describeLocation(dbg.current_address), threadId
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
135 );
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
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
138 /**********************************************************************************************
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
139
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 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
142 {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
143 if ( jump_to_last_known_location_on_exception )
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 uint index;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
146 current_frame_level = 0;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
147 Location loc = dbg.images.findLocation(dbg.current_address);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
148
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
149 if ( loc.codeblock is null )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
150 {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
151 dbg.stack.firstFrame(index);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
152 ubyte[] frame = dbg.stack.prevFrame(index, index);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
153 while ( loc.codeblock is null && frame !is null )
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 uint ret_adr = (cast(uint[])frame)[1];
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
156 loc = dbg.images.findLocation(ret_adr);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
157 frame = dbg.stack.prevFrame(index, index);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
158 ++current_frame_level;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
159 }
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 DbgIO.println("Unhandled D Exception (%s", class_name);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
164 DbgIO.write(msg.length>0?" \""~msg~"\"":"");
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
165 DbgIO.println(") at %s thread(%d)", describeLocation(dbg.current_address), threadId);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
166 cmdQueue ~= onexCommands;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
167 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
168
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
169 /**********************************************************************************************
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
170
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
171 **********************************************************************************************/
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
172 void userInterrupt()
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 DbgIO.println("User interrupt at %s", describeLocation(dbg.current_address));
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 /**********************************************************************************************
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 **********************************************************************************************/
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
180 bool breakpoint(int index, Breakpoint bp, DbgThread thread)
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 if ( bp.hardware )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
183 {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
184 DbgIO.println("Hardware breakpoint for 0x%x hit at %s thread(%d)",
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
185 bp.address, describeLocation(dbg.current_address), thread.id
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 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
188 else if ( bp.file is null || bp.line == 0 )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
189 DbgIO.println("Unknown breakpoint hit at %s thread(%d)", describeLocation(bp.address), thread.id);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
190 else
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
191 {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
192 string[] source = dbg.getSourceFile(bp.file);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
193 string source_line;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
194 if ( source !is null && bp.line <= source.length )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
195 source_line = source[bp.line-1];
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 if ( !bp.temporary )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
198 DbgIO.print("Breakpoint %d hit at ", index);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
199 DbgIO.println("%s:%d 0x%x thread(%d)", bp.file, bp.line, bp.address, thread.id);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
200 if ( source_line.length > 0 )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
201 DbgIO.writeln(source_line);
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 return true;
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
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
206 /**********************************************************************************************
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
207
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
208 **********************************************************************************************/
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
209 void debugString(string str)
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
210 {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
211 printf("OUTPUT DEBUG STRING:\n%s\n", toStringz(str));
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
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
214 /**********************************************************************************************
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
215 Command line parser. Gets called when debuggee is suspended.
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
216 **********************************************************************************************/
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
217 bool parseCommand(string input)
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 if ( strip(input).length > 0 )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
220 {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
221 auto r = std.regexp.RegExp("(([^\" \\t]+)|(\"[^\"]+\"))+");
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
222 lastcmd.length = 0;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
223 foreach ( m; r.search(input) )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
224 lastcmd ~= r.match(0);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
225 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
226 if ( lastcmd.length <= 0 )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
227 return false;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
228
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
229 switch ( lastcmd[0] )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
230 {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
231 case "help":
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
232 case "h":
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
233 case "?":
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
234 DbgIO.write(import("ddbg_help.txt"));
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
235 break;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
236 case "=":
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
237 if ( !dbg.process_loaded && dbg.miniDump is null )
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 if ( lastcmd.length > 1 )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
240 {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
241 try DbgIO.writeln(symbolValueToString(dbg.handleData(dbg.evaluateExpression(lastcmd[1], current_frame_level), false)));
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
242 catch ( EvaluationException e ) {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
243 DbgIO.writeln(e.toString);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
244 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
245 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
246 break;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
247 case "arg":
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
248 if ( dbg.process_loaded )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
249 DbgIO.println("Warning: process already started");
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
250 command_line = debuggee~" "~join(lastcmd[1..$], " ");
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
251 break;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
252 // add breakpoint
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
253 case "bp":
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
254 int index;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
255 if ( lastcmd.length < 2 ) {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
256 DbgIO.println("invalid syntax - see help for details");
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
257 break;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
258 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
259
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
260 int pos = find(lastcmd[1], '#');
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
261 uint threadId;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
262 if ( pos > 0 )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
263 {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
264 threadId = cast(uint)atoi(lastcmd[1][pos+1..$]);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
265 lastcmd[1] = lastcmd[1][0..pos];
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 Location loc = new Location(lastcmd[1]);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
268 loc.bind(dbg.images, dbg.source_search_paths);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
269 if ( lastcmd.length > 2 )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
270 index = cast(int)atoi(lastcmd[2]);
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 Breakpoint bp;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
273 if ( index <= 0 && dbg.breakpoints.length > 0 )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
274 index = dbg.breakpoints.keys.dup.sort[$-1]+1;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
275 bp = dbg.setBreakpoint(loc, index, threadId);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
276 DbgIO.println("Breakpoint set: %s", bp.toString);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
277 break;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
278 // delete breakpoint
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
279 case "dbp":
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
280 if ( lastcmd.length > 1 )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
281 {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
282 if ( lastcmd[1] == "*" )
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 foreach ( uint i; dbg.breakpoints.keys )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
285 dbg.removeBreakpoint(i);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
286 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
287 else if ( isNumeric(lastcmd[1]) )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
288 {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
289 if ( !dbg.removeBreakpoint(cast(uint)atoi(lastcmd[1])) )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
290 DbgIO.println("invalid breakpoint index: %s",lastcmd[1]);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
291 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
292 else
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
293 {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
294 Location loc = new Location(lastcmd[1]);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
295 loc.bind(dbg.images, dbg.source_search_paths);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
296 if ( loc !is null )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
297 {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
298 int bp_index;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
299 dbg.getBreakpoint(loc, bp_index);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
300 if ( bp_index >= 0 && !dbg.removeBreakpoint(bp_index) )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
301 DbgIO.println("No breakpoint set at "~lastcmd[1]);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
302 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
303 else
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
304 DbgIO.println("dbp [<source file>:<line>|#index|*]");
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 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
307 else
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
308 DbgIO.println("dbp [<source file>:<line>|#index|*]");
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
309 break;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
310 // set evaluation depth
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
311 case "er":
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
312 lastcmd.length = 1;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
313 if ( dbg.evaluationDepth > 1 ) {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
314 lastEvaluationDepth = dbg.evaluationDepth;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
315 lastcmd ~= "1";
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 else
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
318 lastcmd ~= .toString(lastEvaluationDepth);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
319 case "ed":
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
320 if ( lastcmd.length < 2 || !isNumeric(lastcmd[1]) )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
321 DbgIO.println("Usage: ed <depth>");
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
322 else {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
323 dbg.evaluationDepth = cast(int)atoi(lastcmd[1]);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
324 DbgIO.println("Expression evaluation depth is %d", dbg.evaluationDepth);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
325 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
326 break;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
327 case "el":
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
328 if ( lastcmd.length < 2 || !isNumeric(lastcmd[1]) )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
329 DbgIO.println("Usage: el <length>");
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
330 else {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
331 DataHandler.max_elem_count = cast(int)atoi(lastcmd[1]);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
332 DbgIO.println("Array evaluation length is %d", DataHandler.max_elem_count);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
333 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
334 break;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
335 // select frame
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
336 case "f":
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
337 if ( lastcmd.length > 1 )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
338 current_frame_level = cast(uint)atoi(lastcmd[1]);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
339 DbgIO.println("Current frame level is %d", current_frame_level);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
340 break;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
341 // image base address
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
342 case "ii":
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
343 foreach ( img; dbg.images.images )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
344 {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
345 uint ibase = img.imageBase;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
346 DbgIO.println("ImageBase\t0x%x", ibase);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
347 DbgIO.println("CodeBase\t0x%x", img.getCodeBase);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
348 DbgIO.println("Sections:\nname\t\taddress\t\tsize\t\tcharacteristics");
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
349 foreach ( s; img.sections )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
350 with ( *s.header ) DbgIO.println("%s\t0x%08x\t0x%08x\t0x%08x", cast(char[8])Name, ibase+VirtualAddress, Misc.VirtualSize, Characteristics);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
351 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
352 break;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
353 // jump to last known source frame
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
354 case "jkf":
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
355 jump_to_last_known_location_on_exception = !jump_to_last_known_location_on_exception;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
356 DbgIO.println("%s to from of last known source location on exception",
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
357 jump_to_last_known_location_on_exception?"Jumping":"Not jumping"
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
358 );
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
359 break;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
360 // walk memory
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
361 case "mi":
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
362 if ( !dbg.process_loaded )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
363 break;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
364 uint filteredStates = MEM_COMMIT;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
365 foreach ( lc; lastcmd[1..$] )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
366 {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
367 switch ( lc )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
368 {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
369 case "free": filteredStates |= MEM_FREE; break;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
370 case "rsrv": filteredStates |= MEM_RESERVE; break;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
371 default:
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 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
374
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
375 MEMORY_BASIC_INFORMATION[] mbis = dbg.process.walkMemory;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
376
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
377 DbgIO.println("Base AlcBase AlcProt RgnSize Stat Protect Type");
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
378 foreach ( mbi; mbis )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
379 {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
380 if ( (mbi.State & filteredStates) == 0 )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
381 continue;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
382
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
383 string state;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
384 switch ( mbi.State )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
385 {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
386 case MEM_COMMIT: state = "comt"; break;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
387 case MEM_FREE: state = "free"; break;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
388 case MEM_RESERVE: state = "rsrv"; break;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
389 default: state = "unkn"; break;
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
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
392 string type;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
393 switch ( mbi.Type )
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 case MEM_IMAGE: type = "imag"; break;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
396 case MEM_MAPPED: type = "mapd"; break;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
397 case MEM_PRIVATE: type = "priv"; break;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
398 default: type = "unkn"; break;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
399 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
400
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
401 string protectName(uint prot)
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
402 {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
403 string protStr;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
404 switch ( prot & 0xff )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
405 {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
406 case 0: protStr = "?"; break;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
407 case PAGE_EXECUTE: protStr = "x"; break;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
408 case PAGE_EXECUTE_READ: protStr = "xr"; break;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
409 case PAGE_EXECUTE_READWRITE: protStr = "xrw"; break;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
410 case PAGE_EXECUTE_WRITECOPY: protStr = "xwc"; break;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
411 case PAGE_NOACCESS: protStr = "na"; break;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
412 case PAGE_READONLY: protStr = "ro"; break;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
413 case PAGE_READWRITE: protStr = "rw"; break;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
414 case PAGE_WRITECOPY: protStr = "wc"; break;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
415 default: protStr = format("%02x", prot & 0xff); break;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
416 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
417 protStr ~= " ";
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
418 if ( prot & PAGE_GUARD )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
419 protStr ~= "g";
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
420 if ( prot & PAGE_NOCACHE )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
421 protStr ~= "nc";
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
422 return protStr;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
423 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
424
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
425 DbgIO.println("%08x %08x %- 7s %08x %s %- 7s %s",
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
426 cast(size_t)mbi.BaseAddress, cast(size_t)mbi.AllocationBase, protectName(mbi.AllocationProtect),
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
427 mbi.RegionSize, state, protectName(mbi.Protect), type
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
428 );
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
429 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
430 break;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
431 // list breakpoints
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
432 case "lbp":
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
433 if ( dbg.breakpoints.length <= 0 )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
434 DbgIO.println("no breakpoints set");
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
435 foreach ( uint i, bp; dbg.breakpoints )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
436 DbgIO.println("%d %s", i, bp.toString);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
437 break;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
438 // ldll
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
439 case "ldll":
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
440 if ( !dbg.process_loaded )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
441 break;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
442 DbgIO.println("Base Name");
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
443 foreach ( dll; dbg.process.loaded_dlls )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
444 DbgIO.println("%08x %s", dll.base, dll.image.name);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
445 break;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
446 // list temporary breakpoints
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
447 case "ltbp":
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
448 if ( dbg.temp_breakpoints.empty )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
449 DbgIO.println("no temporary breakpoints set");
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
450 foreach ( bp; dbg.temp_breakpoints )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
451 DbgIO.writeln(bp.value.toString);
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 // list debug modules
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
454 case "lm":
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
455 Module[] modules_noinfo;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
456 foreach ( img; dbg.images.images )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
457 {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
458 foreach ( m; img.codeView.modulesByIndex )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
459 {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
460 string name = m.name;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
461
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
462 if ( m.header.iLib > 0 )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
463 name ~= " from "~img.codeView.libraries[m.header.iLib];
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 if ( lastcmd.length > 1 && find(name, lastcmd[1]) < 0 )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
466 continue;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
467
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
468 bool has_info = false;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
469 with ( m.symbols )
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 if ( proc_symbols.length+stack_symbols.length+data_symbols.length > 0 )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
472 {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
473 DbgIO.println(
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
474 "%s\n\tSymbols: %d proc %d stack %d data",
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
475 name, proc_symbols.length, stack_symbols.length, data_symbols.length
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 has_info = true;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
478 }
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 if ( m.source_module !is null )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
481 {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
482 DbgIO.println("\tSource files:");
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
483 has_info = true;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
484 foreach ( sf; m.source_module.files )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
485 DbgIO.println("\t\t%s", sf.name);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
486 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
487 if ( !has_info )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
488 modules_noinfo ~= m;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
489 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
490 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
491 if ( modules_noinfo.length > 0 )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
492 {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
493 DbgIO.println("Modules without debug information:");
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
494 foreach ( img; dbg.images.images )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
495 {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
496 foreach ( m; modules_noinfo )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
497 {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
498 string name = m.name;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
499
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
500 if ( m.header.iLib > 0 )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
501 name ~= " from "~img.codeView.libraries[m.header.iLib];
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
502
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
503 DbgIO.println("%s #segs=%d", name, m.seginfos.length);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
504 if ( m.source_module !is null )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
505 {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
506 DbgIO.println("\tSource files:");
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
507 foreach ( sf; m.source_module.files )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
508 DbgIO.println("\t\t%s", sf.name);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
509 }
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 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
512 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
513 break;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
514 // list source modules
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
515 case "lsm":
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
516 uint[string] line_counters;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
517 uint[string] seg_counters;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
518 foreach ( img; dbg.images.images )
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 if ( img.codeView is null )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
521 continue;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
522 foreach ( m; img.codeView.modulesByIndex )
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 if ( m.source_module is null )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
525 continue;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
526 foreach ( sf; m.source_module.files )
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 if ( lastcmd.length > 1 && find(sf.name, lastcmd[1]) < 0 )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
529 continue;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
530 uint lines = sf.lines.length;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
531 if ( (sf.name in line_counters) is null ) {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
532 seg_counters[sf.name] = sf.segments.length;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
533 line_counters[sf.name] = lines;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
534 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
535 else {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
536 seg_counters[sf.name] += sf.segments.length;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
537 line_counters[sf.name] += lines;
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 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
540 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
541 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
542 string[] lc_keys = line_counters.keys.dup;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
543 lc_keys.sort;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
544 foreach ( key; lc_keys )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
545 DbgIO.println("%s\t\tsegs=%d lines=%d", key, seg_counters[key], line_counters[key]);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
546 break;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
547 // list source lines per module
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
548 case "lsl":
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
549 foreach ( img; dbg.images.images )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
550 {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
551 if ( img.codeView is null )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
552 continue;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
553 foreach ( m; img.codeView.modulesByIndex )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
554 {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
555 if ( m.source_module is null )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
556 continue;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
557 DbgIO.println("module %s", m.name);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
558 foreach ( sf; m.source_module.files )
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 DbgIO.println("file %s", sf.name);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
561 if ( lastcmd.length > 1 && find(sf.name, lastcmd[1]) < 0 )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
562 continue;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
563 foreach ( l; sf.lines.reverse )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
564 {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
565 DbgIO.println("line %d", l);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
566 }
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 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
569 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
570 break;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
571 // list all symbols
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
572 case "ls":
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
573 /*
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
574 void dumpSymbolAVL(AVLNode!(NamedSymbol) node, uint indent=0)
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 string indentstr = new char[indent*2];
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
577 indentstr[0..indent*2] = ' ';
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
578 DbgIO.println("%s%s", indentstr, node.value.name_notype);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
579 if ( node.left !is null )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
580 dumpSymbolAVL(node.left, indent+1);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
581 if ( node.right !is null )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
582 dumpSymbolAVL(node.right, indent+1);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
583 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
584 DbgIO.println("AVL dump:");
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
585 dumpSymbolAVL(dbg.image.codeView.globalNamedSymbols.root);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
586 */
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
587 foreach ( img; dbg.images.images )
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 if ( img.codeView is null )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
590 continue;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
591 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
592 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
593 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
594 foreach ( m; img.codeView.modulesByIndex )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
595 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
596 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
597 break;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
598 // list source search paths
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
599 case "lsp":
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
600 foreach ( s; dbg.source_search_paths )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
601 DbgIO.writeln(s);
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 function symbols
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
604 case "lf":
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.proc_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.proc_symbols, lastcmd.length>1?lastcmd[1]:null);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
611 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
612 foreach ( m; img.codeView.modulesByIndex )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
613 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
614 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
615 break;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
616 // list data symbols
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
617 case "ld":
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
618 foreach ( img; dbg.images.images )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
619 {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
620 if ( img.codeView is null )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
621 continue;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
622 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
623 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
624 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
625 foreach ( m; img.codeView.modulesByIndex )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
626 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
627 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
628 break;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
629 // list global symbols
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
630 case "lg":
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
631 foreach ( img; dbg.images.images )
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 if ( img.codeView is null )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
634 continue;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
635 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
636 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
637 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
638 break;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
639 // list global publics
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
640 case "lp":
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
641 foreach ( img; dbg.images.images )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
642 {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
643 if ( img.codeView is null )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
644 continue;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
645 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
646 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
647 break;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
648 // list scope variables
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
649 case "lsv":
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
650 if ( dbg.process_loaded || dbg.miniDump !is null )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
651 evalScopeSymbols();
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
652 break;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
653 // list threads
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
654 case "lt":
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
655 if ( dbg.miniDump !is null )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
656 {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
657 DbgIO.println(" id pri sus location");
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
658 MINIDUMP_THREAD[] threads = dbg.miniDump.threads;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
659 foreach ( thread; threads )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
660 {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
661 CONTEXT* ctx;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
662 ctx = cast(CONTEXT*)dbg.miniDump.rvaToVa(thread.ThreadContext.Rva);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
663 Location loc = dbg.images.findLocation(ctx.Eip);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
664
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
665 DbgIO.println("%s%s%- 6d %- 3d %- 2d %s",
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
666 thread.ThreadId==dbg.thread_id?">":" ", thread.ThreadId==dbg.miniDump.threadInfo.mainThreadId?"*":" ",
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
667 thread.ThreadId, thread.Priority, thread.SuspendCount, describeLocation(loc)
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
668 );
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 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
671 else
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
672 {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
673 DbgIO.println(" id pri sus creation exit kernel user location");
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
674 foreach ( t; dbg.process.threads.values )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
675 {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
676 // id name location pri pri-boost start-info times
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
677 ulong creation,
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
678 exit,
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
679 kernel,
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
680 user;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
681
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
682 t.times(creation, exit, kernel, user);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
683
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
684 CONTEXT ctx;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
685 t.getContext(ctx);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
686 Location loc = dbg.images.findLocation(ctx.Eip);
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 DbgIO.println("%s%s%- 6d %- 3d%s %- 2d %s %s %s %s %s",
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
689 t.id==dbg.thread_id?">":" ", t.id==dbg.process.mainThreadId?"*":" ", t.id,
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
690 t.priority, t.priorityBoost?"b":" ", t.suspendCount,
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
691 formatTicks(creation), formatTicks(exit), formatTicks(kernel), formatTicks(user),
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
692 describeLocation(loc)
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 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
696 break;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
697 // no console
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
698 case "nc":
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
699 dbg.create_new_console = !dbg.create_new_console;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
700 DbgIO.println("Starting debuggee in %s console", dbg.create_new_console?"new":"this");
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
701 break;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
702 // on exception
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
703 case "onex":
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
704 if ( lastcmd.length < 2 )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
705 {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
706 foreach ( cmd; onexCommands )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
707 DbgIO.writeln(cmd[0..$-1]);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
708 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
709 else
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
710 {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
711 onexCommands = null;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
712 string cmdList;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
713 foreach ( cmd; lastcmd[1..$] )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
714 {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
715 if ( cmd[0] == '"' && cmd[$-1] == '"' )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
716 cmdList ~= " "~cmd[1..$-1];
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
717 else
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
718 cmdList ~= " "~cmd;
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 foreach ( cmd; split(cmdList, ";") )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
721 onexCommands ~= strip(cmd)~";";
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
722 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
723 break;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
724 // on termination
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
725 case "onterm":
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
726 if ( lastcmd.length < 2 )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
727 {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
728 foreach ( cmd; ontermCommands )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
729 DbgIO.writeln(cmd[0..$-1]);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
730 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
731 else
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 ontermCommands = null;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
734 string cmdList;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
735 foreach ( cmd; lastcmd[1..$] )
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 if ( cmd[0] == '"' && cmd[$-1] == '"' )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
738 cmdList ~= " "~cmd[1..$-1];
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
739 else
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
740 cmdList ~= " "~cmd;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
741 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
742 foreach ( cmd; split(cmdList, ";") )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
743 ontermCommands ~= strip(cmd)~";";
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
744 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
745 break;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
746 // print source
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
747 case "ps":
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
748 Location loc;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
749 string[] source;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
750
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
751 do
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 ( current_frame_level > 0 )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
754 {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
755 auto frame = dbg.stack.getFrame(current_frame_level);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
756 if ( frame is null )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
757 goto Lnotfound;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
758 uint ret_adr = (cast(uint[])frame)[1];
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
759 loc = dbg.images.findLocation(ret_adr);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
760 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
761 else
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
762 loc = dbg.images.findLocation(dbg.current_address);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
763 debug DbgIO.println("found location %s", loc.file);
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 source = dbg.getSourceFile(loc.file);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
766 if ( source !is null )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
767 break;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
768 if ( auto_find_scope_frame ) {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
769 ++current_frame_level;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
770 continue;
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 Lnotfound:
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
773 DbgIO.writeln("Source file for current location unknown");
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
774 break;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
775 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
776 while( source is null );
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
777
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
778 int start_line, end_line;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
779 if ( lastcmd.length > 1 ) {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
780 start_line = cast(uint)atoi(lastcmd[1]);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
781 end_line = loc.line + start_line;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
782 start_line = loc.line - start_line;
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 else if ( loc.scope_sym !is null )
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 ProcedureSymbol psym = cast(ProcedureSymbol)loc.scope_sym;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
787 auto start_address = loc.getCodeBase + psym.cvdata.offset;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
788 auto start_loc = dbg.images.findLocation(start_address);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
789 auto end_loc = dbg.images.findLocation(start_address+psym.cvdata.proc_length-1);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
790 debug DbgIO.println("address range: 0x%x 0x%x", start_address, start_address+psym.cvdata.proc_length-1);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
791 debug DbgIO.println("lines before prev: %d - %d", start_loc.line, end_loc.line);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
792 end_loc = dbg.images.findPrevSrcLine(end_loc);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
793 start_line = start_loc.line;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
794 if ( end_loc !is null )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
795 end_line = end_loc.line;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
796 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
797 if ( end_line == 0 ) {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
798 start_line = loc.line - PRINT_SOURCE_LINES;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
799 end_line = loc.line + PRINT_SOURCE_LINES;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
800 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
801
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
802 debug DbgIO.println("lines: %d - %d", start_line, end_line);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
803 for ( int l = dmax(0, start_line-1); l < dmin(cast(int)source.length, end_line); ++l )
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 if ( l+1 == loc.line )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
806 DbgIO.write(">");
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
807 DbgIO.writeln(source[l]);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
808 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
809 break;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
810 // quit
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
811 case "q":
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
812 dbg.abort = true;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
813 quit = true;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
814 return true;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
815 // run/continue
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
816 case "r":
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
817 if ( dbg.miniDump !is null ) {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
818 DbgIO.println("Command not valid in post-mortem mode");
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
819 break;
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 if ( dbg.process_loaded ) {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
822 dbg.resume;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
823 return true;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
824 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
825 else {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
826 dbg.start(command_line);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
827 return true;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
828 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
829 // single-step
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
830 case "s":
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
831 if ( dbg.miniDump !is null ) {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
832 DbgIO.println("Command not valid in post-mortem mode");
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
833 break;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
834 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
835 if ( dbg.process_loaded ) {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
836 dbg.single_step = true;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
837 dbg.activateSingleStep(true);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
838 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
839 return true;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
840 // add source search path
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
841 case "sp":
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
842 if ( lastcmd.length > 1 )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
843 {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
844 string sp = lastcmd[1].dup;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
845 if ( sp[$-1] != '\\' )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
846 sp ~= '\\';
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
847 dbg.source_search_paths ~= sp;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
848 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
849 else
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
850 DbgIO.println("usage: sp <search_path>");
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
851 break;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
852 // switch thread
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
853 case "st":
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
854 if ( lastcmd.length < 2 ) {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
855 DbgIO.writeln("Usage: st <threadID>");
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
856 break;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
857 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
858 size_t threadId = cast(size_t)atoi(lastcmd[1]);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
859 if ( dbg.miniDump !is null )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
860 {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
861 foreach ( thread; dbg.miniDump.threads )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
862 {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
863 if ( threadId == thread.ThreadId ) {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
864 dbg.selectThread(threadId);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
865 break;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
866 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
867 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
868 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
869 else
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
870 {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
871 foreach ( t; dbg.process.threads.values )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
872 {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
873 if ( threadId == t.id ) {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
874 dbg.selectThread(threadId);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
875 break;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
876 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
877 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
878 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
879 break;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
880 // step over
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
881 case "ov":
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
882 if ( dbg.miniDump !is null ) {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
883 DbgIO.println("Command not valid in post-mortem mode");
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
884 break;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
885 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
886 if ( dbg.process_loaded && dbg.step(StepMode.e_over) )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
887 {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
888 debug foreach ( bp; dbg.temp_breakpoints )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
889 DbgIO.writeln(bp.value.toString);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
890 return true;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
891 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
892 break;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
893 // step into
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
894 case "in":
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
895 if ( dbg.miniDump !is null ) {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
896 DbgIO.println("Command not valid in post-mortem mode");
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
897 break;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
898 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
899 if ( dbg.process_loaded && dbg.step(StepMode.e_in) )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
900 {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
901 debug foreach ( bp; dbg.temp_breakpoints )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
902 DbgIO.writeln(bp.value.toString);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
903 return true;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
904 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
905 break;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
906 // step out
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
907 case "out":
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
908 if ( dbg.miniDump !is null ) {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
909 DbgIO.println("Command not valid in post-mortem mode");
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
910 break;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
911 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
912 if ( dbg.process_loaded && dbg.step(StepMode.e_out) )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
913 {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
914 debug foreach ( bp; dbg.temp_breakpoints )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
915 DbgIO.writeln(bp.value.toString);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
916 return true;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
917 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
918 break;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
919 // disassemble
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
920 case "da":
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
921 if ( !dbg.process_loaded )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
922 break;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
923
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
924 uint start_address;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
925 if ( current_frame_level > 0 ) {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
926 auto frame = dbg.stack.getFrame(current_frame_level);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
927 start_address = (cast(uint[])frame)[1];
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
928 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
929 else
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
930 start_address = dbg.current_address;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
931
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
932 if ( lastcmd.length > 1 )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
933 sscanf(toStringz(lastcmd[1]), "%x", &start_address);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
934 else
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
935 {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
936 Location loc = dbg.images.findLocation(dbg.current_address);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
937 if ( loc.scope_sym !is null ) {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
938 ProcedureSymbol psym = cast(ProcedureSymbol)loc.scope_sym;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
939 start_address = loc.getCodeBase + psym.cvdata.offset;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
940 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
941 break;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
942 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
943 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
944 DisAsm.disasm(dbg.process, start_address, 0, &printDisassembly);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
945 break;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
946 // disassemble line
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
947 case "dal":
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
948 if ( !dbg.process_loaded )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
949 break;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
950
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
951 int num_lines = 1;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
952 if ( lastcmd.length > 1 )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
953 {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
954 sscanf(toStringz(lastcmd[1]), "%d", &num_lines);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
955 if ( num_lines < 0 )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
956 --num_lines;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
957 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
958
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
959 uint start_address;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
960 if ( current_frame_level > 0 ) {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
961 auto frame = dbg.stack.getFrame(current_frame_level);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
962 start_address = (cast(uint[])frame)[1];
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
963 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
964 else
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
965 start_address = dbg.current_address;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
966
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
967 for ( ; num_lines != 0; num_lines<0?++num_lines:--num_lines )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
968 {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
969 Location loc = dbg.images.findLocation(start_address);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
970 if ( loc is null ) {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
971 DbgIO.println("No source line information available");
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
972 break;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
973 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
974 DisAsm.disasm(
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
975 dbg.process,
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
976 loc.getCodeBase+loc.codeblock.start,
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
977 loc.getCodeBase+loc.codeblock.end,
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
978 &printDisassembly
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
979 );
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
980 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
981 break;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
982 // dump registers
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
983 case "dr":
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
984 if ( lastcmd.length > 1 )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
985 {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
986 foreach ( lc; lastcmd[1..$] )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
987 {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
988 switch ( lc )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
989 {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
990 case "cpu": dump_registers |= CPU_REGISTERS; break;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
991 case "fpu": dump_registers |= FPU_REGISTERS; break;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
992 case "mmx": dump_registers |= MMX_REGISTERS; break;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
993 case "sse": dump_registers |= SSE_REGISTERS; break;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
994 default:
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
995 DbgIO.println("Unknown register set \"%s\"", lc);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
996 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
997 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
998 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
999 if ( dump_registers == 0 ) {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1000 DbgIO.println("No register set selected. See help for usage of \"dr\"");
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1001 break;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1002 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1003 if ( dbg.miniDump !is null )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1004 printRegisterDump(dbg.miniDump.getContext);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1005 else if ( dbg.process_loaded )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1006 printRegisterDump(dbg.process.threads[dbg.thread_id]);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1007 break;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1008 // dump stack
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1009 case "ds":
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1010 if ( !dbg.process_loaded )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1011 break;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1012
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1013 int dump_length;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1014 if ( lastcmd.length > 1 )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1015 dump_length = cast(int)atoi(lastcmd[1])*4;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1016 else
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1017 {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1018 CONTEXT ctx;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1019 if ( dbg.process.threads[dbg.thread_id].getContext(ctx, CONTEXT_CONTROL) )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1020 dump_length = ctx.Ebp-ctx.Esp+8;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1021 if ( dump_length <= 0 )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1022 dump_length = 16*4;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1023 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1024 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
1025 dumpMemory(dbg.stack.top_ptr, top, dbg.stack.data);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1026 break;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1027 case "dm":
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1028 if ( !dbg.process_loaded )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1029 break;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1030
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1031 if ( lastcmd.length < 3 ) {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1032 DbgIO.println("usage: dm <start> <length>");
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1033 break;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1034 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1035 uint start;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1036 sscanf(toStringz(lastcmd[1]), "%x", &start);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1037 dumpMemory(start, cast(uint)atoi(lastcmd[2]));
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1038 break;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1039 case "hwbp":
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1040 int index;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1041 if ( lastcmd.length < 2 ) {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1042 DbgIO.println("invalid syntax - see help for details");
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1043 break;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1044 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1045
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1046 int pos = find(lastcmd[1], '#');
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1047 uint threadId;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1048 if ( pos > 0 )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1049 {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1050 threadId = cast(uint)atoi(lastcmd[1][pos+1..$]);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1051 lastcmd[1] = lastcmd[1][0..pos];
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1052 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1053
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1054 Location loc;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1055
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1056 size_t address;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1057 sscanf(toStringz(lastcmd[1]), "%x", &address);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1058 if ( address > 0 )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1059 loc = new Location(address);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1060 else
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1061 loc = new Location(lastcmd[1]);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1062 loc.bind(dbg.images, dbg.source_search_paths);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1063 if ( lastcmd.length > 2 )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1064 index = cast(int)atoi(lastcmd[2]);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1065
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1066 Breakpoint bp;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1067 if ( index <= 0 && dbg.breakpoints.length > 0 )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1068 index = dbg.breakpoints.keys.dup.sort[$-1]+1;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1069 bp = dbg.setBreakpoint(loc, index, threadId, true);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1070 DbgIO.println("Hardware Breakpoint set: %s", bp.toString);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1071 break;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1072 // type of expression
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1073 case "t":
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1074 if ( dbg.process_loaded && lastcmd.length > 1 )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1075 {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1076 SymbolData sd;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1077 try {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1078 sd = dbg.evaluateExpression(lastcmd[1], current_frame_level);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1079 string type = demangle("_D0"~sd.type);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1080 DbgIO.println("%s\n%s", sd.type, type);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1081 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1082 catch ( EvaluationException e ) {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1083 DbgIO.writeln(e.toString);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1084 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1085 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1086 break;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1087 // unwind stack
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1088 case "us":
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1089 if ( dbg.process_loaded || dbg.miniDump !is null )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1090 unwindStack();
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1091 break;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1092 // write minidump
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1093 case "wmd":
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1094 if ( dbg.miniDump !is null ) {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1095 DbgIO.println("Command not valid in post-mortem mode");
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1096 break;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1097 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1098 if ( !dbg.process_loaded )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1099 break;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1100 if ( !MiniDump.haveMiniDump ) {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1101 DbgIO.println("DbgHelp.dll required for MiniDump support.\nInstall the Microsoft Platform SDK or Windows XP.");
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1102 break;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1103 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1104 if ( lastcmd.length < 2 ) {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1105 DbgIO.println("Usage: wmd <filename>");
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1106 break;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1107 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1108 dbg.writeMiniDump(lastcmd[1]);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1109 break;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1110 // read minidump
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1111 case "rmd":
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1112 if ( dbg.process_loaded ) {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1113 DbgIO.println("For post-mortem debugging, the process must not be started");
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1114 break;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1115 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1116 if ( !MiniDump.haveMiniDump ) {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1117 DbgIO.println("DbgHelp.dll required for MiniDump support.\nInstall the Microsoft Platform SDK or Windows XP.");
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1118 break;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1119 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1120 if ( lastcmd.length < 2 ) {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1121 DbgIO.println("Usage: rmd <filename>");
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1122 break;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1123 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1124 dbg.readMiniDump(lastcmd[1]);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1125 break;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1126 // unknown command
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1127 default:
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1128 DbgIO.println("Unknown command '%s' ignored!", lastcmd[0]);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1129 break;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1130 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1131
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1132 return false;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1133 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1134
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1135 /**********************************************************************************************
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1136
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1137 **********************************************************************************************/
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1138 void dumpMemory(uint start, uint length, ubyte[] _data=null)
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1139 {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1140 ubyte[] data;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1141 if ( _data is null )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1142 {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1143 data.length = length;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1144 if ( !dbg.process.readProcessMemory(start, data.ptr, data.length) )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1145 return;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1146 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1147 else
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1148 data = _data;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1149 for ( uint i = 0; i < length; ++i )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1150 {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1151 if ( i % (4*4) == 0 )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1152 {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1153 if ( i > 0 )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1154 DbgIO.println("");
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1155 DbgIO.print("%08x:", start+i);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1156 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1157 if ( i % 4 == 0 )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1158 DbgIO.print(" ");
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1159 DbgIO.print("%02x", data[i]);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1160 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1161 DbgIO.println("");
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1162 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1163
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1164 /**********************************************************************************************
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1165
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1166 **********************************************************************************************/
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1167 void evalScopeSymbols()
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1168 {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1169 uint scope_address = dbg.getScopeAddress(current_frame_level);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1170
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1171 ScopeSymbol scope_sym = dbg.images.findProcedureSymbol(scope_address);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1172 if ( scope_sym is null ) {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1173 DbgIO.println("No valid scope active");
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1174 return;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1175 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1176
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1177 for ( ; scope_sym !is null; scope_sym = scope_sym.parent_scope )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1178 {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1179 DbgIO.println("Scope: %s, parent: %x", scope_sym.name_type, cast(void*)scope_sym.parent_scope);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1180
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1181 StackSymbol[] locals_args = scope_sym.symbols.stack_symbols;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1182 auto psym = cast(ProcedureSymbol)scope_sym;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1183 if ( psym !is null )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1184 locals_args ~= psym.arguments.stack_symbols;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1185 foreach ( sym; locals_args.sort )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1186 {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1187 string name = sym.mangled_name;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1188 DbgIO.print("%s = ", name);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1189 // DbgIO.print("%s = [ebp%s%d] ", name, sym.cvdata.offset>0?"+":"", sym.cvdata.offset);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1190 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
1191 catch ( EvaluationException e ) {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1192 DbgIO.println(e.msg);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1193 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1194 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1195 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1196 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1197
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1198 /**********************************************************************************************
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1199
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1200 **********************************************************************************************/
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1201 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
1202 {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1203 bool nl = false;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1204 if ( location !is null ) {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1205 DbgIO.print("%s ", location);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1206 nl = true;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1207 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1208 if ( source !is null ) {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1209 DbgIO.write(source);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1210 nl = true;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1211 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1212 if ( nl )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1213 DbgIO.println;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1214
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1215 // align next column
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1216 char[] indent;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1217 int indcount = 2*12-bytes.length;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1218 if ( indcount > 0 ) {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1219 indent.length = indcount;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1220 indent[0..indcount] = ' ';
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1221 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1222 // print aligned asm source
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1223 assert(asmsource !is null);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1224 assert(bytes !is null);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1225 DbgIO.print("%08x: ", address, bytes, indent, asmsource);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1226
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1227 if ( symbol !is null )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1228 DbgIO.write(symbol);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1229 DbgIO.println;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1230 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1231
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1232 /**********************************************************************************************
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1233 Prints the register contents of the given thread's context.
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1234 **********************************************************************************************/
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1235 void printRegisterDump(DbgThread thread)
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1236 {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1237 CONTEXT ctxMem;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1238 uint context_flags;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1239 if ( dump_registers & CPU_REGISTERS )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1240 context_flags |= CONTEXT_FULL;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1241 if ( dump_registers & FPU_REGISTERS )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1242 context_flags |= CONTEXT_FLOATING_POINT;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1243 if ( dump_registers & (MMX_REGISTERS|SSE_REGISTERS) )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1244 context_flags |= CONTEXT_EXTENDED_REGISTERS;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1245 if ( thread.getContext(ctxMem, context_flags) )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1246 printRegisterDump(&ctxMem);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1247 else
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1248 DbgIO.println("ERROR: Couldn't get main thread's context");
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1249 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1250
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1251 void printRegisterDump(CONTEXT* ctx)
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1252 {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1253 assert ( ctx !is null );
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1254
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1255 bool first = true;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1256
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1257 if ( dump_registers & CPU_REGISTERS )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1258 {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1259 DbgIO.println("EAX = %08x\tEBX = %08x\tECX = %08x\tEDX = %08x", ctx.Eax, ctx.Ebx, ctx.Ecx, ctx.Edx);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1260 DbgIO.println("EDI = %08x\tESI = %08x\tEBP = %08x\tESP = %08x", ctx.Edi, ctx.Esi, ctx.Ebp, ctx.Esp);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1261 DbgIO.println("EIP = %08x\tEFL = %08x", ctx.Eip, ctx.EFlags);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1262 DbgIO.println(" CS = %08x\t DS = %08x\t ES = %08x\t FS = %08x", ctx.SegCs, ctx.SegDs, ctx.SegEs, ctx.SegFs);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1263 DbgIO.println(" GS = %08x\t SS = %08x", ctx.SegGs, ctx.SegSs);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1264 first = false;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1265 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1266
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1267 if ( dump_registers & FPU_REGISTERS )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1268 {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1269 if ( !first )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1270 DbgIO.println();
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1271 DbgIO.println("FCW = %04x\tFSW = %04x\tFTW = %04x\tFOP = %04x",
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1272 cast(ushort)ctx.FloatSave.ControlWord, cast(ushort)ctx.FloatSave.StatusWord,
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1273 cast(ushort)ctx.FloatSave.TagWord, (cast(ushort[])ctx.ExtendedRegisters)[3]
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1274 );
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1275 DbgIO.println("IP = %08x\tCS = %04x\tDP = %08x\tDS = %04x",
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1276 (cast(uint[])ctx.ExtendedRegisters)[2], (cast(ushort[])ctx.ExtendedRegisters)[6],
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1277 (cast(uint[])ctx.ExtendedRegisters)[4], (cast(ushort[])ctx.ExtendedRegisters)[10]
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1278 );
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1279 for ( int i = 0; i < 8; ++i )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1280 DbgIO.println("ST%d = % .16e", i, (cast(real[])ctx.FloatSave.RegisterArea)[i]);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1281 first = false;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1282 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1283
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1284 if ( dump_registers & MMX_REGISTERS )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1285 {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1286 if ( !first )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1287 DbgIO.println();
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1288 for ( int i = 0; i < 8; ++i )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1289 {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1290 DbgIO.println("MM%d = %016x", i, (cast(long[])ctx.ExtendedRegisters)[4+i*2]);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1291 DbgIO.println(" = [%.6g, %.6g]",
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1292 (cast(float[])ctx.ExtendedRegisters)[8+i*4],
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1293 (cast(float[])ctx.ExtendedRegisters)[8+i*4+1]
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1294 );
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1295 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1296 first = false;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1297 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1298
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1299 if ( dump_registers & SSE_REGISTERS )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1300 {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1301 if ( !first )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1302 DbgIO.println();
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1303 DbgIO.println("MXCSR = %08x", (cast(uint[])ctx.ExtendedRegisters)[6]);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1304 for ( int i = 0; i < 8; ++i )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1305 {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1306 DbgIO.println("XMM%d = %016x%016x", i, (cast(long[])ctx.ExtendedRegisters)[20+i*2+1], (cast(long[])ctx.ExtendedRegisters)[20+i*2]);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1307 DbgIO.println(" = [%.6g, %.6g, %.6g, %.6g]",
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1308 (cast(float[])ctx.ExtendedRegisters)[40+i*4],
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1309 (cast(float[])ctx.ExtendedRegisters)[40+i*4+1],
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1310 (cast(float[])ctx.ExtendedRegisters)[40+i*4+2],
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1311 (cast(float[])ctx.ExtendedRegisters)[40+i*4+3]
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1312 );
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1313 DbgIO.println(" = [%.12g, %.12g]",
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1314 (cast(double[])ctx.ExtendedRegisters)[20+i*2],
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1315 (cast(double[])ctx.ExtendedRegisters)[20+i*2+1]
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1316 );
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1317 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1318 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1319 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1320
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1321 /**********************************************************************************************
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1322
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1323 **********************************************************************************************/
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1324 string symbolValueToString(SymbolValue val)
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1325 {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1326 return symbolValueToString(val,"");
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1327 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1328
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1329 string symbolValueToString(SymbolValue val, string indent)
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1330 {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1331 string str;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1332 if ( val.name !is null )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1333 str = val.name~" = ";
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1334 if ( val.value !is null )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1335 str ~= val.value;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1336 else
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1337 {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1338 if ( val.children.length > 0 )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1339 {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1340 str ~= "{";
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1341 bool first = true;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1342 foreach ( c; val.children )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1343 {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1344 if ( first )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1345 first = false;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1346 else
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1347 str ~= ",";
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1348 str ~= "\n "~indent~symbolValueToString(c, indent~" ");
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1349 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1350 str ~= "\n"~indent~"}";
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1351 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1352 else
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1353 str ~= "{}";
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1354 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1355 return str;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1356 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1357
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1358 /**********************************************************************************************
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1359 Read command and call CLI supplied parser function.
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1360 Gets called when debuggee is suspended.
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1361 **********************************************************************************************/
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1362 bool readCommand()
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1363 {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1364 if ( cmdQueue.length <= 0 ) {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1365 DbgIO.write("->");
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1366 string input = DbgIO.readln();
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1367 cmdQueue ~= input;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1368 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1369 if ( cmdQueue.length <= 0 )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1370 return false;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1371
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1372 string cmd = strip(cmdQueue[0]);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1373 cmdQueue = cmdQueue[1..$];
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1374 if ( cmd.length > 0 && cmd[$-1] == ';' ) {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1375 cmd = cmd[0..$-1];
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1376 DbgIO.writeln("->"~cmd);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1377 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1378 return parseCommand(cmd);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1379 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1380 }