diff 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
line wrap: on
line diff
--- a/src/cli/ddbgcli.d	Tue Apr 05 20:56:40 2011 +0200
+++ b/src/cli/ddbgcli.d	Sun Apr 10 12:15:04 2011 +0200
@@ -190,15 +190,33 @@
         else
         {
             string[]	source = dbg.getSourceFile(bp.file);
-            string		source_line;
+            string		source_lines;
             if ( source !is null && bp.line <= source.length )
-                source_line = source[bp.line-1];
+            {
+                const showmore= 2;
+                int startfrom = bp.line- 1 - showmore;
+                int startend = bp.line- 1 + showmore;
+                if (startfrom <0)
+                   startfrom=0;
+                if (startend >=source.length)
+                   startend=source.length-1;
+                int left = showmore;
+                foreach (line;source[startfrom..startend+1])
+                {
+                  if (left==0)
+                    source_lines ~= ">>"~line ~"\n";
+                  else
+                    source_lines ~= "  "~line ~"\n";
+                  left--;
+                }
+            }
 
             if ( !bp.temporary )
                 DbgIO.print("Breakpoint %d hit at ", index);
+            debug  DbgIO.println("before printing location info");
             DbgIO.println("%s:%d 0x%x thread(%d)", bp.file, bp.line, bp.address, thread.id);
-            if ( source_line.length > 0 )
-                DbgIO.writeln(source_line);
+            if ( source_lines.length > 0 )
+                DbgIO.write(source_lines);
         }
         return true;
     }
@@ -221,11 +239,19 @@
             auto r = std.regexp.RegExp("(([^\" \\t]+)|(\"[^\"]+\"))+");
             lastcmd.length = 0;
             foreach ( m; r.search(input) )
+            {
+                //DbgIO.writeln("match:"~r.match(0));
                 lastcmd ~= r.match(0);
+            }
+            
         }
         if ( lastcmd.length <= 0 )
             return false;
-
+        if (lastcmd[0][0]=='=' && lastcmd[0].length>1)
+        {
+          DbgIO.writeln("after ="~lastcmd[0][1..$]);
+          lastcmd=["=",lastcmd[0][1..$]]~lastcmd[1..$];
+        }
         switch ( lastcmd[0] )
         {
             case "help":
@@ -823,7 +849,8 @@
                     return true;
                 }
                 else {
-                    dbg.start(command_line);
+                    dbg.breakonmain = false;
+                    dbg.start(command_line);                 
                     return true;
                 }
             // single-step
@@ -889,6 +916,12 @@
                         DbgIO.writeln(bp.value.toString);
                     return true;
                 }
+                if (!dbg.process_loaded)
+                {
+                   dbg.breakonmain = true;
+                   dbg.start(command_line);
+                   return true;
+                }
                 break;
             // step into
             case "in":