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