annotate src/cli/ddbgcli.d @ 4:a5fb1bc967e6

- = command does not need space after it - before using r command, ov command runs the program and stops at main - more source file lines are shown at each step
author marton@basel.hu
date Sun, 10 Apr 2011 12:15:04 +0200
parents 4a9dcbd9e54f
children 496dfd8f7342
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);
4
a5fb1bc967e6 - = command does not need space after it
marton@basel.hu
parents: 1
diff changeset
193 string source_lines;
1
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
194 if ( source !is null && bp.line <= source.length )
4
a5fb1bc967e6 - = command does not need space after it
marton@basel.hu
parents: 1
diff changeset
195 {
a5fb1bc967e6 - = command does not need space after it
marton@basel.hu
parents: 1
diff changeset
196 const showmore= 2;
a5fb1bc967e6 - = command does not need space after it
marton@basel.hu
parents: 1
diff changeset
197 int startfrom = bp.line- 1 - showmore;
a5fb1bc967e6 - = command does not need space after it
marton@basel.hu
parents: 1
diff changeset
198 int startend = bp.line- 1 + showmore;
a5fb1bc967e6 - = command does not need space after it
marton@basel.hu
parents: 1
diff changeset
199 if (startfrom <0)
a5fb1bc967e6 - = command does not need space after it
marton@basel.hu
parents: 1
diff changeset
200 startfrom=0;
a5fb1bc967e6 - = command does not need space after it
marton@basel.hu
parents: 1
diff changeset
201 if (startend >=source.length)
a5fb1bc967e6 - = command does not need space after it
marton@basel.hu
parents: 1
diff changeset
202 startend=source.length-1;
a5fb1bc967e6 - = command does not need space after it
marton@basel.hu
parents: 1
diff changeset
203 int left = showmore;
a5fb1bc967e6 - = command does not need space after it
marton@basel.hu
parents: 1
diff changeset
204 foreach (line;source[startfrom..startend+1])
a5fb1bc967e6 - = command does not need space after it
marton@basel.hu
parents: 1
diff changeset
205 {
a5fb1bc967e6 - = command does not need space after it
marton@basel.hu
parents: 1
diff changeset
206 if (left==0)
a5fb1bc967e6 - = command does not need space after it
marton@basel.hu
parents: 1
diff changeset
207 source_lines ~= ">>"~line ~"\n";
a5fb1bc967e6 - = command does not need space after it
marton@basel.hu
parents: 1
diff changeset
208 else
a5fb1bc967e6 - = command does not need space after it
marton@basel.hu
parents: 1
diff changeset
209 source_lines ~= " "~line ~"\n";
a5fb1bc967e6 - = command does not need space after it
marton@basel.hu
parents: 1
diff changeset
210 left--;
a5fb1bc967e6 - = command does not need space after it
marton@basel.hu
parents: 1
diff changeset
211 }
a5fb1bc967e6 - = command does not need space after it
marton@basel.hu
parents: 1
diff changeset
212 }
1
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 if ( !bp.temporary )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
215 DbgIO.print("Breakpoint %d hit at ", index);
4
a5fb1bc967e6 - = command does not need space after it
marton@basel.hu
parents: 1
diff changeset
216 debug DbgIO.println("before printing location info");
1
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
217 DbgIO.println("%s:%d 0x%x thread(%d)", bp.file, bp.line, bp.address, thread.id);
4
a5fb1bc967e6 - = command does not need space after it
marton@basel.hu
parents: 1
diff changeset
218 if ( source_lines.length > 0 )
a5fb1bc967e6 - = command does not need space after it
marton@basel.hu
parents: 1
diff changeset
219 DbgIO.write(source_lines);
1
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 return true;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
222 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
223
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
224 /**********************************************************************************************
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 **********************************************************************************************/
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
227 void debugString(string str)
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 printf("OUTPUT DEBUG STRING:\n%s\n", toStringz(str));
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
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
232 /**********************************************************************************************
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
233 Command line parser. Gets called when debuggee is suspended.
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
234 **********************************************************************************************/
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
235 bool parseCommand(string input)
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
236 {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
237 if ( strip(input).length > 0 )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
238 {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
239 auto r = std.regexp.RegExp("(([^\" \\t]+)|(\"[^\"]+\"))+");
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
240 lastcmd.length = 0;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
241 foreach ( m; r.search(input) )
4
a5fb1bc967e6 - = command does not need space after it
marton@basel.hu
parents: 1
diff changeset
242 {
a5fb1bc967e6 - = command does not need space after it
marton@basel.hu
parents: 1
diff changeset
243 //DbgIO.writeln("match:"~r.match(0));
1
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
244 lastcmd ~= r.match(0);
4
a5fb1bc967e6 - = command does not need space after it
marton@basel.hu
parents: 1
diff changeset
245 }
a5fb1bc967e6 - = command does not need space after it
marton@basel.hu
parents: 1
diff changeset
246
1
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
247 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
248 if ( lastcmd.length <= 0 )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
249 return false;
4
a5fb1bc967e6 - = command does not need space after it
marton@basel.hu
parents: 1
diff changeset
250 if (lastcmd[0][0]=='=' && lastcmd[0].length>1)
a5fb1bc967e6 - = command does not need space after it
marton@basel.hu
parents: 1
diff changeset
251 {
a5fb1bc967e6 - = command does not need space after it
marton@basel.hu
parents: 1
diff changeset
252 DbgIO.writeln("after ="~lastcmd[0][1..$]);
a5fb1bc967e6 - = command does not need space after it
marton@basel.hu
parents: 1
diff changeset
253 lastcmd=["=",lastcmd[0][1..$]]~lastcmd[1..$];
a5fb1bc967e6 - = command does not need space after it
marton@basel.hu
parents: 1
diff changeset
254 }
1
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
255 switch ( lastcmd[0] )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
256 {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
257 case "help":
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
258 case "h":
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
259 case "?":
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
260 DbgIO.write(import("ddbg_help.txt"));
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
261 break;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
262 case "=":
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
263 if ( !dbg.process_loaded && dbg.miniDump is null )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
264 break;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
265 if ( lastcmd.length > 1 )
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 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
268 catch ( EvaluationException e ) {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
269 DbgIO.writeln(e.toString);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
270 }
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 break;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
273 case "arg":
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
274 if ( dbg.process_loaded )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
275 DbgIO.println("Warning: process already started");
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
276 command_line = debuggee~" "~join(lastcmd[1..$], " ");
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 // add breakpoint
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
279 case "bp":
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
280 int index;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
281 if ( lastcmd.length < 2 ) {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
282 DbgIO.println("invalid syntax - see help for details");
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
283 break;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
284 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
285
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
286 int pos = find(lastcmd[1], '#');
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
287 uint threadId;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
288 if ( pos > 0 )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
289 {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
290 threadId = cast(uint)atoi(lastcmd[1][pos+1..$]);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
291 lastcmd[1] = lastcmd[1][0..pos];
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
292 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
293 Location loc = new Location(lastcmd[1]);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
294 loc.bind(dbg.images, dbg.source_search_paths);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
295 if ( lastcmd.length > 2 )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
296 index = cast(int)atoi(lastcmd[2]);
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 Breakpoint bp;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
299 if ( index <= 0 && dbg.breakpoints.length > 0 )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
300 index = dbg.breakpoints.keys.dup.sort[$-1]+1;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
301 bp = dbg.setBreakpoint(loc, index, threadId);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
302 DbgIO.println("Breakpoint set: %s", bp.toString);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
303 break;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
304 // delete breakpoint
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
305 case "dbp":
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
306 if ( lastcmd.length > 1 )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
307 {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
308 if ( lastcmd[1] == "*" )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
309 {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
310 foreach ( uint i; dbg.breakpoints.keys )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
311 dbg.removeBreakpoint(i);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
312 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
313 else if ( isNumeric(lastcmd[1]) )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
314 {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
315 if ( !dbg.removeBreakpoint(cast(uint)atoi(lastcmd[1])) )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
316 DbgIO.println("invalid breakpoint index: %s",lastcmd[1]);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
317 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
318 else
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
319 {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
320 Location loc = new Location(lastcmd[1]);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
321 loc.bind(dbg.images, dbg.source_search_paths);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
322 if ( loc !is null )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
323 {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
324 int bp_index;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
325 dbg.getBreakpoint(loc, bp_index);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
326 if ( bp_index >= 0 && !dbg.removeBreakpoint(bp_index) )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
327 DbgIO.println("No breakpoint set at "~lastcmd[1]);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
328 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
329 else
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
330 DbgIO.println("dbp [<source file>:<line>|#index|*]");
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
331 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
332 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
333 else
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
334 DbgIO.println("dbp [<source file>:<line>|#index|*]");
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
335 break;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
336 // set evaluation depth
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
337 case "er":
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
338 lastcmd.length = 1;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
339 if ( dbg.evaluationDepth > 1 ) {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
340 lastEvaluationDepth = dbg.evaluationDepth;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
341 lastcmd ~= "1";
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
342 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
343 else
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
344 lastcmd ~= .toString(lastEvaluationDepth);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
345 case "ed":
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
346 if ( lastcmd.length < 2 || !isNumeric(lastcmd[1]) )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
347 DbgIO.println("Usage: ed <depth>");
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
348 else {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
349 dbg.evaluationDepth = cast(int)atoi(lastcmd[1]);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
350 DbgIO.println("Expression evaluation depth is %d", dbg.evaluationDepth);
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 case "el":
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
354 if ( lastcmd.length < 2 || !isNumeric(lastcmd[1]) )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
355 DbgIO.println("Usage: el <length>");
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
356 else {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
357 DataHandler.max_elem_count = cast(int)atoi(lastcmd[1]);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
358 DbgIO.println("Array evaluation length is %d", DataHandler.max_elem_count);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
359 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
360 break;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
361 // select frame
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
362 case "f":
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
363 if ( lastcmd.length > 1 )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
364 current_frame_level = cast(uint)atoi(lastcmd[1]);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
365 DbgIO.println("Current frame level is %d", current_frame_level);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
366 break;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
367 // image base address
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
368 case "ii":
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
369 foreach ( img; dbg.images.images )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
370 {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
371 uint ibase = img.imageBase;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
372 DbgIO.println("ImageBase\t0x%x", ibase);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
373 DbgIO.println("CodeBase\t0x%x", img.getCodeBase);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
374 DbgIO.println("Sections:\nname\t\taddress\t\tsize\t\tcharacteristics");
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
375 foreach ( s; img.sections )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
376 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
377 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
378 break;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
379 // jump to last known source frame
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
380 case "jkf":
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
381 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
382 DbgIO.println("%s to from of last known source location on exception",
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
383 jump_to_last_known_location_on_exception?"Jumping":"Not jumping"
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
384 );
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
385 break;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
386 // walk memory
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
387 case "mi":
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
388 if ( !dbg.process_loaded )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
389 break;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
390 uint filteredStates = MEM_COMMIT;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
391 foreach ( lc; lastcmd[1..$] )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
392 {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
393 switch ( lc )
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 "free": filteredStates |= MEM_FREE; break;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
396 case "rsrv": filteredStates |= MEM_RESERVE; break;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
397 default:
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
398 }
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 MEMORY_BASIC_INFORMATION[] mbis = dbg.process.walkMemory;
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 DbgIO.println("Base AlcBase AlcProt RgnSize Stat Protect Type");
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
404 foreach ( mbi; mbis )
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 if ( (mbi.State & filteredStates) == 0 )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
407 continue;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
408
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
409 string state;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
410 switch ( mbi.State )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
411 {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
412 case MEM_COMMIT: state = "comt"; break;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
413 case MEM_FREE: state = "free"; break;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
414 case MEM_RESERVE: state = "rsrv"; break;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
415 default: state = "unkn"; 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
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
418 string type;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
419 switch ( mbi.Type )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
420 {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
421 case MEM_IMAGE: type = "imag"; break;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
422 case MEM_MAPPED: type = "mapd"; break;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
423 case MEM_PRIVATE: type = "priv"; break;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
424 default: type = "unkn"; break;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
425 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
426
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
427 string protectName(uint prot)
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 string protStr;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
430 switch ( prot & 0xff )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
431 {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
432 case 0: protStr = "?"; break;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
433 case PAGE_EXECUTE: protStr = "x"; break;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
434 case PAGE_EXECUTE_READ: protStr = "xr"; break;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
435 case PAGE_EXECUTE_READWRITE: protStr = "xrw"; break;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
436 case PAGE_EXECUTE_WRITECOPY: protStr = "xwc"; break;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
437 case PAGE_NOACCESS: protStr = "na"; break;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
438 case PAGE_READONLY: protStr = "ro"; break;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
439 case PAGE_READWRITE: protStr = "rw"; break;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
440 case PAGE_WRITECOPY: protStr = "wc"; break;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
441 default: protStr = format("%02x", prot & 0xff); break;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
442 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
443 protStr ~= " ";
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
444 if ( prot & PAGE_GUARD )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
445 protStr ~= "g";
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
446 if ( prot & PAGE_NOCACHE )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
447 protStr ~= "nc";
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
448 return protStr;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
449 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
450
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
451 DbgIO.println("%08x %08x %- 7s %08x %s %- 7s %s",
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
452 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
453 mbi.RegionSize, state, protectName(mbi.Protect), type
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
454 );
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
455 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
456 break;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
457 // list breakpoints
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
458 case "lbp":
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
459 if ( dbg.breakpoints.length <= 0 )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
460 DbgIO.println("no breakpoints set");
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
461 foreach ( uint i, bp; dbg.breakpoints )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
462 DbgIO.println("%d %s", i, bp.toString);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
463 break;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
464 // ldll
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
465 case "ldll":
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
466 if ( !dbg.process_loaded )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
467 break;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
468 DbgIO.println("Base Name");
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
469 foreach ( dll; dbg.process.loaded_dlls )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
470 DbgIO.println("%08x %s", dll.base, dll.image.name);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
471 break;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
472 // list temporary breakpoints
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
473 case "ltbp":
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
474 if ( dbg.temp_breakpoints.empty )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
475 DbgIO.println("no temporary breakpoints set");
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
476 foreach ( bp; dbg.temp_breakpoints )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
477 DbgIO.writeln(bp.value.toString);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
478 break;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
479 // list debug modules
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
480 case "lm":
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
481 Module[] modules_noinfo;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
482 foreach ( img; dbg.images.images )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
483 {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
484 foreach ( m; img.codeView.modulesByIndex )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
485 {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
486 string name = m.name;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
487
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
488 if ( m.header.iLib > 0 )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
489 name ~= " from "~img.codeView.libraries[m.header.iLib];
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 ( lastcmd.length > 1 && find(name, lastcmd[1]) < 0 )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
492 continue;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
493
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
494 bool has_info = false;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
495 with ( m.symbols )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
496 {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
497 if ( proc_symbols.length+stack_symbols.length+data_symbols.length > 0 )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
498 {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
499 DbgIO.println(
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
500 "%s\n\tSymbols: %d proc %d stack %d data",
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
501 name, proc_symbols.length, stack_symbols.length, data_symbols.length
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 has_info = true;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
504 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
505 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
506 if ( m.source_module !is null )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
507 {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
508 DbgIO.println("\tSource files:");
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
509 has_info = true;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
510 foreach ( sf; m.source_module.files )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
511 DbgIO.println("\t\t%s", sf.name);
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 if ( !has_info )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
514 modules_noinfo ~= m;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
515 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
516 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
517 if ( modules_noinfo.length > 0 )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
518 {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
519 DbgIO.println("Modules without debug information:");
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
520 foreach ( img; dbg.images.images )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
521 {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
522 foreach ( m; modules_noinfo )
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 string name = m.name;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
525
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
526 if ( m.header.iLib > 0 )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
527 name ~= " from "~img.codeView.libraries[m.header.iLib];
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
528
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
529 DbgIO.println("%s #segs=%d", name, m.seginfos.length);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
530 if ( m.source_module !is null )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
531 {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
532 DbgIO.println("\tSource files:");
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
533 foreach ( sf; m.source_module.files )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
534 DbgIO.println("\t\t%s", sf.name);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
535 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
536 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
537 }
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 break;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
540 // list source modules
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
541 case "lsm":
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
542 uint[string] line_counters;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
543 uint[string] seg_counters;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
544 foreach ( img; dbg.images.images )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
545 {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
546 if ( img.codeView is null )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
547 continue;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
548 foreach ( m; img.codeView.modulesByIndex )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
549 {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
550 if ( m.source_module is null )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
551 continue;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
552 foreach ( sf; m.source_module.files )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
553 {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
554 if ( lastcmd.length > 1 && find(sf.name, lastcmd[1]) < 0 )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
555 continue;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
556 uint lines = sf.lines.length;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
557 if ( (sf.name in line_counters) is null ) {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
558 seg_counters[sf.name] = sf.segments.length;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
559 line_counters[sf.name] = lines;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
560 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
561 else {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
562 seg_counters[sf.name] += sf.segments.length;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
563 line_counters[sf.name] += lines;
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 }
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 string[] lc_keys = line_counters.keys.dup;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
569 lc_keys.sort;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
570 foreach ( key; lc_keys )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
571 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
572 break;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
573 // list source lines per module
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
574 case "lsl":
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
575 foreach ( img; dbg.images.images )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
576 {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
577 if ( img.codeView is null )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
578 continue;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
579 foreach ( m; img.codeView.modulesByIndex )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
580 {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
581 if ( m.source_module is null )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
582 continue;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
583 DbgIO.println("module %s", m.name);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
584 foreach ( sf; m.source_module.files )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
585 {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
586 DbgIO.println("file %s", sf.name);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
587 if ( lastcmd.length > 1 && find(sf.name, lastcmd[1]) < 0 )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
588 continue;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
589 foreach ( l; sf.lines.reverse )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
590 {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
591 DbgIO.println("line %d", l);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
592 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
593 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
594 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
595 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
596 break;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
597 // list all symbols
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
598 case "ls":
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
599 /*
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
600 void dumpSymbolAVL(AVLNode!(NamedSymbol) node, uint indent=0)
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
601 {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
602 string indentstr = new char[indent*2];
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
603 indentstr[0..indent*2] = ' ';
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
604 DbgIO.println("%s%s", indentstr, node.value.name_notype);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
605 if ( node.left !is null )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
606 dumpSymbolAVL(node.left, indent+1);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
607 if ( node.right !is null )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
608 dumpSymbolAVL(node.right, indent+1);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
609 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
610 DbgIO.println("AVL dump:");
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
611 dumpSymbolAVL(dbg.image.codeView.globalNamedSymbols.root);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
612 */
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
613 foreach ( img; dbg.images.images )
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 if ( img.codeView is null )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
616 continue;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
617 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
618 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
619 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
620 foreach ( m; img.codeView.modulesByIndex )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
621 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
622 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
623 break;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
624 // list source search paths
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
625 case "lsp":
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
626 foreach ( s; dbg.source_search_paths )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
627 DbgIO.writeln(s);
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 function symbols
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
630 case "lf":
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.proc_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.proc_symbols, lastcmd.length>1?lastcmd[1]:null);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
637 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
638 foreach ( m; img.codeView.modulesByIndex )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
639 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
640 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
641 break;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
642 // list data symbols
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
643 case "ld":
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
644 foreach ( img; dbg.images.images )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
645 {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
646 if ( img.codeView is null )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
647 continue;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
648 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
649 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
650 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
651 foreach ( m; img.codeView.modulesByIndex )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
652 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
653 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
654 break;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
655 // list global symbols
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
656 case "lg":
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
657 foreach ( img; dbg.images.images )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
658 {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
659 if ( img.codeView is null )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
660 continue;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
661 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
662 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
663 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
664 break;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
665 // list global publics
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
666 case "lp":
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
667 foreach ( img; dbg.images.images )
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 if ( img.codeView is null )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
670 continue;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
671 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
672 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
673 break;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
674 // list scope variables
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
675 case "lsv":
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
676 if ( dbg.process_loaded || dbg.miniDump !is null )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
677 evalScopeSymbols();
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
678 break;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
679 // list threads
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
680 case "lt":
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
681 if ( dbg.miniDump !is null )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
682 {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
683 DbgIO.println(" id pri sus location");
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
684 MINIDUMP_THREAD[] threads = dbg.miniDump.threads;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
685 foreach ( thread; threads )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
686 {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
687 CONTEXT* ctx;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
688 ctx = cast(CONTEXT*)dbg.miniDump.rvaToVa(thread.ThreadContext.Rva);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
689 Location loc = dbg.images.findLocation(ctx.Eip);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
690
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
691 DbgIO.println("%s%s%- 6d %- 3d %- 2d %s",
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
692 thread.ThreadId==dbg.thread_id?">":" ", thread.ThreadId==dbg.miniDump.threadInfo.mainThreadId?"*":" ",
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
693 thread.ThreadId, thread.Priority, thread.SuspendCount, describeLocation(loc)
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 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
697 else
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
698 {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
699 DbgIO.println(" id pri sus creation exit kernel user location");
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
700 foreach ( t; dbg.process.threads.values )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
701 {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
702 // id name location pri pri-boost start-info times
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
703 ulong creation,
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
704 exit,
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
705 kernel,
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
706 user;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
707
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
708 t.times(creation, exit, kernel, user);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
709
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
710 CONTEXT ctx;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
711 t.getContext(ctx);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
712 Location loc = dbg.images.findLocation(ctx.Eip);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
713
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
714 DbgIO.println("%s%s%- 6d %- 3d%s %- 2d %s %s %s %s %s",
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
715 t.id==dbg.thread_id?">":" ", t.id==dbg.process.mainThreadId?"*":" ", t.id,
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
716 t.priority, t.priorityBoost?"b":" ", t.suspendCount,
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
717 formatTicks(creation), formatTicks(exit), formatTicks(kernel), formatTicks(user),
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
718 describeLocation(loc)
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
719 );
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
720 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
721 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
722 break;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
723 // no console
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
724 case "nc":
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
725 dbg.create_new_console = !dbg.create_new_console;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
726 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
727 break;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
728 // on exception
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
729 case "onex":
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
730 if ( lastcmd.length < 2 )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
731 {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
732 foreach ( cmd; onexCommands )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
733 DbgIO.writeln(cmd[0..$-1]);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
734 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
735 else
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 onexCommands = null;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
738 string cmdList;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
739 foreach ( cmd; lastcmd[1..$] )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
740 {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
741 if ( cmd[0] == '"' && cmd[$-1] == '"' )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
742 cmdList ~= " "~cmd[1..$-1];
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
743 else
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
744 cmdList ~= " "~cmd;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
745 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
746 foreach ( cmd; split(cmdList, ";") )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
747 onexCommands ~= strip(cmd)~";";
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
748 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
749 break;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
750 // on termination
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
751 case "onterm":
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
752 if ( lastcmd.length < 2 )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
753 {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
754 foreach ( cmd; ontermCommands )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
755 DbgIO.writeln(cmd[0..$-1]);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
756 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
757 else
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
758 {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
759 ontermCommands = null;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
760 string cmdList;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
761 foreach ( cmd; lastcmd[1..$] )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
762 {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
763 if ( cmd[0] == '"' && cmd[$-1] == '"' )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
764 cmdList ~= " "~cmd[1..$-1];
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
765 else
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
766 cmdList ~= " "~cmd;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
767 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
768 foreach ( cmd; split(cmdList, ";") )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
769 ontermCommands ~= strip(cmd)~";";
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
770 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
771 break;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
772 // print source
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
773 case "ps":
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
774 Location loc;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
775 string[] source;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
776
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
777 do
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
778 {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
779 if ( current_frame_level > 0 )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
780 {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
781 auto frame = dbg.stack.getFrame(current_frame_level);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
782 if ( frame is null )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
783 goto Lnotfound;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
784 uint ret_adr = (cast(uint[])frame)[1];
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
785 loc = dbg.images.findLocation(ret_adr);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
786 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
787 else
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
788 loc = dbg.images.findLocation(dbg.current_address);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
789 debug DbgIO.println("found location %s", loc.file);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
790
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
791 source = dbg.getSourceFile(loc.file);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
792 if ( source !is null )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
793 break;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
794 if ( auto_find_scope_frame ) {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
795 ++current_frame_level;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
796 continue;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
797 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
798 Lnotfound:
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
799 DbgIO.writeln("Source file for current location unknown");
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
800 break;
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 while( source is null );
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
803
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
804 int start_line, end_line;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
805 if ( lastcmd.length > 1 ) {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
806 start_line = cast(uint)atoi(lastcmd[1]);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
807 end_line = loc.line + start_line;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
808 start_line = loc.line - start_line;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
809 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
810 else if ( loc.scope_sym !is null )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
811 {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
812 ProcedureSymbol psym = cast(ProcedureSymbol)loc.scope_sym;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
813 auto start_address = loc.getCodeBase + psym.cvdata.offset;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
814 auto start_loc = dbg.images.findLocation(start_address);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
815 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
816 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
817 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
818 end_loc = dbg.images.findPrevSrcLine(end_loc);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
819 start_line = start_loc.line;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
820 if ( end_loc !is null )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
821 end_line = end_loc.line;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
822 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
823 if ( end_line == 0 ) {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
824 start_line = loc.line - PRINT_SOURCE_LINES;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
825 end_line = loc.line + PRINT_SOURCE_LINES;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
826 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
827
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
828 debug DbgIO.println("lines: %d - %d", start_line, end_line);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
829 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
830 {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
831 if ( l+1 == loc.line )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
832 DbgIO.write(">");
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
833 DbgIO.writeln(source[l]);
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 break;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
836 // quit
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
837 case "q":
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
838 dbg.abort = true;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
839 quit = true;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
840 return true;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
841 // run/continue
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
842 case "r":
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
843 if ( dbg.miniDump !is null ) {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
844 DbgIO.println("Command not valid in post-mortem mode");
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
845 break;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
846 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
847 if ( dbg.process_loaded ) {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
848 dbg.resume;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
849 return true;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
850 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
851 else {
4
a5fb1bc967e6 - = command does not need space after it
marton@basel.hu
parents: 1
diff changeset
852 dbg.breakonmain = false;
a5fb1bc967e6 - = command does not need space after it
marton@basel.hu
parents: 1
diff changeset
853 dbg.start(command_line);
1
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
854 return true;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
855 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
856 // single-step
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
857 case "s":
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
858 if ( dbg.miniDump !is null ) {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
859 DbgIO.println("Command not valid in post-mortem mode");
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
860 break;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
861 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
862 if ( dbg.process_loaded ) {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
863 dbg.single_step = true;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
864 dbg.activateSingleStep(true);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
865 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
866 return true;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
867 // add source search path
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
868 case "sp":
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
869 if ( lastcmd.length > 1 )
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 string sp = lastcmd[1].dup;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
872 if ( sp[$-1] != '\\' )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
873 sp ~= '\\';
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
874 dbg.source_search_paths ~= sp;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
875 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
876 else
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
877 DbgIO.println("usage: sp <search_path>");
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
878 break;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
879 // switch thread
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
880 case "st":
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
881 if ( lastcmd.length < 2 ) {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
882 DbgIO.writeln("Usage: st <threadID>");
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
883 break;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
884 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
885 size_t threadId = cast(size_t)atoi(lastcmd[1]);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
886 if ( dbg.miniDump !is null )
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 foreach ( thread; dbg.miniDump.threads )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
889 {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
890 if ( threadId == thread.ThreadId ) {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
891 dbg.selectThread(threadId);
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 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
894 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
895 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
896 else
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
897 {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
898 foreach ( t; dbg.process.threads.values )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
899 {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
900 if ( threadId == t.id ) {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
901 dbg.selectThread(threadId);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
902 break;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
903 }
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 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
906 break;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
907 // step over
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
908 case "ov":
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
909 if ( dbg.miniDump !is null ) {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
910 DbgIO.println("Command not valid in post-mortem mode");
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
911 break;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
912 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
913 if ( dbg.process_loaded && dbg.step(StepMode.e_over) )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
914 {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
915 debug foreach ( bp; dbg.temp_breakpoints )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
916 DbgIO.writeln(bp.value.toString);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
917 return true;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
918 }
4
a5fb1bc967e6 - = command does not need space after it
marton@basel.hu
parents: 1
diff changeset
919 if (!dbg.process_loaded)
a5fb1bc967e6 - = command does not need space after it
marton@basel.hu
parents: 1
diff changeset
920 {
a5fb1bc967e6 - = command does not need space after it
marton@basel.hu
parents: 1
diff changeset
921 dbg.breakonmain = true;
a5fb1bc967e6 - = command does not need space after it
marton@basel.hu
parents: 1
diff changeset
922 dbg.start(command_line);
a5fb1bc967e6 - = command does not need space after it
marton@basel.hu
parents: 1
diff changeset
923 return true;
a5fb1bc967e6 - = command does not need space after it
marton@basel.hu
parents: 1
diff changeset
924 }
1
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
925 break;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
926 // step into
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
927 case "in":
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
928 if ( dbg.miniDump !is null ) {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
929 DbgIO.println("Command not valid in post-mortem mode");
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
930 break;
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 ( dbg.process_loaded && dbg.step(StepMode.e_in) )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
933 {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
934 debug foreach ( bp; dbg.temp_breakpoints )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
935 DbgIO.writeln(bp.value.toString);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
936 return true;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
937 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
938 break;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
939 // step out
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
940 case "out":
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
941 if ( dbg.miniDump !is null ) {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
942 DbgIO.println("Command not valid in post-mortem mode");
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
943 break;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
944 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
945 if ( dbg.process_loaded && dbg.step(StepMode.e_out) )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
946 {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
947 debug foreach ( bp; dbg.temp_breakpoints )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
948 DbgIO.writeln(bp.value.toString);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
949 return true;
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 break;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
952 // disassemble
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
953 case "da":
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
954 if ( !dbg.process_loaded )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
955 break;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
956
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
957 uint start_address;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
958 if ( current_frame_level > 0 ) {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
959 auto frame = dbg.stack.getFrame(current_frame_level);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
960 start_address = (cast(uint[])frame)[1];
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
961 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
962 else
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
963 start_address = dbg.current_address;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
964
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
965 if ( lastcmd.length > 1 )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
966 sscanf(toStringz(lastcmd[1]), "%x", &start_address);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
967 else
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(dbg.current_address);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
970 if ( loc.scope_sym !is null ) {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
971 ProcedureSymbol psym = cast(ProcedureSymbol)loc.scope_sym;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
972 start_address = loc.getCodeBase + psym.cvdata.offset;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
973 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
974 break;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
975 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
976 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
977 DisAsm.disasm(dbg.process, start_address, 0, &printDisassembly);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
978 break;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
979 // disassemble line
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
980 case "dal":
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
981 if ( !dbg.process_loaded )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
982 break;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
983
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
984 int num_lines = 1;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
985 if ( lastcmd.length > 1 )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
986 {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
987 sscanf(toStringz(lastcmd[1]), "%d", &num_lines);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
988 if ( num_lines < 0 )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
989 --num_lines;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
990 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
991
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
992 uint start_address;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
993 if ( current_frame_level > 0 ) {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
994 auto frame = dbg.stack.getFrame(current_frame_level);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
995 start_address = (cast(uint[])frame)[1];
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 else
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
998 start_address = dbg.current_address;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
999
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1000 for ( ; num_lines != 0; num_lines<0?++num_lines:--num_lines )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1001 {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1002 Location loc = dbg.images.findLocation(start_address);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1003 if ( loc is null ) {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1004 DbgIO.println("No source line information available");
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1005 break;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1006 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1007 DisAsm.disasm(
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1008 dbg.process,
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1009 loc.getCodeBase+loc.codeblock.start,
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1010 loc.getCodeBase+loc.codeblock.end,
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1011 &printDisassembly
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 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1014 break;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1015 // dump registers
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1016 case "dr":
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1017 if ( lastcmd.length > 1 )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1018 {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1019 foreach ( lc; lastcmd[1..$] )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1020 {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1021 switch ( lc )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1022 {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1023 case "cpu": dump_registers |= CPU_REGISTERS; break;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1024 case "fpu": dump_registers |= FPU_REGISTERS; break;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1025 case "mmx": dump_registers |= MMX_REGISTERS; break;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1026 case "sse": dump_registers |= SSE_REGISTERS; break;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1027 default:
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1028 DbgIO.println("Unknown register set \"%s\"", lc);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1029 }
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 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1032 if ( dump_registers == 0 ) {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1033 DbgIO.println("No register set selected. See help for usage of \"dr\"");
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1034 break;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1035 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1036 if ( dbg.miniDump !is null )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1037 printRegisterDump(dbg.miniDump.getContext);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1038 else if ( dbg.process_loaded )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1039 printRegisterDump(dbg.process.threads[dbg.thread_id]);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1040 break;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1041 // dump stack
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1042 case "ds":
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1043 if ( !dbg.process_loaded )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1044 break;
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 dump_length;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1047 if ( lastcmd.length > 1 )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1048 dump_length = cast(int)atoi(lastcmd[1])*4;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1049 else
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1050 {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1051 CONTEXT ctx;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1052 if ( dbg.process.threads[dbg.thread_id].getContext(ctx, CONTEXT_CONTROL) )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1053 dump_length = ctx.Ebp-ctx.Esp+8;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1054 if ( dump_length <= 0 )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1055 dump_length = 16*4;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1056 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1057 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
1058 dumpMemory(dbg.stack.top_ptr, top, dbg.stack.data);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1059 break;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1060 case "dm":
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1061 if ( !dbg.process_loaded )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1062 break;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1063
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1064 if ( lastcmd.length < 3 ) {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1065 DbgIO.println("usage: dm <start> <length>");
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1066 break;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1067 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1068 uint start;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1069 sscanf(toStringz(lastcmd[1]), "%x", &start);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1070 dumpMemory(start, cast(uint)atoi(lastcmd[2]));
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 case "hwbp":
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1073 int index;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1074 if ( lastcmd.length < 2 ) {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1075 DbgIO.println("invalid syntax - see help for details");
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1076 break;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1077 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1078
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1079 int pos = find(lastcmd[1], '#');
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1080 uint threadId;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1081 if ( pos > 0 )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1082 {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1083 threadId = cast(uint)atoi(lastcmd[1][pos+1..$]);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1084 lastcmd[1] = lastcmd[1][0..pos];
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
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1087 Location loc;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1088
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1089 size_t address;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1090 sscanf(toStringz(lastcmd[1]), "%x", &address);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1091 if ( address > 0 )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1092 loc = new Location(address);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1093 else
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1094 loc = new Location(lastcmd[1]);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1095 loc.bind(dbg.images, dbg.source_search_paths);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1096 if ( lastcmd.length > 2 )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1097 index = cast(int)atoi(lastcmd[2]);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1098
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1099 Breakpoint bp;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1100 if ( index <= 0 && dbg.breakpoints.length > 0 )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1101 index = dbg.breakpoints.keys.dup.sort[$-1]+1;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1102 bp = dbg.setBreakpoint(loc, index, threadId, true);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1103 DbgIO.println("Hardware Breakpoint set: %s", bp.toString);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1104 break;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1105 // type of expression
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1106 case "t":
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1107 if ( dbg.process_loaded && lastcmd.length > 1 )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1108 {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1109 SymbolData sd;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1110 try {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1111 sd = dbg.evaluateExpression(lastcmd[1], current_frame_level);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1112 string type = demangle("_D0"~sd.type);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1113 DbgIO.println("%s\n%s", sd.type, type);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1114 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1115 catch ( EvaluationException e ) {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1116 DbgIO.writeln(e.toString);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1117 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1118 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1119 break;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1120 // unwind stack
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1121 case "us":
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1122 if ( dbg.process_loaded || dbg.miniDump !is null )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1123 unwindStack();
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1124 break;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1125 // write minidump
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1126 case "wmd":
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1127 if ( dbg.miniDump !is null ) {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1128 DbgIO.println("Command not valid in post-mortem mode");
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 if ( !dbg.process_loaded )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1132 break;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1133 if ( !MiniDump.haveMiniDump ) {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1134 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
1135 break;
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 if ( lastcmd.length < 2 ) {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1138 DbgIO.println("Usage: wmd <filename>");
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1139 break;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1140 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1141 dbg.writeMiniDump(lastcmd[1]);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1142 break;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1143 // read minidump
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1144 case "rmd":
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1145 if ( dbg.process_loaded ) {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1146 DbgIO.println("For post-mortem debugging, the process must not be started");
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1147 break;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1148 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1149 if ( !MiniDump.haveMiniDump ) {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1150 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
1151 break;
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 ( lastcmd.length < 2 ) {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1154 DbgIO.println("Usage: rmd <filename>");
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1155 break;
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 dbg.readMiniDump(lastcmd[1]);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1158 break;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1159 // unknown command
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1160 default:
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1161 DbgIO.println("Unknown command '%s' ignored!", lastcmd[0]);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1162 break;
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 return false;
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
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
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 void dumpMemory(uint start, uint length, ubyte[] _data=null)
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1172 {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1173 ubyte[] data;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1174 if ( _data is null )
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 data.length = length;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1177 if ( !dbg.process.readProcessMemory(start, data.ptr, data.length) )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1178 return;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1179 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1180 else
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1181 data = _data;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1182 for ( uint i = 0; i < length; ++i )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1183 {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1184 if ( i % (4*4) == 0 )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1185 {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1186 if ( i > 0 )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1187 DbgIO.println("");
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1188 DbgIO.print("%08x:", start+i);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1189 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1190 if ( i % 4 == 0 )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1191 DbgIO.print(" ");
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1192 DbgIO.print("%02x", data[i]);
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 DbgIO.println("");
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 void evalScopeSymbols()
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1201 {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1202 uint scope_address = dbg.getScopeAddress(current_frame_level);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1203
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1204 ScopeSymbol scope_sym = dbg.images.findProcedureSymbol(scope_address);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1205 if ( scope_sym is null ) {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1206 DbgIO.println("No valid scope active");
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1207 return;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1208 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1209
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1210 for ( ; scope_sym !is null; scope_sym = scope_sym.parent_scope )
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 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
1213
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1214 StackSymbol[] locals_args = scope_sym.symbols.stack_symbols;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1215 auto psym = cast(ProcedureSymbol)scope_sym;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1216 if ( psym !is null )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1217 locals_args ~= psym.arguments.stack_symbols;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1218 foreach ( sym; locals_args.sort )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1219 {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1220 string name = sym.mangled_name;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1221 DbgIO.print("%s = ", name);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1222 // 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
1223 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
1224 catch ( EvaluationException e ) {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1225 DbgIO.println(e.msg);
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 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1228 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1229 }
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 **********************************************************************************************/
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1234 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
1235 {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1236 bool nl = false;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1237 if ( location !is null ) {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1238 DbgIO.print("%s ", location);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1239 nl = true;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1240 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1241 if ( source !is null ) {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1242 DbgIO.write(source);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1243 nl = true;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1244 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1245 if ( nl )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1246 DbgIO.println;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1247
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1248 // align next column
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1249 char[] indent;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1250 int indcount = 2*12-bytes.length;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1251 if ( indcount > 0 ) {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1252 indent.length = indcount;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1253 indent[0..indcount] = ' ';
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 // print aligned asm source
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1256 assert(asmsource !is null);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1257 assert(bytes !is null);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1258 DbgIO.print("%08x: ", address, bytes, indent, asmsource);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1259
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1260 if ( symbol !is null )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1261 DbgIO.write(symbol);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1262 DbgIO.println;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1263 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1264
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 Prints the register contents of the given thread's context.
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1267 **********************************************************************************************/
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1268 void printRegisterDump(DbgThread thread)
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1269 {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1270 CONTEXT ctxMem;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1271 uint context_flags;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1272 if ( dump_registers & CPU_REGISTERS )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1273 context_flags |= CONTEXT_FULL;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1274 if ( dump_registers & FPU_REGISTERS )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1275 context_flags |= CONTEXT_FLOATING_POINT;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1276 if ( dump_registers & (MMX_REGISTERS|SSE_REGISTERS) )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1277 context_flags |= CONTEXT_EXTENDED_REGISTERS;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1278 if ( thread.getContext(ctxMem, context_flags) )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1279 printRegisterDump(&ctxMem);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1280 else
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1281 DbgIO.println("ERROR: Couldn't get main thread's context");
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 void printRegisterDump(CONTEXT* ctx)
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 assert ( ctx !is null );
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1287
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1288 bool first = true;
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 if ( dump_registers & CPU_REGISTERS )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1291 {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1292 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
1293 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
1294 DbgIO.println("EIP = %08x\tEFL = %08x", ctx.Eip, ctx.EFlags);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1295 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
1296 DbgIO.println(" GS = %08x\t SS = %08x", ctx.SegGs, ctx.SegSs);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1297 first = false;
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
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1300 if ( dump_registers & FPU_REGISTERS )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1301 {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1302 if ( !first )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1303 DbgIO.println();
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1304 DbgIO.println("FCW = %04x\tFSW = %04x\tFTW = %04x\tFOP = %04x",
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1305 cast(ushort)ctx.FloatSave.ControlWord, cast(ushort)ctx.FloatSave.StatusWord,
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1306 cast(ushort)ctx.FloatSave.TagWord, (cast(ushort[])ctx.ExtendedRegisters)[3]
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1307 );
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1308 DbgIO.println("IP = %08x\tCS = %04x\tDP = %08x\tDS = %04x",
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1309 (cast(uint[])ctx.ExtendedRegisters)[2], (cast(ushort[])ctx.ExtendedRegisters)[6],
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1310 (cast(uint[])ctx.ExtendedRegisters)[4], (cast(ushort[])ctx.ExtendedRegisters)[10]
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1311 );
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1312 for ( int i = 0; i < 8; ++i )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1313 DbgIO.println("ST%d = % .16e", i, (cast(real[])ctx.FloatSave.RegisterArea)[i]);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1314 first = false;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1315 }
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 if ( dump_registers & MMX_REGISTERS )
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 if ( !first )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1320 DbgIO.println();
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1321 for ( int i = 0; i < 8; ++i )
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 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
1324 DbgIO.println(" = [%.6g, %.6g]",
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1325 (cast(float[])ctx.ExtendedRegisters)[8+i*4],
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1326 (cast(float[])ctx.ExtendedRegisters)[8+i*4+1]
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 first = false;
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
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1332 if ( dump_registers & SSE_REGISTERS )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1333 {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1334 if ( !first )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1335 DbgIO.println();
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1336 DbgIO.println("MXCSR = %08x", (cast(uint[])ctx.ExtendedRegisters)[6]);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1337 for ( int i = 0; i < 8; ++i )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1338 {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1339 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
1340 DbgIO.println(" = [%.6g, %.6g, %.6g, %.6g]",
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1341 (cast(float[])ctx.ExtendedRegisters)[40+i*4],
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1342 (cast(float[])ctx.ExtendedRegisters)[40+i*4+1],
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1343 (cast(float[])ctx.ExtendedRegisters)[40+i*4+2],
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1344 (cast(float[])ctx.ExtendedRegisters)[40+i*4+3]
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1345 );
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1346 DbgIO.println(" = [%.12g, %.12g]",
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1347 (cast(double[])ctx.ExtendedRegisters)[20+i*2],
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1348 (cast(double[])ctx.ExtendedRegisters)[20+i*2+1]
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 }
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 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1353
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
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 string symbolValueToString(SymbolValue val)
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 return symbolValueToString(val,"");
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1360 }
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 string symbolValueToString(SymbolValue val, string indent)
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 string str;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1365 if ( val.name !is null )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1366 str = val.name~" = ";
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1367 if ( val.value !is null )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1368 str ~= val.value;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1369 else
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1370 {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1371 if ( val.children.length > 0 )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1372 {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1373 str ~= "{";
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1374 bool first = true;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1375 foreach ( c; val.children )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1376 {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1377 if ( first )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1378 first = false;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1379 else
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1380 str ~= ",";
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1381 str ~= "\n "~indent~symbolValueToString(c, indent~" ");
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1382 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1383 str ~= "\n"~indent~"}";
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1384 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1385 else
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1386 str ~= "{}";
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1387 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1388 return str;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1389 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1390
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1391 /**********************************************************************************************
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1392 Read command and call CLI supplied parser function.
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1393 Gets called when debuggee is suspended.
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1394 **********************************************************************************************/
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1395 bool readCommand()
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1396 {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1397 if ( cmdQueue.length <= 0 ) {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1398 DbgIO.write("->");
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1399 string input = DbgIO.readln();
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1400 cmdQueue ~= input;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1401 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1402 if ( cmdQueue.length <= 0 )
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1403 return false;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1404
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1405 string cmd = strip(cmdQueue[0]);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1406 cmdQueue = cmdQueue[1..$];
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1407 if ( cmd.length > 0 && cmd[$-1] == ';' ) {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1408 cmd = cmd[0..$-1];
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1409 DbgIO.writeln("->"~cmd);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1410 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1411 return parseCommand(cmd);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1412 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1413 }