Fixed handling of DGA2.0 keyboard events.
[wine] / debugger / display.c
1 /*
2  * File display.c - display handling for Wine internal debugger.
3  *
4  * Copyright (C) 1997, Eric Youngdale.
5  *
6  */
7
8 #include <stdlib.h>
9 #include <stdio.h>
10 #include <string.h>
11 #include <limits.h>
12 #include <sys/types.h>
13
14 #include "neexe.h"
15 #include "module.h"
16 #include "selectors.h"
17 #include "debugger.h"
18
19 #include <stdarg.h>
20
21 #define MAX_DISPLAY 25
22
23 struct display
24 {
25   struct expr * exp;
26   int           count;
27   char          format;
28 };
29
30 static struct display displaypoints[MAX_DISPLAY];
31
32 int
33 DEBUG_AddDisplay(struct expr * exp, int count, char format)
34 {
35   int i;
36
37   /*
38    * First find a slot where we can store this display.
39    */
40   for(i=0; i < MAX_DISPLAY; i++ )
41     {
42       if( displaypoints[i].exp == NULL )
43         {
44           displaypoints[i].exp = DEBUG_CloneExpr(exp);
45           displaypoints[i].count  = count;
46           displaypoints[i].format = format;
47           break;
48         }
49     }
50
51   return TRUE;
52 }
53
54 int
55 DEBUG_InfoDisplay()
56 {
57   int i;
58
59   /*
60    * First find a slot where we can store this display.
61    */
62   for(i=0; i < MAX_DISPLAY; i++ )
63     {
64       if( displaypoints[i].exp != NULL )
65         {
66           fprintf(stderr, "%d : ", i+1);
67           DEBUG_DisplayExpr(displaypoints[i].exp);
68           fprintf(stderr, "\n");
69         }
70     }
71
72   return TRUE;
73 }
74
75 int
76 DEBUG_DoDisplay()
77 {
78   DBG_ADDR      addr;
79   int i;
80
81   /*
82    * First find a slot where we can store this display.
83    */
84   for(i=0; i < MAX_DISPLAY; i++ )
85     {
86       if( displaypoints[i].exp != NULL )
87         {
88           addr = DEBUG_EvalExpr(displaypoints[i].exp);
89           if( addr.type == NULL )
90             {
91               fprintf(stderr, "Unable to evaluate expression ");
92               DEBUG_DisplayExpr(displaypoints[i].exp);
93               fprintf(stderr, "\nDisabling...\n");
94               DEBUG_DelDisplay(i);
95             }
96           else
97             {
98               fprintf(stderr, "%d  : ", i + 1);
99               DEBUG_DisplayExpr(displaypoints[i].exp);
100               fprintf(stderr, " = ");
101               if( displaypoints[i].format == 'i' )
102                 {
103                   DEBUG_ExamineMemory( &addr, 
104                                displaypoints[i].count, 
105                                displaypoints[i].format);
106                 }
107               else
108                 {
109                   DEBUG_Print( &addr, 
110                                displaypoints[i].count, 
111                                displaypoints[i].format, 0);
112                 }
113             }
114         }
115     }
116
117   return TRUE;
118 }
119
120 int
121 DEBUG_DelDisplay(int displaynum)
122 {
123   int i;
124   
125   if( displaynum >= MAX_DISPLAY || displaynum == 0 || displaynum < -1 )
126     {
127       fprintf(stderr, "Invalid display number\n");
128       return TRUE;
129     }
130   if( displaynum == -1 )
131     {
132       for(i=0; i < MAX_DISPLAY; i++ )
133         {
134           if( displaypoints[i].exp != NULL )
135             {
136               DEBUG_FreeExpr(displaypoints[i].exp);
137               displaypoints[i].exp = NULL;
138             }
139         }
140     }
141   else if( displaypoints[displaynum - 1].exp != NULL )
142     {
143       DEBUG_FreeExpr(displaypoints[displaynum - 1].exp);
144       displaypoints[displaynum - 1].exp = NULL;
145     }
146   return TRUE;
147 }