1 | /* pmdebug.cc
|
---|
2 | Copyright (c) 1996 Eberhard Mattes
|
---|
3 |
|
---|
4 | This file is part of pmgdb.
|
---|
5 |
|
---|
6 | pmgdb is free software; you can redistribute it and/or modify
|
---|
7 | it under the terms of the GNU General Public License as published by
|
---|
8 | the Free Software Foundation; either version 2, or (at your option)
|
---|
9 | any later version.
|
---|
10 |
|
---|
11 | pmgdb is distributed in the hope that it will be useful,
|
---|
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
14 | GNU General Public License for more details.
|
---|
15 |
|
---|
16 | You should have received a copy of the GNU General Public License
|
---|
17 | along with pmgdb; see the file COPYING. If not, write to
|
---|
18 | the Free Software Foundation, 59 Temple Place - Suite 330,
|
---|
19 | Boston, MA 02111-1307, USA. */
|
---|
20 |
|
---|
21 |
|
---|
22 | #define INCL_DOS
|
---|
23 | #define INCL_WIN
|
---|
24 | #include <os2.h>
|
---|
25 | #include <stdlib.h>
|
---|
26 | #include <string.h>
|
---|
27 | #include "pmdebug.h"
|
---|
28 |
|
---|
29 |
|
---|
30 | pmdebug pmdbg;
|
---|
31 |
|
---|
32 |
|
---|
33 | static VOID APIENTRY pmdebug_exitlist (ULONG)
|
---|
34 | {
|
---|
35 | pmdbg.exit ();
|
---|
36 | DosExitList (EXLST_EXIT, NULL);
|
---|
37 | }
|
---|
38 |
|
---|
39 |
|
---|
40 | pmdebug::pmdebug ()
|
---|
41 | {
|
---|
42 | cur_mode = off; locked = false; pid = 0; hwndLock = NULLHANDLE;
|
---|
43 | }
|
---|
44 |
|
---|
45 |
|
---|
46 | pmdebug::~pmdebug ()
|
---|
47 | {
|
---|
48 | exit ();
|
---|
49 | }
|
---|
50 |
|
---|
51 |
|
---|
52 | void pmdebug::exit ()
|
---|
53 | {
|
---|
54 | if (cur_mode == sync && locked)
|
---|
55 | {
|
---|
56 | // TODO: Destroy all windows of the debuggee (pid)
|
---|
57 | // TODO: Kill debuggee (important!)
|
---|
58 | WinLockInput (NULLHANDLE, FALSE);
|
---|
59 | locked = false;
|
---|
60 | }
|
---|
61 | set_mode (off, NULLHANDLE);
|
---|
62 | }
|
---|
63 |
|
---|
64 |
|
---|
65 | void pmdebug::set_mode (mode new_mode, HWND hwnd, int in_pid)
|
---|
66 | {
|
---|
67 | if (new_mode == cur_mode)
|
---|
68 | return;
|
---|
69 | if (cur_mode == sync && locked)
|
---|
70 | {
|
---|
71 | WinLockInput (NULLHANDLE, FALSE);
|
---|
72 | locked = false;
|
---|
73 | }
|
---|
74 | if (new_mode == sync)
|
---|
75 | DosExitList (EXLST_ADD | (0 << 8), pmdebug_exitlist);
|
---|
76 | else if (cur_mode == sync)
|
---|
77 | DosExitList (EXLST_REMOVE, pmdebug_exitlist);
|
---|
78 | cur_mode = new_mode;
|
---|
79 | pid = in_pid; hwndLock = hwnd;
|
---|
80 | }
|
---|
81 |
|
---|
82 |
|
---|
83 | void pmdebug::start ()
|
---|
84 | {
|
---|
85 | switch (cur_mode)
|
---|
86 | {
|
---|
87 | case sync:
|
---|
88 | if (locked)
|
---|
89 | WinLockInput (NULLHANDLE, FALSE);
|
---|
90 | locked = false;
|
---|
91 | break;
|
---|
92 | default:
|
---|
93 | break;
|
---|
94 | }
|
---|
95 | }
|
---|
96 |
|
---|
97 |
|
---|
98 | void pmdebug::stop ()
|
---|
99 | {
|
---|
100 | switch (cur_mode)
|
---|
101 | {
|
---|
102 | case sync:
|
---|
103 | if (!locked)
|
---|
104 | {
|
---|
105 | locked = true;
|
---|
106 | WinLockInput (NULLHANDLE, FALSE);
|
---|
107 | WinLockInput (NULLHANDLE, WLI_NOBUTTONUP);
|
---|
108 | WinSetSysModalWindow (HWND_DESKTOP, hwndLock);
|
---|
109 | WinSetFocus (HWND_DESKTOP, hwndLock);
|
---|
110 | WinSetSysModalWindow (HWND_DESKTOP, NULLHANDLE);
|
---|
111 | }
|
---|
112 | break;
|
---|
113 | default:
|
---|
114 | break;
|
---|
115 | }
|
---|
116 | }
|
---|
117 |
|
---|
118 |
|
---|
119 | void pmdebug::term ()
|
---|
120 | {
|
---|
121 | pid = 0;
|
---|
122 | start ();
|
---|
123 | }
|
---|