Fixed infinite loop for 0-length wavehdrs.
[wine/multimedia.git] / debugger / display.c
blobdf9f9fc5c35ad509cb7f1212c24cc1fbe7dd4532
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 "neexe.h"
15 #include "module.h"
16 #include "selectors.h"
17 #include "debugger.h"
19 #include <stdarg.h>
21 #define MAX_DISPLAY 25
23 struct display
25 struct expr * exp;
26 int count;
27 char format;
30 static struct display displaypoints[MAX_DISPLAY];
32 int
33 DEBUG_AddDisplay(struct expr * exp, int count, char format)
35 int i;
38 * First find a slot where we can store this display.
40 for(i=0; i < MAX_DISPLAY; i++ )
42 if( displaypoints[i].exp == NULL )
44 displaypoints[i].exp = DEBUG_CloneExpr(exp);
45 displaypoints[i].count = count;
46 displaypoints[i].format = format;
47 break;
51 return TRUE;
54 int
55 DEBUG_InfoDisplay()
57 int i;
60 * First find a slot where we can store this display.
62 for(i=0; i < MAX_DISPLAY; i++ )
64 if( displaypoints[i].exp != NULL )
66 fprintf(stderr, "%d : ", i+1);
67 DEBUG_DisplayExpr(displaypoints[i].exp);
68 fprintf(stderr, "\n");
72 return TRUE;
75 int
76 DEBUG_DoDisplay()
78 DBG_ADDR addr;
79 int i;
82 * First find a slot where we can store this display.
84 for(i=0; i < MAX_DISPLAY; i++ )
86 if( displaypoints[i].exp != NULL )
88 addr = DEBUG_EvalExpr(displaypoints[i].exp);
89 if( addr.type == NULL )
91 fprintf(stderr, "Unable to evaluate expression ");
92 DEBUG_DisplayExpr(displaypoints[i].exp);
93 fprintf(stderr, "\nDisabling...\n");
94 DEBUG_DelDisplay(i);
96 else
98 fprintf(stderr, "%d : ", i + 1);
99 DEBUG_DisplayExpr(displaypoints[i].exp);
100 fprintf(stderr, " = ");
101 if( displaypoints[i].format == 'i' )
103 DEBUG_ExamineMemory( &addr,
104 displaypoints[i].count,
105 displaypoints[i].format);
107 else
109 DEBUG_Print( &addr,
110 displaypoints[i].count,
111 displaypoints[i].format, 0);
117 return TRUE;
121 DEBUG_DelDisplay(int displaynum)
123 int i;
125 if( displaynum >= MAX_DISPLAY || displaynum == 0 || displaynum < -1 )
127 fprintf(stderr, "Invalid display number\n");
128 return TRUE;
130 if( displaynum == -1 )
132 for(i=0; i < MAX_DISPLAY; i++ )
134 if( displaypoints[i].exp != NULL )
136 DEBUG_FreeExpr(displaypoints[i].exp);
137 displaypoints[i].exp = NULL;
141 else if( displaypoints[displaynum - 1].exp != NULL )
143 DEBUG_FreeExpr(displaypoints[displaynum - 1].exp);
144 displaypoints[displaynum - 1].exp = NULL;
146 return TRUE;