← Back to team overview

zorba-coders team mailing list archive

[Merge] lp:~zorba-coders/zorba/debugger_enhancements into lp:zorba

 

Gabriel Petrovay has proposed merging lp:~zorba-coders/zorba/debugger_enhancements into lp:zorba.

Requested reviews:
  Gabriel Petrovay (gabipetrovay)
  Juan Zacarias (juan457)
  David Graf (davidagraf)
Related bugs:
  Bug #898581 in Zorba: "Debugger: syntax error client block"
  https://bugs.launchpad.net/zorba/+bug/898581

For more details, see:
https://code.launchpad.net/~zorba-coders/zorba/debugger_enhancements/+merge/86801

Fixes one issue and a couple of warnings in the debugger.
Removes the ZORBA_WITH_DEBUGGER_CLIENT cmake variable.
-- 
https://code.launchpad.net/~zorba-coders/zorba/debugger_enhancements/+merge/86801
Your team Zorba Coders is subscribed to branch lp:zorba.
=== modified file 'CMakeConfiguration.txt'
--- CMakeConfiguration.txt	2011-12-21 14:40:33 +0000
+++ CMakeConfiguration.txt	2011-12-23 12:56:26 +0000
@@ -89,13 +89,6 @@
 SET(ZORBA_WITH_DEBUGGER ON CACHE BOOL "compile zorba with debugger support")
 MESSAGE(STATUS "ZORBA_WITH_DEBUGGER [ON/OFF]:         " ${ZORBA_WITH_DEBUGGER})
 
-SET(ZORBA_WITH_DEBUGGER_CLIENT ON CACHE BOOL "compile zorba with a command line debugger client")
-MESSAGE(STATUS "ZORBA_WITH_DEBUGGER_CLIENT [ON/OFF]:  " ${ZORBA_WITH_DEBUGGER_CLIENT})
-
-IF (ZORBA_WITH_DEBUGGER_CLIENT AND NOT ZORBA_WITH_DEBUGGER)
-  MESSAGE(FATAL_ERROR "Can not build a debugger client if the debugger support is disabled. Turn on ZORBA_WITH_DEBUGGER")
-ENDIF (ZORBA_WITH_DEBUGGER_CLIENT AND NOT ZORBA_WITH_DEBUGGER)
-
 SET(ZORBA_TEST_TIMEOUT_VALUE 60 CACHE INTEGER "default test timeout value")
 MESSAGE(STATUS "ZORBA_TEST_TIMEOUT_VALUE:             " ${ZORBA_TEST_TIMEOUT_VALUE})
 

=== modified file 'bin/CMakeLists.txt'
--- bin/CMakeLists.txt	2011-12-21 14:40:33 +0000
+++ bin/CMakeLists.txt	2011-12-23 12:56:26 +0000
@@ -15,7 +15,7 @@
 INCLUDE_DIRECTORIES(AFTER ${CMAKE_SOURCE_DIR}/src/)
 INCLUDE_DIRECTORIES(AFTER ${CMAKE_CURRENT_SOURCE_DIR})
 
-IF (ZORBA_WITH_DEBUGGER_CLIENT)
+IF (ZORBA_WITH_DEBUGGER)
   IF (NOT WIN32)
     FIND_PACKAGE (Libedit)
     IF (LIBEDIT_FOUND)
@@ -31,13 +31,14 @@
 
   SET (DEBUG_CLIENT_SRCS
     debugger/main.cpp
+    debugger/process_listener.cpp
     debugger/command_prompt.cpp
     debugger/command_line_handler.cpp
     debugger/event_handler.cpp
   )
   
   ZORBA_GENERATE_EXE ("xqdb" "${DEBUG_CLIENT_SRCS}" "${LIBEDIT_LIBS}" "xqdb" "bin")
