diff src/debugger.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 47dd986a534e
children 496dfd8f7342
line wrap: on
line diff
--- a/src/debugger.d	Tue Apr 05 20:56:40 2011 +0200
+++ b/src/debugger.d	Sun Apr 10 12:15:04 2011 +0200
@@ -34,7 +34,7 @@
 
 const uint      VERSION_MAJOR = 0,
                 VERSION_MINOR = 13,
-                VERSION_PATCH = 1;
+                VERSION_PATCH = 2;
 const string	VERSION_STRING =    "Ddbg "~itoa(VERSION_MAJOR)~"."~itoa(VERSION_MINOR)
                                     ~(VERSION_PATCH>0?"."~itoa(VERSION_PATCH):"")~" beta",
                 WELCOME_STRING =	VERSION_STRING~" - D Debugger\n"~
@@ -69,7 +69,9 @@
     bool	            paused,
                         process_loaded,
                         abort,
-                        single_step;
+                        single_step,
+                        breakonmain =false
+;
 
     size_t			    current_address;
     uint                last_line;
@@ -96,7 +98,7 @@
 
     UserInterface	    ui;
 
-    uint                evaluationDepth = 1;
+    uint                evaluationDepth = 2;
     bool                create_new_console;
 
     //=============================================================================================
@@ -602,6 +604,21 @@
                                 int bpi=-1;
                                 Breakpoint bp = setBreakpoint(mainds.offset+main_image.getCodeBase, bpi, 0, true);
                                 bp.deactivate_d_exception_handler = true;
+                                debug DbgIO.println("set breakpoint");
+                            }
+                            {
+                                int bpi=-1;
+                                // stop on first line
+                                if (breakonmain)
+                                {
+                                 breakonmain=false;
+                                 mainds = main_image.codeView.global_pub.findDataSymbol("__Dmain");
+                                 if ( mainds !is null )
+                                 {
+                                   Breakpoint bp = setBreakpoint(mainds.offset+main_image.getCodeBase, bpi, thread_id);
+                                 }
+                                }
+  
                             }
                         }
 
@@ -835,6 +852,7 @@
     void handleBreakpoint(Breakpoint bp, uint bp_index)
     {
         CONTEXT ctx;
+        debug DbgIO.println("handling breakpoint");
         if ( !process.threads[thread_id].getContext(ctx) )
             throw new DebuggerException("Error: Couldn't GetThreadContext to reset instruction pointer: %s", lastError);
 
@@ -972,6 +990,7 @@
             return full;
         foreach ( string sp; source_search_paths )
         {
+            debug DbgIO.println("searching for source file %s",sp~filename);
             full = getFullPath(sp~filename);
             if ( exists(full) )
                 return full;
@@ -1270,6 +1289,7 @@
             debug DbgIO.println("not setting bp at current 0x%08x", address);
             return null;
         }
+        debug DbgIO.println("setting breakpoint 0x%08x", address);
         bp = new Breakpoint(loc, new_index<0, threadId, hardware);
         addBreakpoint(bp, new_index);
         return bp;
@@ -1283,6 +1303,7 @@
     void addBreakpoint(Breakpoint bp, int new_index)
     {
         // add to breakpoint list
+        debug DbgIO.println("adding breakpoint 0x%08x", bp.address);
         if ( bp.temporary )
             temp_breakpoints ~= bp;
         else