Merge lp:~zorba-coders/zorba/debugger_enhancements into lp:zorba
- debugger_enhancements
- Merge into trunk
Proposed by
Gabriel Petrovay
Status: | Merged | ||||
---|---|---|---|---|---|
Approved by: | Gabriel Petrovay | ||||
Approved revision: | 10598 | ||||
Merged at revision: | 10595 | ||||
Proposed branch: | lp:~zorba-coders/zorba/debugger_enhancements | ||||
Merge into: | lp:zorba | ||||
Diff against target: |
722 lines (+310/-58) 15 files modified
CMakeConfiguration.txt (+0/-7) bin/CMakeLists.txt (+3/-2) bin/debugger/command_line_handler.cpp (+25/-22) bin/debugger/command_line_handler.h (+5/-4) bin/debugger/main.cpp (+80/-15) bin/debugger/process_listener.cpp (+102/-0) bin/debugger/process_listener.h (+74/-0) include/zorba/config.h.cmake (+0/-1) src/debugger/debugger_commons.cpp (+1/-2) src/debugger/debugger_commons.h (+2/-2) src/debugger/debugger_protocol.cpp (+12/-0) src/debugger/debugger_protocol.h (+3/-0) src/debugger/debugger_runtime.cpp (+1/-1) src/debugger/debugger_runtime.h (+1/-1) src/debugger/debugger_server.cpp (+1/-1) |
||||
To merge this branch: | bzr merge lp:~zorba-coders/zorba/debugger_enhancements | ||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
David Graf (community) | Approve | ||
Gabriel Petrovay (community) | Approve | ||
Juan Zacarias | Pending | ||
Review via email: mp+86801@code.launchpad.net |
Commit message
Fixes one issue and a couple of warnings in the debugger.
Removes the ZORBA_WITH_
Description of the change
Fixes one issue and a couple of warnings in the debugger.
Removes the ZORBA_WITH_
To post a comment you must log in.
Revision history for this message
Gabriel Petrovay (gabipetrovay) : | # |
review:
Approve
Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote : | # |
Validation queue starting for merge proposal.
Log at: http://
Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote : | # |
Validation queue job debugger_
All tests succeeded!
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'CMakeConfiguration.txt' |
2 | --- CMakeConfiguration.txt 2011-12-21 14:40:33 +0000 |
3 | +++ CMakeConfiguration.txt 2011-12-23 12:56:26 +0000 |
4 | @@ -89,13 +89,6 @@ |
5 | SET(ZORBA_WITH_DEBUGGER ON CACHE BOOL "compile zorba with debugger support") |
6 | MESSAGE(STATUS "ZORBA_WITH_DEBUGGER [ON/OFF]: " ${ZORBA_WITH_DEBUGGER}) |
7 | |
8 | -SET(ZORBA_WITH_DEBUGGER_CLIENT ON CACHE BOOL "compile zorba with a command line debugger client") |
9 | -MESSAGE(STATUS "ZORBA_WITH_DEBUGGER_CLIENT [ON/OFF]: " ${ZORBA_WITH_DEBUGGER_CLIENT}) |
10 | - |
11 | -IF (ZORBA_WITH_DEBUGGER_CLIENT AND NOT ZORBA_WITH_DEBUGGER) |
12 | - MESSAGE(FATAL_ERROR "Can not build a debugger client if the debugger support is disabled. Turn on ZORBA_WITH_DEBUGGER") |
13 | -ENDIF (ZORBA_WITH_DEBUGGER_CLIENT AND NOT ZORBA_WITH_DEBUGGER) |
14 | - |
15 | SET(ZORBA_TEST_TIMEOUT_VALUE 60 CACHE INTEGER "default test timeout value") |
16 | MESSAGE(STATUS "ZORBA_TEST_TIMEOUT_VALUE: " ${ZORBA_TEST_TIMEOUT_VALUE}) |
17 | |
18 | |
19 | === modified file 'bin/CMakeLists.txt' |
20 | --- bin/CMakeLists.txt 2011-12-21 14:40:33 +0000 |
21 | +++ bin/CMakeLists.txt 2011-12-23 12:56:26 +0000 |
22 | @@ -15,7 +15,7 @@ |
23 | INCLUDE_DIRECTORIES(AFTER ${CMAKE_SOURCE_DIR}/src/) |
24 | INCLUDE_DIRECTORIES(AFTER ${CMAKE_CURRENT_SOURCE_DIR}) |
25 | |
26 | -IF (ZORBA_WITH_DEBUGGER_CLIENT) |
27 | +IF (ZORBA_WITH_DEBUGGER) |
28 | IF (NOT WIN32) |
29 | FIND_PACKAGE (Libedit) |
30 | IF (LIBEDIT_FOUND) |
31 | @@ -31,13 +31,14 @@ |
32 | |
33 | SET (DEBUG_CLIENT_SRCS |
34 | debugger/main.cpp |
35 | + debugger/process_listener.cpp |
36 | debugger/command_prompt.cpp |
37 | debugger/command_line_handler.cpp |
38 | debugger/event_handler.cpp |
39 | ) |
40 | |
41 | ZORBA_GENERATE_EXE ("xqdb" "${DEBUG_CLIENT_SRCS}" "${LIBEDIT_LIBS}" "xqdb" "bin") |
42 | -ENDIF (ZORBA_WITH_DEBUGGER_CLIENT) |
43 | +ENDIF (ZORBA_WITH_DEBUGGER) |
44 | |
45 | SET(SRCS |
46 | zorbacmd.cpp |
47 | |
48 | === modified file 'bin/debugger/command_line_handler.cpp' |
49 | --- bin/debugger/command_line_handler.cpp 2011-12-21 14:40:33 +0000 |
50 | +++ bin/debugger/command_line_handler.cpp 2011-12-23 12:56:26 +0000 |
51 | @@ -23,6 +23,9 @@ |
52 | # define msleep Sleep |
53 | #endif |
54 | |
55 | +#include "command_prompt.h" |
56 | + |
57 | + |
58 | namespace zorba { namespace debugger { |
59 | |
60 | using namespace ::ZORBA_TR1_NS; |
61 | @@ -31,11 +34,11 @@ |
62 | unsigned short port, |
63 | LockFreeConsumer<std::size_t>& aConsumer, |
64 | LockFreeConsumer<bool>& aContinueQueue, |
65 | - EventHandler& aHandler, |
66 | - CommandPrompt& aCommandPrompt) |
67 | + EventHandler* aHandler, |
68 | + CommandPrompt* aCommandPrompt) |
69 | : theConsumer(aConsumer), |
70 | theContinueQueue(aContinueQueue), |
71 | - theClient(DebuggerClient::createDebuggerClient(&aHandler, port, "localhost")), |
72 | + theClient(DebuggerClient::createDebuggerClient(aHandler, port, "localhost")), |
73 | theCommandLine(aCommandPrompt), |
74 | theQuit(false), theTerminated(true), theContinue(false), theWaitFor(0) |
75 | { |
76 | @@ -64,10 +67,10 @@ |
77 | if (lCanQuit) { |
78 | theTerminated = true; |
79 | } |
80 | - theCommandLine.execute(); |
81 | + theCommandLine->execute(); |
82 | while (theContinue) { |
83 | theContinue = false; |
84 | - theCommandLine.execute(); |
85 | + theCommandLine->execute(); |
86 | } |
87 | } while (!theQuit); |
88 | } |
89 | @@ -253,20 +256,20 @@ |
90 | typedef tuple<bint, bint, bstring> TUPLE_INT_INT_STR; |
91 | |
92 | // DBGP: status |
93 | - theCommandLine << createCommand<Status>(TUPLE(), "status", *this, "Gets the status of the server"); |
94 | + *theCommandLine << createCommand<Status>(TUPLE(), "status", *this, "Gets the status of the server"); |
95 | |
96 | // ALIAS: variables (context_get -c -1) |
97 | { |
98 | std::set<std::string> lAliases; |
99 | lAliases.insert("vars"); |
100 | - theCommandLine << createCommand<Variables>(TUPLE(), "variables", lAliases, *this, "Gets the variables visible in the current scope"); |
101 | + *theCommandLine << createCommand<Variables>(TUPLE(), "variables", lAliases, *this, "Gets the variables visible in the current scope"); |
102 | } |
103 | |
104 | // META: quit |
105 | - theCommandLine << createCommand<Quit>(TUPLE(), "quit", *this, "Stops debugging and quits the client"); |
106 | + *theCommandLine << createCommand<Quit>(TUPLE(), "quit", *this, "Stops debugging and quits the client"); |
107 | |
108 | // DBGP: run |
109 | - theCommandLine << createCommand<Run>(TUPLE(), "run", *this, "Run the query"); |
110 | + *theCommandLine << createCommand<Run>(TUPLE(), "run", *this, "Run the query"); |
111 | |
112 | // DBGP: breakpoint_set |
113 | { |
114 | @@ -279,7 +282,7 @@ |
115 | lCommand->addArgument(1, "f", createArgType<TUPLE_STR_STR_INT, std::string, 1>(TUPLE_STR_STR_INT()), "name of the file where to stop", true); |
116 | lCommand->addArgument(2, "l", createArgType<TUPLE_STR_STR_INT, int, 2>(TUPLE_STR_STR_INT()), "line number", true); |
117 | |
118 | - theCommandLine << lCommand; |
119 | + *theCommandLine << lCommand; |
120 | } |
121 | |
122 | // DBGP: breakpoint_get |
123 | @@ -289,7 +292,7 @@ |
124 | |
125 | lCommand->addArgument(0, "d", createArgType<TUPLE_INT, int, 0>(TUPLE_INT()), "breakpoint ID", true); |
126 | |
127 | - theCommandLine << lCommand; |
128 | + *theCommandLine << lCommand; |
129 | } |
130 | |
131 | // DBGP: breakpoint_remove |
132 | @@ -302,14 +305,14 @@ |
133 | |
134 | lCommand->addArgument(0, "d", createArgType<TUPLE_INT, int, 0>(TUPLE_INT()), "breakpoint ID", true); |
135 | |
136 | - theCommandLine << lCommand; |
137 | + *theCommandLine << lCommand; |
138 | } |
139 | |
140 | // DBGP: breakpoint_list |
141 | - theCommandLine << createCommand<BreakpointList>(TUPLE(), "blist", *this, "List all set breakpoints"); |
142 | + *theCommandLine << createCommand<BreakpointList>(TUPLE(), "blist", *this, "List all set breakpoints"); |
143 | |
144 | // DBGP: stack_depth |
145 | - theCommandLine << createCommand<StackDepth>(TUPLE(), "sdepth", *this, "Get the depth of the stack"); |
146 | + *theCommandLine << createCommand<StackDepth>(TUPLE(), "sdepth", *this, "Get the depth of the stack"); |
147 | |
148 | // DBGP: stack_get |
149 | { |
150 | @@ -318,11 +321,11 @@ |
151 | |
152 | 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); |
153 | |
154 | - theCommandLine << lCommand; |
155 | + *theCommandLine << lCommand; |
156 | } |
157 | |
158 | // DBGP: context_names |
159 | - theCommandLine << createCommand<ContextNames>(tuple<>(), "cnames", *this, "Get the names of the avilable contexts"); |
160 | + *theCommandLine << createCommand<ContextNames>(tuple<>(), "cnames", *this, "Get the names of the avilable contexts"); |
161 | // the DBGP -d arguments for this command is omitted since we always have/return: 0 - Local, 1 - Global |
162 | |
163 | // DBGP: context_get |
164 | @@ -333,7 +336,7 @@ |
165 | lCommand->addArgument(0, "d", createArgType<TUPLE_INT_INT, int, 0>(TUPLE_INT_INT()), "stack depth (optional, default: 0)", false); |
166 | 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); |
167 | |
168 | - theCommandLine << lCommand; |
169 | + *theCommandLine << lCommand; |
170 | } |
171 | |
172 | // DBGP: source |
173 | @@ -347,7 +350,7 @@ |
174 | lCommand->addArgument(1, "e", createArgType<TUPLE_INT_INT_STR, int, 1>(TUPLE_INT_INT_STR()), "end line (optional, default: last line)", false); |
175 | 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); |
176 | |
177 | - theCommandLine << lCommand; |
178 | + *theCommandLine << lCommand; |
179 | } |
180 | |
181 | // DBGP: eval |
182 | @@ -363,7 +366,7 @@ |
183 | // - everything following the fist contiguous set of whitespaces are sent as string |
184 | lCommand->addArgument(0, "c", createArgType<TUPLE_STR, std::string, 0>(TUPLE_STR()), "expression to evaluate", true); |
185 | |
186 | - theCommandLine << lCommand; |
187 | + *theCommandLine << lCommand; |
188 | } |
189 | |
190 | // DBGP: step_in |
191 | @@ -371,14 +374,14 @@ |
192 | std::set<std::string> lAliases; |
193 | lAliases.insert("step"); |
194 | lAliases.insert("s"); |
195 | - theCommandLine << createCommand<StepIn>(TUPLE(), "in", lAliases, *this, "Step in"); |
196 | + *theCommandLine << createCommand<StepIn>(TUPLE(), "in", lAliases, *this, "Step in"); |
197 | } |
198 | |
199 | // DBGP: step_out |
200 | { |
201 | std::set<std::string> lAliases; |
202 | lAliases.insert("finish"); |
203 | - theCommandLine << createCommand<StepOut>(TUPLE(), "out", lAliases, *this, "Step out"); |
204 | + *theCommandLine << createCommand<StepOut>(TUPLE(), "out", lAliases, *this, "Step out"); |
205 | } |
206 | |
207 | // DBGP: step_over |
208 | @@ -386,7 +389,7 @@ |
209 | std::set<std::string> lAliases; |
210 | lAliases.insert("next"); |
211 | lAliases.insert("n"); |
212 | - theCommandLine << createCommand<StepOver>(TUPLE(), "over", lAliases, *this, "Step over"); |
213 | + *theCommandLine << createCommand<StepOver>(TUPLE(), "over", lAliases, *this, "Step over"); |
214 | } |
215 | } |
216 | |
217 | |
218 | === modified file 'bin/debugger/command_line_handler.h' |
219 | --- bin/debugger/command_line_handler.h 2011-12-21 14:40:33 +0000 |
220 | +++ bin/debugger/command_line_handler.h 2011-12-23 12:56:26 +0000 |
221 | @@ -23,12 +23,13 @@ |
222 | #include <zorba/debugger_client.h> |
223 | |
224 | #include "command.h" |
225 | -#include "command_prompt.h" |
226 | #include "event_handler.h" |
227 | |
228 | |
229 | namespace zorba { namespace debugger { |
230 | |
231 | + class CommandPrompt; |
232 | + |
233 | enum Commands { |
234 | Status, |
235 | Variables, |
236 | @@ -62,8 +63,8 @@ |
237 | unsigned short port, |
238 | LockFreeConsumer<std::size_t>& aConsumer, |
239 | LockFreeConsumer<bool>& aContinueQueue, |
240 | - EventHandler& aHandler, |
241 | - CommandPrompt& aCommandPrompt); |
242 | + EventHandler* aHandler, |
243 | + CommandPrompt* aCommandPrompt); |
244 | |
245 | ~CommandLineHandler(); |
246 | |
247 | @@ -112,7 +113,7 @@ |
248 | LockFreeConsumer<std::size_t>& theConsumer; |
249 | LockFreeConsumer<bool>& theContinueQueue; |
250 | DebuggerClient* theClient; |
251 | - CommandPrompt& theCommandLine; |
252 | + CommandPrompt* theCommandLine; |
253 | bool theQuit; |
254 | bool theTerminated; |
255 | bool theContinue; |
256 | |
257 | === modified file 'bin/debugger/main.cpp' |
258 | --- bin/debugger/main.cpp 2011-12-21 14:40:33 +0000 |
259 | +++ bin/debugger/main.cpp 2011-12-23 12:56:26 +0000 |
260 | @@ -26,10 +26,73 @@ |
261 | |
262 | #include "command_prompt.h" |
263 | #include "command_line_handler.h" |
264 | +#include "process_listener.h" |
265 | |
266 | using namespace zorba; |
267 | using namespace zorba::debugger; |
268 | |
269 | +class XqdbClient { |
270 | + |
271 | + public: |
272 | + |
273 | + XqdbClient(unsigned int aPort) |
274 | + { |
275 | + theIdQueue = new LockFreeQueue<std::size_t>(); |
276 | + theQuitQueue = new LockFreeQueue<bool>(); |
277 | + theEventHandler = new EventHandler(*theIdQueue, *theQuitQueue); |
278 | + theEventHandler->init(); |
279 | + |
280 | + theCommandPrompt = new CommandPrompt(); |
281 | + theCommandLineHandler = new CommandLineHandler(aPort, *theIdQueue, *theQuitQueue, theEventHandler, theCommandPrompt); |
282 | + } |
283 | + |
284 | + ~XqdbClient() |
285 | + { |
286 | + if (theCommandLineHandler) { |
287 | + delete theCommandLineHandler; |
288 | + } |
289 | + if (theCommandPrompt) { |
290 | + delete theCommandPrompt; |
291 | + } |
292 | + if (theEventHandler) { |
293 | + delete theEventHandler; |
294 | + } |
295 | + |
296 | + delete theIdQueue; |
297 | + delete theQuitQueue; |
298 | + } |
299 | + |
300 | + void start() |
301 | + { |
302 | + theCommandLineHandler->execute(); |
303 | + } |
304 | + |
305 | + private: |
306 | + |
307 | + LockFreeQueue<std::size_t>* theIdQueue; |
308 | + LockFreeQueue<bool>* theQuitQueue; |
309 | + |
310 | + EventHandler* theEventHandler; |
311 | + CommandPrompt* theCommandPrompt; |
312 | + CommandLineHandler* theCommandLineHandler; |
313 | +}; |
314 | + |
315 | + |
316 | +XqdbClient* theClient; |
317 | + |
318 | + |
319 | +void |
320 | +onExitProcess(ExitCode aExitCode) { |
321 | + //if (aExitCode != -1) { |
322 | + // std::cout << "Zorba has exited with code: " << aExitCode << std::endl; |
323 | + //} |
324 | + std::cout << "Terminating debugger client."<< std::endl; |
325 | + // TODO: and the memory? |
326 | + |
327 | + delete theClient; |
328 | + exit(aExitCode); |
329 | +} |
330 | + |
331 | int |
332 | startZorba(std::string& aExec, std::vector<std::string>& aArgs) |
333 | { |
334 | @@ -38,7 +101,6 @@ |
335 | // start a process on Windows |
336 | |
337 | DWORD iReturnVal = 0; |
338 | - DWORD dwExitCode = 0; |
339 | |
340 | std::wstring lExec; |
341 | std::wstring lArgs; |
342 | @@ -81,7 +143,7 @@ |
343 | |
344 | if (lResult) { |
345 | // Watch the process |
346 | - dwExitCode = WaitForSingleObject(piProcessInfo.hProcess, 0); |
347 | + ProcessListener* lPl = new ProcessListener(piProcessInfo.hProcess, &onExitProcess); |
348 | } |
349 | else { |
350 | // CreateProcess failed |
351 | @@ -150,9 +212,15 @@ |
352 | if (pID < 0) { |
353 | std::cerr << "Failed to fork Zorba" << std::endl; |
354 | return pID; |
355 | - } else { |
356 | - return 0; |
357 | } |
358 | + |
359 | + // pID > 0 |
360 | + |
361 | + // Watch the process |
362 | + //ProcessListener* lPl = |
363 | + new ProcessListener(pID, &onExitProcess); |
364 | + |
365 | + return 0; |
366 | } |
367 | #endif |
368 | } |
369 | @@ -298,30 +366,27 @@ |
370 | return lResult; |
371 | } |
372 | } else { |
373 | - std::cout << "Waiting for an incomming Zorba connection..." << std::endl; |
374 | + std::cout << "Listening for an incomming Zorba connection on port " << lPort << "..." << std::endl; |
375 | } |
376 | |
377 | // ************************************************************************** |
378 | // start the debugger command line |
379 | |
380 | - LockFreeQueue<std::size_t> lQueue; |
381 | - LockFreeQueue<bool> lContEvent; |
382 | - EventHandler lEventHandler(lQueue, lContEvent); |
383 | - lEventHandler.init(); |
384 | - |
385 | - CommandPrompt lCommandPrompt; |
386 | - CommandLineHandler lCommandLineHandler(lPort, lQueue, lContEvent, lEventHandler, lCommandPrompt); |
387 | - |
388 | - lCommandLineHandler.execute(); |
389 | + theClient = new XqdbClient(lPort); |
390 | + theClient->start(); |
391 | + |
392 | + //tCommandLineHandler.execute(); |
393 | |
394 | #ifndef WIN32 |
395 | wait(); |
396 | #endif |
397 | |
398 | + delete theClient; |
399 | + |
400 | } catch (...) { |
401 | + delete theClient; |
402 | return -1; |
403 | } |
404 | |
405 | return 0; |
406 | } |
407 | - |
408 | |
409 | === added file 'bin/debugger/process_listener.cpp' |
410 | --- bin/debugger/process_listener.cpp 1970-01-01 00:00:00 +0000 |
411 | +++ bin/debugger/process_listener.cpp 2011-12-23 12:56:26 +0000 |
412 | @@ -0,0 +1,102 @@ |
413 | +/* |
414 | + * Copyright 2006-2008 The FLWOR Foundation. |
415 | + * |
416 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
417 | + * you may not use this file except in compliance with the License. |
418 | + * You may obtain a copy of the License at |
419 | + * |
420 | + * http://www.apache.org/licenses/LICENSE-2.0 |
421 | + * |
422 | + * Unless required by applicable law or agreed to in writing, software |
423 | + * distributed under the License is distributed on an "AS IS" BASIS, |
424 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
425 | + * See the License for the specific language governing permissions and |
426 | + * limitations under the License. |
427 | + */ |
428 | + |
429 | +#include "process_listener.h" |
430 | + |
431 | +#include <iostream> |
432 | + |
433 | +#ifdef ZORBA_HAVE_PTHREAD_H |
434 | +# include <sys/wait.h> |
435 | +# include <cassert> |
436 | +#endif |
437 | + |
438 | + |
439 | +namespace zorba { namespace debugger { |
440 | + |
441 | +ProcessListener::ProcessListener(ProcessId aProcessID, ExitCallbackType aCallback) |
442 | + : theProcessID(aProcessID), theCallback(aCallback) |
443 | +{ |
444 | +#ifdef WIN32 |
445 | + theThread = CreateThread(NULL, 0, &run, (void*) this, 0, &theThreadId); |
446 | +#else |
447 | + if (pthread_create(&theThread, NULL, &run, (void*) this)) { |
448 | + assert(false); |
449 | + } |
450 | +#endif |
451 | +} |
452 | + |
453 | +ProcessListener::~ProcessListener() |
454 | +{ |
455 | +} |
456 | + |
457 | +ProcessId |
458 | +ProcessListener::getProcessID() |
459 | +{ |
460 | + return theProcessID; |
461 | +} |
462 | + |
463 | +ExitCallbackType |
464 | +ProcessListener::getCallback() |
465 | +{ |
466 | + return theCallback; |
467 | +} |
468 | + |
469 | + |
470 | +ZORBA_THREAD_RETURN |
471 | +ProcessListener::run(void* params) |
472 | +{ |
473 | + ProcessListener* lThis = static_cast<ProcessListener*>(params); |
474 | + ExitCode lExitCode = -1; |
475 | + ProcessId lPid = lThis->getProcessID(); |
476 | + |
477 | +#ifdef WIN32 |
478 | + // wait for the process to exit |
479 | + WaitForSingleObject(lPid, INFINITE); |
480 | + |
481 | + // find out the process exit code if possible |
482 | + if (!GetExitCodeProcess(lThis->getProcessID(), &lExitCode)) { |
483 | + lExitCode = -1; |
484 | + } |
485 | + |
486 | + // wait a little for zorba to dump the garbage |
487 | + Sleep(1000); |
488 | +#else |
489 | + int lChildExitStatus; |
490 | + |
491 | + // wait for the process to exit |
492 | + waitpid(lPid, &lChildExitStatus, 0); |
493 | + |
494 | + // find out the process exit code if possible |
495 | + if (WIFEXITED(lChildExitStatus)) { |
496 | + lExitCode = WEXITSTATUS(lChildExitStatus); |
497 | + } |
498 | + |
499 | + // wait a little for zorba to dump the garbage |
500 | + sleep(1); |
501 | +#endif |
502 | + |
503 | + // and call the callback when this happened |
504 | + ExitCallbackType lCallback = lThis->getCallback(); |
505 | + lCallback(lExitCode); |
506 | + |
507 | + for (int i = 0; i < 10; i++) { |
508 | + std::cout << i << std::endl; |
509 | + } |
510 | + return NULL; |
511 | +} |
512 | + |
513 | +} // namespace zorba |
514 | +} // namespace debugger |
515 | |
516 | === added file 'bin/debugger/process_listener.h' |
517 | --- bin/debugger/process_listener.h 1970-01-01 00:00:00 +0000 |
518 | +++ bin/debugger/process_listener.h 2011-12-23 12:56:26 +0000 |
519 | @@ -0,0 +1,74 @@ |
520 | +/* |
521 | + * Copyright 2006-2008 The FLWOR Foundation. |
522 | + * |
523 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
524 | + * you may not use this file except in compliance with the License. |
525 | + * You may obtain a copy of the License at |
526 | + * |
527 | + * http://www.apache.org/licenses/LICENSE-2.0 |
528 | + * |
529 | + * Unless required by applicable law or agreed to in writing, software |
530 | + * distributed under the License is distributed on an "AS IS" BASIS, |
531 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
532 | + * See the License for the specific language governing permissions and |
533 | + * limitations under the License. |
534 | + */ |
535 | +#pragma once |
536 | +#ifndef ZORBA_DEBUGGER_PROCESS_LISTENER_H |
537 | +#define ZORBA_DEBUGGER_PROCESS_LISTENER_H |
538 | + |
539 | +#include <zorba/config.h> |
540 | + |
541 | +#ifdef ZORBA_HAVE_PTHREAD_H |
542 | +# include <pthread.h> |
543 | + typedef pthread_t ThreadId; |
544 | + typedef pid_t ProcessId; |
545 | + typedef int ExitCode; |
546 | +# define ZORBA_THREAD_RETURN void * |
547 | +#else |
548 | +# include <windows.h> |
549 | + typedef DWORD ThreadId; |
550 | + typedef HANDLE ProcessId; |
551 | + typedef DWORD ExitCode; |
552 | +# define ZORBA_THREAD_RETURN DWORD WINAPI |
553 | +#endif |
554 | + |
555 | +typedef void (*ExitCallbackType)(ExitCode); |
556 | + |
557 | + |
558 | +namespace zorba { namespace debugger { |
559 | + |
560 | +class ProcessListener |
561 | +{ |
562 | + public: |
563 | + ProcessListener(ProcessId processID, ExitCallbackType callback); |
564 | + |
565 | + ~ProcessListener(); |
566 | + |
567 | + ProcessId |
568 | + getProcessID(); |
569 | + |
570 | + ExitCallbackType |
571 | + getCallback(); |
572 | + |
573 | + private: |
574 | + |
575 | + static ZORBA_THREAD_RETURN run(void* params); |
576 | + |
577 | + private: |
578 | + |
579 | +#ifdef ZORBA_HAVE_PTHREAD_H |
580 | + pthread_t theThread; |
581 | +#else |
582 | + ThreadId theThreadId; |
583 | + HANDLE theThread; |
584 | +#endif |
585 | + |
586 | + ProcessId theProcessID; |
587 | + ExitCallbackType theCallback; |
588 | +}; |
589 | + |
590 | +} // namespace zorba |
591 | +} // namespace debugger |
592 | + |
593 | +#endif // ZORBA_DEBUGGER_PROCESS_LISTENER_H |
594 | |
595 | === modified file 'include/zorba/config.h.cmake' |
596 | --- include/zorba/config.h.cmake 2011-12-21 14:40:33 +0000 |
597 | +++ include/zorba/config.h.cmake 2011-12-23 12:56:26 +0000 |
598 | @@ -153,7 +153,6 @@ |
599 | #cmakedefine ZORBA_WITH_DEBUGGER |
600 | #cmakedefine ZORBA_WITH_FILE_ACCESS |
601 | #cmakedefine ZORBA_WITH_LIBXML2_SAX |
602 | -#cmakedefine ZORBA_WITH_DEBUGGER_CLIENT |
603 | |
604 | // Zorba parser configuration |
605 | #cmakedefine ZORBA_DEBUG_PARSER |
606 | |
607 | === modified file 'src/debugger/debugger_commons.cpp' |
608 | --- src/debugger/debugger_commons.cpp 2011-12-21 14:40:33 +0000 |
609 | +++ src/debugger/debugger_commons.cpp 2011-12-23 12:56:26 +0000 |
610 | @@ -226,7 +226,7 @@ |
611 | } |
612 | |
613 | unsigned int |
614 | -DebuggerCommons::addBreakpoint(String& aFileName, int aLine, bool aEnabled) |
615 | +DebuggerCommons::addBreakpoint(String& aFileName, unsigned int aLine, bool aEnabled) |
616 | { |
617 | QueryLoc lLocation; |
618 | lLocation.setLineBegin(aLine); |
619 | @@ -261,7 +261,6 @@ |
620 | |
621 | // 2. secondly we hope he gave us part of a path of a file |
622 | lIter = theBreakableIDs.begin(); |
623 | - String::size_type lFileNameSize = lFileName.size(); |
624 | std::vector<std::pair<QueryLoc, int> > lFoundBreakables; |
625 | zorba::String lFirstBreakablePath; |
626 | while (lIter != theBreakableIDs.end()) { |
627 | |
628 | === modified file 'src/debugger/debugger_commons.h' |
629 | --- src/debugger/debugger_commons.h 2011-12-21 14:40:33 +0000 |
630 | +++ src/debugger/debugger_commons.h 2011-12-23 12:56:26 +0000 |
631 | @@ -238,7 +238,7 @@ |
632 | public: |
633 | |
634 | unsigned int |
635 | - addBreakpoint(String& fileName, int line, bool enabled); |
636 | + addBreakpoint(String& fileName, unsigned int line, bool enabled); |
637 | |
638 | Breakable |
639 | getBreakpoint(unsigned int id); |
640 | @@ -383,7 +383,7 @@ |
641 | store::Item_t theEvalItem; |
642 | bool theExecEval; |
643 | bool theStepping; |
644 | - unsigned int theMainModuleBreakableId; |
645 | + unsigned int theMainModuleBreakableId; |
646 | }; |
647 | |
648 | } |
649 | |
650 | === modified file 'src/debugger/debugger_protocol.cpp' |
651 | --- src/debugger/debugger_protocol.cpp 2011-12-21 14:40:33 +0000 |
652 | +++ src/debugger/debugger_protocol.cpp 2011-12-23 12:56:26 +0000 |
653 | @@ -158,4 +158,16 @@ |
654 | } |
655 | } |
656 | |
657 | +bool |
658 | +DebuggerCommand::getArg(std::string aArg, unsigned int& aValue) { |
659 | + std::map<std::string, std::string>::iterator lElem = theArgs.find(aArg); |
660 | + if (lElem == theArgs.end()) { |
661 | + return false; |
662 | + } else { |
663 | + std::stringstream lSs(lElem->second); |
664 | + lSs >> aValue; |
665 | + return true; |
666 | + } |
667 | +} |
668 | + |
669 | } // namespace zorba |
670 | |
671 | === modified file 'src/debugger/debugger_protocol.h' |
672 | --- src/debugger/debugger_protocol.h 2011-06-22 11:19:07 +0000 |
673 | +++ src/debugger/debugger_protocol.h 2011-12-23 12:56:26 +0000 |
674 | @@ -45,6 +45,9 @@ |
675 | bool |
676 | getArg(std::string arg, int& value); |
677 | |
678 | + bool |
679 | + getArg(std::string arg, unsigned int& value); |
680 | + |
681 | std::string& |
682 | getName() { return theName; } |
683 | |
684 | |
685 | === modified file 'src/debugger/debugger_runtime.cpp' |
686 | --- src/debugger/debugger_runtime.cpp 2011-12-21 14:40:33 +0000 |
687 | +++ src/debugger/debugger_runtime.cpp 2011-12-23 12:56:26 +0000 |
688 | @@ -158,7 +158,7 @@ |
689 | // Breakpoints |
690 | |
691 | unsigned int |
692 | -DebuggerRuntime::addBreakpoint(String& aFileName, int aLine, bool aEnabled) |
693 | +DebuggerRuntime::addBreakpoint(String& aFileName, unsigned int aLine, bool aEnabled) |
694 | { |
695 | AutoLock lLock(theLock, Lock::WRITE); |
696 | DebuggerCommons* lCommons = getDebbugerCommons(); |
697 | |
698 | === modified file 'src/debugger/debugger_runtime.h' |
699 | --- src/debugger/debugger_runtime.h 2011-12-21 14:40:33 +0000 |
700 | +++ src/debugger/debugger_runtime.h 2011-12-23 12:56:26 +0000 |
701 | @@ -82,7 +82,7 @@ |
702 | // Breakpints |
703 | |
704 | unsigned int |
705 | - addBreakpoint(String& aFileName, int aLine, bool enabled); |
706 | + addBreakpoint(String& aFileName, unsigned int aLine, bool enabled); |
707 | |
708 | Breakable |
709 | getBreakpoint(unsigned int id); |
710 | |
711 | === modified file 'src/debugger/debugger_server.cpp' |
712 | --- src/debugger/debugger_server.cpp 2011-12-21 14:40:33 +0000 |
713 | +++ src/debugger/debugger_server.cpp 2011-12-23 12:56:26 +0000 |
714 | @@ -201,7 +201,7 @@ |
715 | } else { |
716 | if (aCommand.getName() == "breakpoint_set") { |
717 | |
718 | - int lLineNo; |
719 | + unsigned int lLineNo; |
720 | aCommand.getArg("n", lLineNo); |
721 | std::string lFileNameTmp; |
722 | aCommand.getArg("f", lFileNameTmp); |
Looks good!