-ENDIF (ZORBA_WITH_DEBUGGER_CLIENT)
+ENDIF (ZORBA_WITH_DEBUGGER)
 
 SET(SRCS
   zorbacmd.cpp

=== modified file 'bin/debugger/command_line_handler.cpp'
--- bin/debugger/command_line_handler.cpp	2011-12-21 14:40:33 +0000
+++ bin/debugger/command_line_handler.cpp	2011-12-23 12:56:26 +0000
@@ -23,6 +23,9 @@
 # define msleep Sleep
 #endif
 
+#include "command_prompt.h"
+
+
 namespace zorba { namespace debugger {
   
   using namespace ::ZORBA_TR1_NS;
@@ -31,11 +34,11 @@
   unsigned short port,
   LockFreeConsumer<std::size_t>& aConsumer,
   LockFreeConsumer<bool>& aContinueQueue,
-  EventHandler& aHandler,
-  CommandPrompt& aCommandPrompt)
+  EventHandler* aHandler,
+  CommandPrompt* aCommandPrompt)
   : theConsumer(aConsumer),
     theContinueQueue(aContinueQueue),
-    theClient(DebuggerClient::createDebuggerClient(&aHandler, port, "localhost")),
+    theClient(DebuggerClient::createDebuggerClient(aHandler, port, "localhost")),
     theCommandLine(aCommandPrompt),
     theQuit(false), theTerminated(true), theContinue(false), theWaitFor(0)
   {
@@ -64,10 +67,10 @@
     if (lCanQuit) {
       theTerminated = true;
     }
-    theCommandLine.execute();
+    theCommandLine->execute();
     while (theContinue) {
       theContinue = false;
-      theCommandLine.execute();
+      theCommandLine->execute();
     }
   } while (!theQuit);
 }
@@ -253,20 +256,20 @@
   typedef tuple<bint, bint, bstring> TUPLE_INT_INT_STR;
 
   // DBGP: status
-  theCommandLine << createCommand<Status>(TUPLE(), "status", *this, "Gets the status of the server");
+  *theCommandLine << createCommand<Status>(TUPLE(), "status", *this, "Gets the status of the server");
 
   // ALIAS: variables (context_get -c -1)
   {
     std::set<std::string> lAliases;
     lAliases.insert("vars");
-    theCommandLine << createCommand<Variables>(TUPLE(), "variables", lAliases, *this, "Gets the variables visible in the current scope");
+    *theCommandLine << createCommand<Variables>(TUPLE(), "variables", lAliases, *this, "Gets the variables visible in the current scope");
   }
 
   // META: quit
-  theCommandLine << createCommand<Quit>(TUPLE(), "quit", *this, "Stops debugging and quits the client");
+  *theCommandLine << createCommand<Quit>(TUPLE(), "quit", *this, "Stops debugging and quits the client");
 
   // DBGP: run
-  theCommandLine << createCommand<Run>(TUPLE(), "run", *this, "Run the query");
+  *theCommandLine << createCommand<Run>(TUPLE(), "run", *this, "Run the query");
 
   // DBGP: breakpoint_set
   {
@@ -279,7 +282,7 @@
     lCommand->addArgument(1, "f", createArgType<TUPLE_STR_STR_INT, std::string, 1>(TUPLE_STR_STR_INT()), "name of the file where to stop", true);
     lCommand->addArgument(2, "l", createArgType<TUPLE_STR_STR_INT, int, 2>(TUPLE_STR_STR_INT()), "line number", true);
       
-    theCommandLine << lCommand;
+    *theCommandLine << lCommand;
   }
 
   // DBGP: breakpoint_get
@@ -289,7 +292,7 @@
 
     lCommand->addArgument(0, "d", createArgType<TUPLE_INT, int, 0>(TUPLE_INT()), "breakpoint ID", true);
       
-    theCommandLine << lCommand;
+    *theCommandLine << lCommand;
   }
 
   // DBGP: breakpoint_remove
@@ -302,14 +305,14 @@
 
     lCommand->addArgument(0, "d", createArgType<TUPLE_INT, int, 0>(TUPLE_INT()), "breakpoint ID", true);
       
