Mercurial > projects > ddbg_continued
diff src/cli/ddbgcli.d @ 5:496dfd8f7342 default tip
added:
-repeat option for "in", "ov"
-run until a line option
-run until a function option
-break on a function start
-n is an alias for ov
author | marton@basel.hu |
---|---|
date | Sun, 17 Apr 2011 11:05:31 +0200 |
parents | a5fb1bc967e6 |
children |
line wrap: on
line diff
--- a/src/cli/ddbgcli.d Sun Apr 10 12:15:04 2011 +0200 +++ b/src/cli/ddbgcli.d Sun Apr 17 11:05:31 2011 +0200 @@ -57,6 +57,8 @@ bool auto_find_scope_frame, /// find frame of last active scope if current frame has no source/symbols jump_to_last_known_location_on_exception = true; + + uint repeat = 0; /********************************************************************************************** @@ -108,6 +110,7 @@ void exitProcess() { DbgIO.println("Process terminated"); + repeat = 0; cmdQueue ~= ontermCommands; } @@ -228,6 +231,75 @@ { printf("OUTPUT DEBUG STRING:\n%s\n", toStringz(str)); } + bool setBreakpointByFunctionname(char[][] lastcmd,uint threadId, int index) + { + DataSymbol[] ds; + size_t codebase; + // int index; + + foreach ( img; dbg.images.images ) + { + if ( img.codeView is null ) + continue; + DataSymbol[] tds; + ds ~= img.codeView.global_pub.findDataSymbolBySubstring(lastcmd[1]); + ds ~= img.codeView.global_sym.findDataSymbolBySubstring(lastcmd[1]); + ds ~= img.codeView.static_sym.findDataSymbolBySubstring(lastcmd[1]); + + foreach ( m; img.codeView.modulesByIndex ) + ds ~= m.symbols.findDataSymbolBySubstring(lastcmd[1]); + if (ds.length>0) + codebase=img.getCodeBase; + + } + debug DbgIO.println("Found candidates:%d",ds.length); + if (ds.length==1) + { + //Location loc = new Location(lastcmd[1]); + //loc.bind(dbg.images, dbg.source_search_paths); + if (index>=0) + if ( lastcmd.length > 2 ) + index = cast(int)atoi(lastcmd[2]); + + Breakpoint bp; + if (index>=0) // not temporary + {if ( index <= 0 && dbg.breakpoints.length > 0 ) + index = dbg.breakpoints.keys.dup.sort[$-1]+1; + } + else + index=-1; + bp = dbg.setBreakpoint(ds[0].offset+codebase, index, threadId); + + DbgIO.println("Breakpoint set: %s", bp.toString); + } + else + if (ds.length==0) + { + DbgIO.println("Breakpoint is not set:no matching functions are found!"); + return false; + } + else + { + DbgIO.println("Breakpoint is not set:too many matching functions are found!"); + int maxi=ds.length; + if (maxi>20) + { + DbgIO.println("There are more than 20 possibilities, first twenty is snown:"); + maxi=20; + } + else + { + DbgIO.println("These are the matched function names:"); + } + foreach (s;ds[0..maxi]) + { + //DbgIO.println(s.name_notype); + printSymbol(s); + } + return false; + } + return true; + } /********************************************************************************************** Command line parser. Gets called when debuggee is suspended. @@ -282,7 +354,7 @@ DbgIO.println("invalid syntax - see help for details"); break; } - + int pos = find(lastcmd[1], '#'); uint threadId; if ( pos > 0 ) @@ -301,6 +373,27 @@ bp = dbg.setBreakpoint(loc, index, threadId); DbgIO.println("Breakpoint set: %s", bp.toString); break; + case "bpf": + int index; + if ( lastcmd.length < 2 ) { + DbgIO.println("invalid syntax - see help for details"); + break; + } + + int pos = find(lastcmd[1], '#'); + uint threadId; + if ( pos > 0 ) + { + threadId = cast(uint)atoi(lastcmd[1][pos+1..$]); + lastcmd[1] = lastcmd[1][0..pos]; + } + if (lastcmd.length>1) + setBreakpointByFunctionname(lastcmd,threadId,0); + break; + + + + break; // delete breakpoint case "dbp": if ( lastcmd.length > 1 ) @@ -839,11 +932,47 @@ quit = true; return true; // run/continue - case "r": + case "r": case "rf": if ( dbg.miniDump !is null ) { DbgIO.println("Command not valid in post-mortem mode"); break; } + int index; + if ( lastcmd[0]=="r" && lastcmd.length == 2 ) { + + + int pos = find(lastcmd[1], '#'); + uint threadId; + if ( pos > 0 ) + { + threadId = cast(uint)atoi(lastcmd[1][pos+1..$]); + lastcmd[1] = lastcmd[1][0..pos]; + } + Location loc = new Location(lastcmd[1]); + if (!loc.bind(dbg.images, dbg.source_search_paths)) + break; + //if ( lastcmd.length > 2 ) + // index = cast(int)atoi(lastcmd[2]); + index=-1; + Breakpoint bp; + if ( index <= 0 && dbg.breakpoints.length > 0 ) + index = dbg.breakpoints.keys.dup.sort[$-1]+1; + bp = dbg.setBreakpoint(loc, index, threadId); + DbgIO.println("Breakpoint set: %s", bp.toString); + } + if ( lastcmd[0]=="rf" && lastcmd.length == 2 ) { + int pos = find(lastcmd[1], '#'); + uint threadId; + if ( pos > 0 ) + { + threadId = cast(uint)atoi(lastcmd[1][pos+1..$]); + lastcmd[1] = lastcmd[1][0..pos]; + } + if (!setBreakpointByFunctionname(lastcmd,threadId,-1)) + break; + + + } if ( dbg.process_loaded ) { dbg.resume; return true; @@ -905,11 +1034,16 @@ } break; // step over - case "ov": + case "n": case "ov": if ( dbg.miniDump !is null ) { DbgIO.println("Command not valid in post-mortem mode"); break; } + if ( lastcmd.length ==2 ) { + repeat=cast(uint)atoi(lastcmd[1]); + repeat--; + lastcmd.length = 1; + } if ( dbg.process_loaded && dbg.step(StepMode.e_over) ) { debug foreach ( bp; dbg.temp_breakpoints ) @@ -929,6 +1063,11 @@ DbgIO.println("Command not valid in post-mortem mode"); break; } + if ( lastcmd.length ==2 ) { + repeat=cast(uint)atoi(lastcmd[1]); + repeat--; + lastcmd.length = 1; + } if ( dbg.process_loaded && dbg.step(StepMode.e_in) ) { debug foreach ( bp; dbg.temp_breakpoints ) @@ -1394,6 +1533,12 @@ **********************************************************************************************/ bool readCommand() { + + if (repeat>0) + { + repeat--; + return parseCommand(""); + } if ( cmdQueue.length <= 0 ) { DbgIO.write("->"); string input = DbgIO.readln();