Mercurial > projects > ddbg_continued
comparison 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 |
comparison
equal
deleted
inserted
replaced
3:47dd986a534e | 4:a5fb1bc967e6 |
---|---|
188 else if ( bp.file is null || bp.line == 0 ) | 188 else if ( bp.file is null || bp.line == 0 ) |
189 DbgIO.println("Unknown breakpoint hit at %s thread(%d)", describeLocation(bp.address), thread.id); | 189 DbgIO.println("Unknown breakpoint hit at %s thread(%d)", describeLocation(bp.address), thread.id); |
190 else | 190 else |
191 { | 191 { |
192 string[] source = dbg.getSourceFile(bp.file); | 192 string[] source = dbg.getSourceFile(bp.file); |
193 string source_line; | 193 string source_lines; |
194 if ( source !is null && bp.line <= source.length ) | 194 if ( source !is null && bp.line <= source.length ) |
195 source_line = source[bp.line-1]; | 195 { |
196 const showmore= 2; | |
197 int startfrom = bp.line- 1 - showmore; | |
198 int startend = bp.line- 1 + showmore; | |
199 if (startfrom <0) | |
200 startfrom=0; | |
201 if (startend >=source.length) | |
202 startend=source.length-1; | |
203 int left = showmore; | |
204 foreach (line;source[startfrom..startend+1]) | |
205 { | |
206 if (left==0) | |
207 source_lines ~= ">>"~line ~"\n"; | |
208 else | |
209 source_lines ~= " "~line ~"\n"; | |
210 left--; | |
211 } | |
212 } | |
196 | 213 |
197 if ( !bp.temporary ) | 214 if ( !bp.temporary ) |
198 DbgIO.print("Breakpoint %d hit at ", index); | 215 DbgIO.print("Breakpoint %d hit at ", index); |
216 debug DbgIO.println("before printing location info"); | |
199 DbgIO.println("%s:%d 0x%x thread(%d)", bp.file, bp.line, bp.address, thread.id); | 217 DbgIO.println("%s:%d 0x%x thread(%d)", bp.file, bp.line, bp.address, thread.id); |
200 if ( source_line.length > 0 ) | 218 if ( source_lines.length > 0 ) |
201 DbgIO.writeln(source_line); | 219 DbgIO.write(source_lines); |
202 } | 220 } |
203 return true; | 221 return true; |
204 } | 222 } |
205 | 223 |
206 /********************************************************************************************** | 224 /********************************************************************************************** |
219 if ( strip(input).length > 0 ) | 237 if ( strip(input).length > 0 ) |
220 { | 238 { |
221 auto r = std.regexp.RegExp("(([^\" \\t]+)|(\"[^\"]+\"))+"); | 239 auto r = std.regexp.RegExp("(([^\" \\t]+)|(\"[^\"]+\"))+"); |
222 lastcmd.length = 0; | 240 lastcmd.length = 0; |
223 foreach ( m; r.search(input) ) | 241 foreach ( m; r.search(input) ) |
242 { | |
243 //DbgIO.writeln("match:"~r.match(0)); | |
224 lastcmd ~= r.match(0); | 244 lastcmd ~= r.match(0); |
245 } | |
246 | |
225 } | 247 } |
226 if ( lastcmd.length <= 0 ) | 248 if ( lastcmd.length <= 0 ) |
227 return false; | 249 return false; |
228 | 250 if (lastcmd[0][0]=='=' && lastcmd[0].length>1) |
251 { | |
252 DbgIO.writeln("after ="~lastcmd[0][1..$]); | |
253 lastcmd=["=",lastcmd[0][1..$]]~lastcmd[1..$]; | |
254 } | |
229 switch ( lastcmd[0] ) | 255 switch ( lastcmd[0] ) |
230 { | 256 { |
231 case "help": | 257 case "help": |
232 case "h": | 258 case "h": |
233 case "?": | 259 case "?": |
821 if ( dbg.process_loaded ) { | 847 if ( dbg.process_loaded ) { |
822 dbg.resume; | 848 dbg.resume; |
823 return true; | 849 return true; |
824 } | 850 } |
825 else { | 851 else { |
826 dbg.start(command_line); | 852 dbg.breakonmain = false; |
853 dbg.start(command_line); | |
827 return true; | 854 return true; |
828 } | 855 } |
829 // single-step | 856 // single-step |
830 case "s": | 857 case "s": |
831 if ( dbg.miniDump !is null ) { | 858 if ( dbg.miniDump !is null ) { |
886 if ( dbg.process_loaded && dbg.step(StepMode.e_over) ) | 913 if ( dbg.process_loaded && dbg.step(StepMode.e_over) ) |
887 { | 914 { |
888 debug foreach ( bp; dbg.temp_breakpoints ) | 915 debug foreach ( bp; dbg.temp_breakpoints ) |
889 DbgIO.writeln(bp.value.toString); | 916 DbgIO.writeln(bp.value.toString); |
890 return true; | 917 return true; |
918 } | |
919 if (!dbg.process_loaded) | |
920 { | |
921 dbg.breakonmain = true; | |
922 dbg.start(command_line); | |
923 return true; | |
891 } | 924 } |
892 break; | 925 break; |
893 // step into | 926 // step into |
894 case "in": | 927 case "in": |
895 if ( dbg.miniDump !is null ) { | 928 if ( dbg.miniDump !is null ) { |