]> git.tdb.fi Git - gldbg.git/commitdiff
Retain user-set breakpoints and send them to the process on startup
authorMikko Rasa <tdb@tdb.fi>
Sat, 25 Aug 2012 17:12:45 +0000 (20:12 +0300)
committerMikko Rasa <tdb@tdb.fi>
Sat, 25 Aug 2012 17:32:05 +0000 (20:32 +0300)
source/gldbg.cpp
source/gldbg.h

index c37e65552a3684c5681284e5821959829d79648b..dd0476d4168db408f8a990792f94cc0e436c466a 100644 (file)
@@ -79,7 +79,19 @@ void GlDbg::launch()
        process.launch();
        close(fds[1]);
 
-       breakpoints.clear();
+       for(BreakList::iterator i=breakpoints.begin(); i!=breakpoints.end(); )
+       {
+               if(i->has_owner(0))
+               {
+                       i->owners.clear();
+                       i->owners.push_back(0);
+                       send_breakpoint(i->function, i->flag, 0);
+                       ++i;
+               }
+               else
+                       breakpoints.erase(i++);
+       }
+
        for(ToolList::iterator i=tools.begin(); i!=tools.end(); ++i)
                (*i)->process_started();
 }
@@ -95,6 +107,15 @@ void GlDbg::hold()
        send(pkt);
 }
 
+void GlDbg::send_breakpoint(unsigned short func, unsigned char set_flags, unsigned char clear_flags)
+{
+       GlPacket *pkt = packet_begin(FUNC_GLDBREAK);
+       packet_write_short(pkt, func);
+       packet_write_char(pkt, set_flags);
+       packet_write_char(pkt, clear_flags);
+       send(pkt);
+}
+
 void GlDbg::set_breakpoint(unsigned short func, unsigned char flag, Tool *owner)
 {
        Breakpoint *bp = (func ? get_breakpoint(func, flag) : 0);
@@ -108,11 +129,8 @@ void GlDbg::set_breakpoint(unsigned short func, unsigned char flag, Tool *owner)
                        breakpoints.back().add_owner(owner);
                }
 
-               GlPacket *pkt = packet_begin(FUNC_GLDBREAK);
-               packet_write_short(pkt, func);
-               packet_write_char(pkt, flag);
-               packet_write_char(pkt, 0);
-               send(pkt);
+               if(process.get_state()>=Process::RUNNING)
+                       send_breakpoint(func, flag, 0);
        }
 }
 
@@ -135,11 +153,8 @@ void GlDbg::clear_breakpoint(unsigned short func, unsigned char flag, Tool *owne
                                        break;
                                }
 
-                       GlPacket *pkt = packet_begin(FUNC_GLDBREAK);
-                       packet_write_short(pkt, func);
-                       packet_write_char(pkt, 0);
-                       packet_write_char(pkt, flag);
-                       send(pkt);
+                       if(process.get_state()>=Process::RUNNING)
+                               send_breakpoint(func, 0, flag);
                }
        }
 }
index 36ca1df25848a83c22333183cb3f869974af9507..3a2bcd1a718535fdba44b00f6d2018f423df74a3 100644 (file)
@@ -55,6 +55,9 @@ public:
        void launch();
        void send(GlPacket *);
        void hold();
+private:
+       void send_breakpoint(unsigned short, unsigned char, unsigned char);
+public:
        void set_breakpoint(unsigned short, unsigned char, Tool *);
        void clear_breakpoint(unsigned short, unsigned char, Tool *);
        void resume_from_break(Tool *);