Move int08 stub and LOL to upper memory.
[wine] / programs / winedbg / display.c
1 /*
2  * File display.c - display handling for Wine internal debugger.
3  *
4  * Copyright (C) 1997, Eric Youngdale.
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * This library 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 GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19  */
20
21 #include <stdlib.h>
22 #include <string.h>
23 #include <limits.h>
24 #include <sys/types.h>
25
26 #include "debugger.h"
27
28 #include <stdarg.h>
29
30 #define MAX_DISPLAY 25
31
32 struct display
33 {
34   struct expr * exp;
35   int           count;
36   char          format;
37 };
38
39 static struct display displaypoints[MAX_DISPLAY];
40
41 int
42 DEBUG_AddDisplay(struct expr * exp, int count, char format)
43 {
44   int i;
45
46   /*
47    * First find a slot where we can store this display.
48    */
49   for(i=0; i < MAX_DISPLAY; i++ )
50     {
51       if( displaypoints[i].exp == NULL )
52         {
53           displaypoints[i].exp = DEBUG_CloneExpr(exp);
54           displaypoints[i].count  = count;
55           displaypoints[i].format = format;
56           break;
57         }
58     }
59
60   return TRUE;
61 }
62
63 int
64 DEBUG_InfoDisplay(void)
65 {
66   int i;
67
68   /*
69    * First find a slot where we can store this display.
70    */
71   for(i=0; i < MAX_DISPLAY; i++ )
72     {
73       if( displaypoints[i].exp != NULL )
74         {
75           DEBUG_Printf(DBG_CHN_MESG, "%d : ", i+1);
76           DEBUG_DisplayExpr(displaypoints[i].exp);
77           DEBUG_Printf(DBG_CHN_MESG, "\n");
78         }
79     }
80
81   return TRUE;
82 }
83
84 int
85 DEBUG_DoDisplay(void)
86 {
87   DBG_VALUE     value;
88   int           i;
89
90   /*
91    * First find a slot where we can store this display.
92    */
93   for(i=0; i < MAX_DISPLAY; i++ )
94     {
95       if( displaypoints[i].exp != NULL )
96         {
97           value = DEBUG_EvalExpr(displaypoints[i].exp);
98           if( value.type == NULL )
99             {
100               DEBUG_Printf(DBG_CHN_MESG, "Unable to evaluate expression ");
101               DEBUG_DisplayExpr(displaypoints[i].exp);
102               DEBUG_Printf(DBG_CHN_MESG, "\nDisabling...\n");
103               DEBUG_DelDisplay(i);
104             }
105           else
106             {
107               DEBUG_Printf(DBG_CHN_MESG, "%d  : ", i + 1);
108               DEBUG_DisplayExpr(displaypoints[i].exp);
109               DEBUG_Printf(DBG_CHN_MESG, " = ");
110               if( displaypoints[i].format == 'i' )
111                 {
112                   DEBUG_ExamineMemory( &value,
113                                        displaypoints[i].count,
114                                        displaypoints[i].format);
115                 }
116               else
117                 {
118                   DEBUG_Print( &value,
119                                displaypoints[i].count,
120                                displaypoints[i].format, 0);
121                 }
122             }
123         }
124     }
125
126   return TRUE;
127 }
128
129 int
130 DEBUG_DelDisplay(int displaynum)
131 {
132   int i;
133
134   if( displaynum >= MAX_DISPLAY || displaynum == 0 || displaynum < -1 )
135     {
136       DEBUG_Printf(DBG_CHN_MESG, "Invalid display number\n");
137       return TRUE;
138     }
139   if( displaynum == -1 )
140     {
141       for(i=0; i < MAX_DISPLAY; i++ )
142         {
143           if( displaypoints[i].exp != NULL )
144             {
145               DEBUG_FreeExpr(displaypoints[i].exp);
146               displaypoints[i].exp = NULL;
147             }
148         }
149     }
150   else if( displaypoints[displaynum - 1].exp != NULL )
151     {
152       DEBUG_FreeExpr(displaypoints[displaynum - 1].exp);
153       displaypoints[displaynum - 1].exp = NULL;
154     }
155   return TRUE;
156 }