-    theCommandLine << lCommand;
+    *theCommandLine << lCommand;
   }
 
   // DBGP: breakpoint_list
-  theCommandLine << createCommand<BreakpointList>(TUPLE(), "blist", *this, "List all set breakpoints");
+  *theCommandLine << createCommand<BreakpointList>(TUPLE(), "blist", *this, "List all set breakpoints");
 
   // DBGP: stack_depth
-  theCommandLine << createCommand<StackDepth>(TUPLE(), "sdepth", *this, "Get the depth of the stack");
+  *theCommandLine << createCommand<StackDepth>(TUPLE(), "sdepth", *this, "Get the depth of the stack");
 
   // DBGP: stack_get
   {
@@ -318,11 +321,11 @@
 
     lCommand->addArgument(0, "d", createArgType<TUPLE_INT, int, 0>(TUPLE_INT()), "stack frame to show: 0 for current stack frame, N for the main module (optional, all frames are shown if not provided)", false);
 
-    theCommandLine << lCommand;
+    *theCommandLine << lCommand;
   }
 
   // DBGP: context_names
-  theCommandLine << createCommand<ContextNames>(tuple<>(), "cnames", *this, "Get the names of the avilable contexts");
+  *theCommandLine << createCommand<ContextNames>(tuple<>(), "cnames", *this, "Get the names of the avilable contexts");
   // the DBGP -d arguments for this command is omitted since we always have/return: 0 - Local, 1 - Global
 
   // DBGP: context_get
@@ -333,7 +336,7 @@
     lCommand->addArgument(0, "d", createArgType<TUPLE_INT_INT, int, 0>(TUPLE_INT_INT()), "stack depth (optional, default: 0)", false);
     lCommand->addArgument(0, "c", createArgType<TUPLE_INT_INT, int, 1>(TUPLE_INT_INT()), "context ID: 0 for Local, 1 for Global (optional, default: 0)", false);
 
-    theCommandLine << lCommand;
+    *theCommandLine << lCommand;
   }
 
   // DBGP: source
@@ -347,7 +350,7 @@
     lCommand->addArgument(1, "e", createArgType<TUPLE_INT_INT_STR, int, 1>(TUPLE_INT_INT_STR()), "end line (optional, default: last line)", false);
     lCommand->addArgument(2, "f", createArgType<TUPLE_INT_INT_STR, std::string, 2>(TUPLE_INT_INT_STR()), "file URI (optional, default: the file in the top-most stack frame during execution, main module otherwise)", false);
 
-    theCommandLine << lCommand;
+    *theCommandLine << lCommand;
   }
 
   // DBGP: eval
@@ -363,7 +366,7 @@
     // - everything following the fist contiguous set of whitespaces are sent as string
     lCommand->addArgument(0, "c", createArgType<TUPLE_STR, std::string, 0>(TUPLE_STR()), "expression to evaluate", true);
       
-    theCommandLine << lCommand;
+    *theCommandLine << lCommand;
   }
 
   // DBGP: step_in
@@ -371,14 +374,14 @@
     std::set<std::string> lAliases;
     lAliases.insert("step");
     lAliases.insert("s");
-    theCommandLine << createCommand<StepIn>(TUPLE(), "in", lAliases, *this, "Step in");
+    *theCommandLine << createCommand<StepIn>(TUPLE(), "in", lAliases, *this, "Step in");
   }
 
   // DBGP: step_out
   {
     std::set<std::string> lAliases;
     lAliases.insert("finish");
-    theCommandLine << createCommand<StepOut>(TUPLE(), "out", lAliases, *this, "Step out");
+    *theCommandLine << createCommand<StepOut>(TUPLE(), "out", lAliases, *this, "Step out");
   }
 
   // DBGP: step_over
@@ -386,7 +389,7 @@
     std::set<std::string> lAliases;
     lAliases.insert("next");
     lAliases.insert("n");
