]> git.tdb.fi Git - gldbg.git/blobdiff - source/gldbg.cpp
Fix limit query in Inspector/GlState
[gldbg.git] / source / gldbg.cpp
index dd0476d4168db408f8a990792f94cc0e436c466a..9da31ea85917f76731126188690ee1727b0058dc 100644 (file)
@@ -20,8 +20,10 @@ using namespace std;
 GlDbg *GlDbg::instance = 0;
 
 GlDbg::GlDbg(int argc, char **argv):
+       done(false),
        cmd_interp(*this),
        process(vector<string>(argv+1, argv+argc)),
+       sock_fd(-1),
        buf_offset(0),
        flushing(false),
        got_sigchld(false),
@@ -56,7 +58,7 @@ int GlDbg::main()
        printf("Copyright © 2009-2010 Mikkosoft Productions\n");
        printf("Type \"help\" for a list of commands\n");
 
-       while(1)
+       while(!done)
                tick();
 
        return 0;
@@ -98,6 +100,9 @@ void GlDbg::launch()
 
 void GlDbg::send(GlPacket *pkt)
 {
+       if(process.get_state()==Process::INACTIVE)
+               throw runtime_error("Program is not running");
+
        packet_send(pkt, sock_fd);
 }
 
@@ -129,7 +134,7 @@ void GlDbg::set_breakpoint(unsigned short func, unsigned char flag, Tool *owner)
                        breakpoints.back().add_owner(owner);
                }
 
-               if(process.get_state()>=Process::RUNNING)
+               if(process.get_state()!=Process::INACTIVE)
                        send_breakpoint(func, flag, 0);
        }
 }
@@ -153,7 +158,7 @@ void GlDbg::clear_breakpoint(unsigned short func, unsigned char flag, Tool *owne
                                        break;
                                }
 
-                       if(process.get_state()>=Process::RUNNING)
+                       if(process.get_state()!=Process::INACTIVE)
                                send_breakpoint(func, 0, flag);
                }
        }
@@ -176,7 +181,7 @@ void GlDbg::quit(bool force)
 {
        if(!force && process.get_state()!=Process::INACTIVE)
                throw runtime_error("Program is still running");
-       exit(0);
+       done = true;
 }
 
 void GlDbg::tick()
@@ -222,7 +227,7 @@ void GlDbg::tick()
                        free(line);
                }
                else if(pstate==Process::INACTIVE)
-                       exit(0);
+                       done = true;
        }
 }