Introduced DBG_VALUE struct to manipulate debugger/debuggee address space.
[wine/dcerpc.git] / debugger / display.c
blob80926f99946f2db6c15eaba6ca926a6085e89289
1 /*
2 * File display.c - display handling for Wine internal debugger.
4 * Copyright (C) 1997, Eric Youngdale.
6 */
8 #include <stdlib.h>
9 #include <stdio.h>
10 #include <string.h>
11 #include <limits.h>
12 #include <sys/types.h>
14 #include "debugger.h"
16 #include <stdarg.h>
18 #define MAX_DISPLAY 25
20 struct display
22 struct expr * exp;
23 int count;
24 char format;
27 static struct display displaypoints[MAX_DISPLAY];
29 int
30 DEBUG_AddDisplay(struct expr * exp, int count, char format)
32 int i;
35 * First find a slot where we can store this display.
37 for(i=0; i < MAX_DISPLAY; i++ )
39 if( displaypoints[i].exp == NULL )
41 displaypoints[i].exp = DEBUG_CloneExpr(exp);
42 displaypoints[i].count = count;
43 displaypoints[i].format = format;
44 break;
48 return TRUE;
51 int
52 DEBUG_InfoDisplay(void)
54 int i;
57 * First find a slot where we can store this display.
59 for(i=0; i < MAX_DISPLAY; i++ )
61 if( displaypoints[i].exp != NULL )
63 fprintf(stderr, "%d : ", i+1);
64 DEBUG_DisplayExpr(displaypoints[i].exp);
65 fprintf(stderr, "\n");
69 return TRUE;
72 int
73 DEBUG_DoDisplay(void)
75 DBG_VALUE value;
76 int i;
79 * First find a slot where we can store this display.
81 for(i=0; i < MAX_DISPLAY; i++ )
83 if( displaypoints[i].exp != NULL )
85 value = DEBUG_EvalExpr(displaypoints[i].exp);
86 if( value.type == NULL )
88 fprintf(stderr, "Unable to evaluate expression ");
89 DEBUG_DisplayExpr(displaypoints[i].exp);
90 fprintf(stderr, "\nDisabling...\n");
91 DEBUG_DelDisplay(i);
93 else
95 fprintf(stderr, "%d : ", i + 1);
96 DEBUG_DisplayExpr(displaypoints[i].exp);
97 fprintf(stderr, " = ");
98 if( displaypoints[i].format == 'i' )
100 DEBUG_ExamineMemory( &value,
101 displaypoints[i].count,
102 displaypoints[i].format);
104 else
106 DEBUG_Print( &value,
107 displaypoints[i].count,
108 displaypoints[i].format, 0);
114 return TRUE;
118 DEBUG_DelDisplay(int displaynum)
120 int i;
122 if( displaynum >= MAX_DISPLAY || displaynum == 0 || displaynum < -1 )
124 fprintf(stderr, "Invalid display number\n");
125 return TRUE;
127 if( displaynum == -1 )
129 for(i=0; i < MAX_DISPLAY; i++ )
131 if( displaypoints[i].exp != NULL )
133 DEBUG_FreeExpr(displaypoints[i].exp);
134 displaypoints[i].exp = NULL;
138 else if( displaypoints[displaynum - 1].exp != NULL )
140 DEBUG_FreeExpr(displaypoints[displaynum - 1].exp);
141 displaypoints[displaynum - 1].exp = NULL;
143 return TRUE;