-    theCommandLine << createCommand<StepOver>(TUPLE(), "over", lAliases, *this, "Step over");
+    *theCommandLine << createCommand<StepOver>(TUPLE(), "over", lAliases, *this, "Step over");
   }
 }
   

=== modified file 'bin/debugger/command_line_handler.h'
--- bin/debugger/command_line_handler.h	2011-12-21 14:40:33 +0000
+++ bin/debugger/command_line_handler.h	2011-12-23 12:56:26 +0000
@@ -23,12 +23,13 @@
 #include <zorba/debugger_client.h>
 
 #include "command.h"
-#include "command_prompt.h"
 #include "event_handler.h"
 
 
 namespace zorba { namespace debugger {
 
+  class CommandPrompt;
+
   enum Commands {
     Status,
     Variables,
@@ -62,8 +63,8 @@
       unsigned short port,
       LockFreeConsumer<std::size_t>& aConsumer,
       LockFreeConsumer<bool>& aContinueQueue,
-      EventHandler& aHandler,
-      CommandPrompt& aCommandPrompt);
+      EventHandler* aHandler,
+      CommandPrompt* aCommandPrompt);
 
     ~CommandLineHandler();
 
@@ -112,7 +113,7 @@
     LockFreeConsumer<std::size_t>&  theConsumer;
     LockFreeConsumer<bool>&         theContinueQueue;
     DebuggerClient*                 theClient;
-    CommandPrompt&                  theCommandLine;
+    CommandPrompt*                  theCommandLine;
     bool                            theQuit;
     bool                            theTerminated;
     bool                            theContinue;

=== modified file 'bin/debugger/main.cpp'
--- bin/debugger/main.cpp	2011-12-21 14:40:33 +0000
+++ bin/debugger/main.cpp	2011-12-23 12:56:26 +0000
@@ -26,10 +26,73 @@
 
 #include "command_prompt.h"
 #include "command_line_handler.h"
+#include "process_listener.h"
 
 using namespace zorba;
 using namespace zorba::debugger;
 
+class XqdbClient {
+
+  public:
+
+    XqdbClient(unsigned int aPort)
+    {
+      theIdQueue = new LockFreeQueue<std::size_t>();
+      theQuitQueue = new LockFreeQueue<bool>();
+      theEventHandler = new EventHandler(*theIdQueue, *theQuitQueue);
+      theEventHandler->init();
+
+      theCommandPrompt = new CommandPrompt();
+      theCommandLineHandler = new CommandLineHandler(aPort, *theIdQueue, *theQuitQueue, theEventHandler, theCommandPrompt);
+    }
+
+    ~XqdbClient()
+    {
+      if (theCommandLineHandler) {
+        delete theCommandLineHandler;
+      }
+      if (theCommandPrompt) {
+        delete theCommandPrompt;
+      }
+      if (theEventHandler) {
+        delete theEventHandler;
+      }
+
+      delete theIdQueue;
+      delete theQuitQueue;
+    }
+
+    void start()
+    {
+      theCommandLineHandler->execute();
+    }
+
+  private:
+
+    LockFreeQueue<std::size_t>* theIdQueue;
+    LockFreeQueue<bool>*        theQuitQueue;
+
+    EventHandler*       theEventHandler;
+    CommandPrompt*      theCommandPrompt;
+    CommandLineHandler* theCommandLineHandler;
+};
+
+
+XqdbClient* theClient;
+
+
+void
+onExitProcess(ExitCode aExitCode) {
+  //if (aExitCode != -1) {
+  //  std::cout << "Zorba has exited with code: " << aExitCode << std::endl;
+  //}
+  std::cout << "Terminating debugger client."<< std::endl;
+  // TODO: and the memory?
+
+  delete theClient;
+  exit(aExitCode);
+}
+
 int
 startZorba(std::string& aExec, std::vector<std::string>& aArgs) 
 {
@@ -38,7 +101,6 @@
   // start a process on Windows
 
   DWORD iReturnVal = 0;
-  DWORD dwExitCode = 0;
 
   std::wstring lExec;
   std::wstring lArgs;
@@ -81,7 +143,7 @@
 
   if (lResult) {
     // Watch the process
-    dwExitCode = WaitForSingleObject(piProcessInfo.hProcess, 0);
+    ProcessListener* lPl = new ProcessListener(piProcessInfo.hProcess, &onExitProcess);
   }
   else {
     // CreateProcess failed
@@ -150,9 +212,15 @@
     if (pID < 0) {
       std::cerr << "Failed to fork Zorba" << std::endl;
       return pID;
-    } else {
-      return 0;
     }
+    
+    // pID > 0
+
+    // Watch the process
+    //ProcessListener* lPl =
+    new ProcessListener(pID, &onExitProcess);
+
+    return 0;
   }
 #endif
 }
@@ -298,30 +366,27 @@
         return lResult;
       }
     } else {
-      std::cout << "Waiting for an incomming Zorba connection..." << std::endl;
+      std::cout << "Listening for an incomming Zorba connection on port " << lPort << "..." << std::endl;
     }
 
     // **************************************************************************
     // start the debugger command line
 
-    LockFreeQueue<std::size_t> lQueue;
-    LockFreeQueue<bool> lContEvent;
-    EventHandler lEventHandler(lQueue, lContEvent);
-    lEventHandler.init();
-
-    CommandPrompt lCommandPrompt;
-    CommandLineHandler lCommandLineHandler(lPort, lQueue, lContEvent, lEventHandler, lCommandPrompt);
-
-    lCommandLineHandler.execute();
+    theClient =  new XqdbClient(lPort);
+    theClient->start();
+
+    //tCommandLineHandler.execute();
 
 #ifndef WIN32
     wait();
 #endif
 
+    delete theClient;
+
   } catch (...) {
+    delete theClient;
     return -1;
   }
 
   return 0;
 }
-

=== added file 'bin/debugger/process_listener.cpp'
--- bin/debugger/process_listener.cpp	1970-01-01 00:00:00 +0000
+++ bin/debugger/process_listener.cpp	2011-12-23 12:56:26 +0000
@@ -0,0 +1,102 @@
+/*
+ * Copyright 2006-2008 The FLWOR Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "process_listener.h"
+
+#include <iostream>
+
+#ifdef ZORBA_HAVE_PTHREAD_H
+# include <sys/wait.h>
+# include <cassert>
+#endif
+
+
+namespace zorba { namespace debugger {
+  
+ProcessListener::ProcessListener(ProcessId aProcessID, ExitCallbackType aCallback)
+  : theProcessID(aProcessID), theCallback(aCallback)
+{
+#ifdef WIN32
+  theThread = CreateThread(NULL, 0, &run, (void*) this, 0, &theThreadId);
+#else
+  if (pthread_create(&theThread, NULL, &run, (void*) this)) {
+    assert(false);
+  }
+#endif
+}
+
+ProcessListener::~ProcessListener()
+{
+}
+
+ProcessId
+ProcessListener::getProcessID()
+{
+  return theProcessID;
+}
+
+ExitCallbackType
+ProcessListener::getCallback()
+{
+  return theCallback;
+}
+
+
+ZORBA_THREAD_RETURN
+ProcessListener::run(void* params)
+{
+  ProcessListener* lThis = static_cast<ProcessListener*>(params);
+  ExitCode lExitCode = -1;
+  ProcessId lPid = lThis->getProcessID();
+
+#ifdef WIN32
+  // wait for the process to exit
+  WaitForSingleObject(lPid, INFINITE);
+
+  // find out the process exit code if possible
+  if (!GetExitCodeProcess(lThis->getProcessID(), &lExitCode)) {
+    lExitCode = -1;
+  }
+
+  // wait a little for zorba to dump the garbage
+  Sleep(1000);
+#else
+  int lChildExitStatus;
+
+  // wait for the process to exit
+  waitpid(lPid, &lChildExitStatus, 0);
+
+  // find out the process exit code if possible
+  if (WIFEXITED(lChildExitStatus)) {
+    lExitCode = WEXITSTATUS(lChildExitStatus);
+  }
+
+  // wait a little for zorba to dump the garbage
+  sleep(1);
+#endif
+
+  // and call the callback when this happened
+  ExitCallbackType lCallback = lThis->getCallback();
+  lCallback(lExitCode);
+
+  for (int i = 0; i < 10; i++) {
+    std::cout << i << std::endl;
+  }
+  return NULL;
+}
+
+} // namespace zorba
+} // namespace debugger

=== added file 'bin/debugger/process_listener.h'
--- bin/debugger/process_listener.h	1970-01-01 00:00:00 +0000
+++ bin/debugger/process_listener.h	2011-12-23 12:56:26 +0000
@@ -0,0 +1,74 @@
+/*
+ * Copyright 2006-2008 The FLWOR Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#pragma once
+#ifndef ZORBA_DEBUGGER_PROCESS_LISTENER_H
+#define ZORBA_DEBUGGER_PROCESS_LISTENER_H
+
+#include <zorba/config.h>
+
+#ifdef ZORBA_HAVE_PTHREAD_H
+# include <pthread.h>
+  typedef pthread_t ThreadId;
+  typedef pid_t ProcessId;
+  typedef int ExitCode;
+# define ZORBA_THREAD_RETURN void *
+#else
+# include <windows.h>
+  typedef DWORD ThreadId;
+  typedef HANDLE ProcessId;
+  typedef DWORD ExitCode;
+# define ZORBA_THREAD_RETURN DWORD WINAPI
+#endif
+
+typedef void (*ExitCallbackType)(ExitCode);
+
+
+namespace zorba { namespace debugger {
+
+class ProcessListener
+{
+  public:
+    ProcessListener(ProcessId processID, ExitCallbackType callback);
+
+    ~ProcessListener();
+
+    ProcessId
+    getProcessID();
+
+    ExitCallbackType
+    getCallback();
+
+  private:
+
+    static ZORBA_THREAD_RETURN run(void* params);
+
+  private:
+
+#ifdef ZORBA_HAVE_PTHREAD_H
+    pthread_t         theThread;
+#else
+    ThreadId          theThreadId;
+    HANDLE            theThread;
+#endif
+
+    ProcessId         theProcessID;
+    ExitCallbackType  theCallback;
+};
+  
+} // namespace zorba
+} // namespace debugger
+
+#endif // ZORBA_DEBUGGER_PROCESS_LISTENER_H

=== modified file 'include/zorba/config.h.cmake'
--- include/zorba/config.h.cmake	2011-12-21 14:40:33 +0000
+++ include/zorba/config.h.cmake	2011-12-23 12:56:26 +0000
@@ -153,7 +153,6 @@
 #cmakedefine ZORBA_WITH_DEBUGGER
 #cmakedefine ZORBA_WITH_FILE_ACCESS
 #cmakedefine ZORBA_WITH_LIBXML2_SAX
-#cmakedefine ZORBA_WITH_DEBUGGER_CLIENT
 
 // Zorba parser configuration
 #cmakedefine ZORBA_DEBUG_PARSER 

=== modified file 'src/debugger/debugger_commons.cpp'
--- src/debugger/debugger_commons.cpp	2011-12-21 14:40:33 +0000
+++ src/debugger/debugger_commons.cpp	2011-12-23 12:56:26 +0000
@@ -226,7 +226,7 @@
 }
 
 unsigned int
-DebuggerCommons::addBreakpoint(String& aFileName, int aLine, bool aEnabled)
+DebuggerCommons::addBreakpoint(String& aFileName, unsigned int aLine, bool aEnabled)
 {
   QueryLoc lLocation;
   lLocation.setLineBegin(aLine);
@@ -261,7 +261,6 @@
 
     // 2. secondly we hope he gave us part of a path of a file
     lIter = theBreakableIDs.begin();
-    String::size_type lFileNameSize = lFileName.size();
     std::vector<std::pair<QueryLoc, int> > lFoundBreakables;
     zorba::String lFirstBreakablePath;
     while (lIter != theBreakableIDs.end()) {

=== modified file 'src/debugger/debugger_commons.h'
--- src/debugger/debugger_commons.h	2011-12-21 14:40:33 +0000
+++ src/debugger/debugger_commons.h	2011-12-23 12:56:26 +0000
@@ -238,7 +238,7 @@
   public:
 
     unsigned int
-    addBreakpoint(String& fileName, int line, bool enabled);
+    addBreakpoint(String& fileName, unsigned int line, bool enabled);
 
     Breakable
     getBreakpoint(unsigned int id);
@@ -383,7 +383,7 @@
     store::Item_t                                   theEvalItem;
     bool                                            theExecEval;
     bool                                            theStepping;
-    unsigned int                                    theMainModuleBreakableId;
+    unsigned int                                   theMainModuleBreakableId;
   };
 
 }

=== modified file 'src/debugger/debugger_protocol.cpp'
--- src/debugger/debugger_protocol.cpp	2011-12-21 14:40:33 +0000
+++ src/debugger/debugger_protocol.cpp	2011-12-23 12:56:26 +0000
@@ -158,4 +158,16 @@
   }
 }
 
+bool
+DebuggerCommand::getArg(std::string aArg, unsigned int& aValue) {
+  std::map<std::string, std::string>::iterator lElem = theArgs.find(aArg); 
+  if (lElem == theArgs.end()) {
+    return false;
+  } else {
+    std::stringstream lSs(lElem->second);
+    lSs >> aValue;
+    return true;
+  }
+}
+
 } // namespace zorba

=== modified file 'src/debugger/debugger_protocol.h'
--- src/debugger/debugger_protocol.h	2011-06-22 11:19:07 +0000
+++ src/debugger/debugger_protocol.h	2011-12-23 12:56:26 +0000
@@ -45,6 +45,9 @@
     bool
     getArg(std::string arg, int& value);
 
+    bool
+    getArg(std::string arg, unsigned int& value);
+
     std::string&
     getName() { return theName; }
 

=== modified file 'src/debugger/debugger_runtime.cpp'
--- src/debugger/debugger_runtime.cpp	2011-12-21 14:40:33 +0000
+++ src/debugger/debugger_runtime.cpp	2011-12-23 12:56:26 +0000
@@ -158,7 +158,7 @@
 // Breakpoints
 
 unsigned int
-DebuggerRuntime::addBreakpoint(String& aFileName, int aLine, bool aEnabled)
+DebuggerRuntime::addBreakpoint(String& aFileName, unsigned int aLine, bool aEnabled)
 {
   AutoLock lLock(theLock, Lock::WRITE);
   DebuggerCommons* lCommons = getDebbugerCommons();

=== modified file 'src/debugger/debugger_runtime.h'
--- src/debugger/debugger_runtime.h	2011-12-21 14:40:33 +0000
+++ src/debugger/debugger_runtime.h	2011-12-23 12:56:26 +0000
@@ -82,7 +82,7 @@
     // Breakpints
 
     unsigned int
-    addBreakpoint(String& aFileName, int aLine, bool enabled);
+    addBreakpoint(String& aFileName, unsigned int aLine, bool enabled);
 
     Breakable
     getBreakpoint(unsigned int id);

=== modified file 'src/debugger/debugger_server.cpp'
--- src/debugger/debugger_server.cpp	2011-12-21 14:40:33 +0000
+++ src/debugger/debugger_server.cpp	2011-12-23 12:56:26 +0000
@@ -201,7 +201,7 @@
       } else {
         if (aCommand.getName() == "breakpoint_set") {
 
-          int lLineNo;
+          unsigned int lLineNo;
           aCommand.getArg("n", lLineNo);
           std::string lFileNameTmp;
           aCommand.getArg("f", lFileNameTmp);


Follow ups