blob: 2bf402ec47a77a14c54415cacf2f4a61c7efec7e [file] [log] [blame]
Alexandre Julliardc6c09441997-01-12 18:32:19 +00001/*
2 * File display.c - display handling for Wine internal debugger.
3 *
4 * Copyright (C) 1997, Eric Youngdale.
5 *
6 */
7
8#include <stdlib.h>
Alexandre Julliardc6c09441997-01-12 18:32:19 +00009#include <string.h>
10#include <limits.h>
11#include <sys/types.h>
Patrik Stridvall021bd851999-07-18 18:40:11 +000012
Alexandre Julliardc6c09441997-01-12 18:32:19 +000013#include "debugger.h"
Alexandre Julliardc6c09441997-01-12 18:32:19 +000014
15#include <stdarg.h>
16
17#define MAX_DISPLAY 25
Alexandre Julliard01d63461997-01-20 19:43:45 +000018
19struct display
20{
21 struct expr * exp;
22 int count;
23 char format;
24};
25
26static struct display displaypoints[MAX_DISPLAY];
Alexandre Julliardc6c09441997-01-12 18:32:19 +000027
28int
Alexandre Julliard01d63461997-01-20 19:43:45 +000029DEBUG_AddDisplay(struct expr * exp, int count, char format)
Alexandre Julliardc6c09441997-01-12 18:32:19 +000030{
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 {
Alexandre Julliard01d63461997-01-20 19:43:45 +000038 if( displaypoints[i].exp == NULL )
Alexandre Julliardc6c09441997-01-12 18:32:19 +000039 {
Alexandre Julliard01d63461997-01-20 19:43:45 +000040 displaypoints[i].exp = DEBUG_CloneExpr(exp);
41 displaypoints[i].count = count;
42 displaypoints[i].format = format;
Alexandre Julliardc6c09441997-01-12 18:32:19 +000043 break;
44 }
45 }
46
47 return TRUE;
48}
49
50int
Eric Pouechd33bcb62000-03-15 19:57:20 +000051DEBUG_InfoDisplay(void)
Alexandre Julliardc6c09441997-01-12 18:32:19 +000052{
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 {
Alexandre Julliard01d63461997-01-20 19:43:45 +000060 if( displaypoints[i].exp != NULL )
Alexandre Julliardc6c09441997-01-12 18:32:19 +000061 {
Eric Poueche5efa0c2000-04-13 19:31:58 +000062 DEBUG_Printf(DBG_CHN_MESG, "%d : ", i+1);
Alexandre Julliard01d63461997-01-20 19:43:45 +000063 DEBUG_DisplayExpr(displaypoints[i].exp);
Eric Poueche5efa0c2000-04-13 19:31:58 +000064 DEBUG_Printf(DBG_CHN_MESG, "\n");
Alexandre Julliardc6c09441997-01-12 18:32:19 +000065 }
66 }
67
68 return TRUE;
69}
70
71int
Eric Pouechd33bcb62000-03-15 19:57:20 +000072DEBUG_DoDisplay(void)
Alexandre Julliardc6c09441997-01-12 18:32:19 +000073{
Eric Pouechd33bcb62000-03-15 19:57:20 +000074 DBG_VALUE value;
75 int i;
Alexandre Julliardc6c09441997-01-12 18:32:19 +000076
77 /*
78 * First find a slot where we can store this display.
79 */
80 for(i=0; i < MAX_DISPLAY; i++ )
81 {
Alexandre Julliard01d63461997-01-20 19:43:45 +000082 if( displaypoints[i].exp != NULL )
Alexandre Julliardc6c09441997-01-12 18:32:19 +000083 {
Eric Pouechd33bcb62000-03-15 19:57:20 +000084 value = DEBUG_EvalExpr(displaypoints[i].exp);
85 if( value.type == NULL )
Alexandre Julliardc6c09441997-01-12 18:32:19 +000086 {
Eric Poueche5efa0c2000-04-13 19:31:58 +000087 DEBUG_Printf(DBG_CHN_MESG, "Unable to evaluate expression ");
Alexandre Julliard01d63461997-01-20 19:43:45 +000088 DEBUG_DisplayExpr(displaypoints[i].exp);
Eric Poueche5efa0c2000-04-13 19:31:58 +000089 DEBUG_Printf(DBG_CHN_MESG, "\nDisabling...\n");
Alexandre Julliardc6c09441997-01-12 18:32:19 +000090 DEBUG_DelDisplay(i);
91 }
92 else
93 {
Eric Poueche5efa0c2000-04-13 19:31:58 +000094 DEBUG_Printf(DBG_CHN_MESG, "%d : ", i + 1);
Alexandre Julliard01d63461997-01-20 19:43:45 +000095 DEBUG_DisplayExpr(displaypoints[i].exp);
Eric Poueche5efa0c2000-04-13 19:31:58 +000096 DEBUG_Printf(DBG_CHN_MESG, " = ");
Alexandre Julliard01d63461997-01-20 19:43:45 +000097 if( displaypoints[i].format == 'i' )
98 {
Eric Pouechd33bcb62000-03-15 19:57:20 +000099 DEBUG_ExamineMemory( &value,
100 displaypoints[i].count,
101 displaypoints[i].format);
Alexandre Julliard01d63461997-01-20 19:43:45 +0000102 }
103 else
104 {
Eric Pouechd33bcb62000-03-15 19:57:20 +0000105 DEBUG_Print( &value,
Alexandre Julliard01d63461997-01-20 19:43:45 +0000106 displaypoints[i].count,
107 displaypoints[i].format, 0);
108 }
Alexandre Julliardc6c09441997-01-12 18:32:19 +0000109 }
110 }
111 }
112
113 return TRUE;
114}
115
116int
117DEBUG_DelDisplay(int displaynum)
118{
119 int i;
120
121 if( displaynum >= MAX_DISPLAY || displaynum == 0 || displaynum < -1 )
122 {
Eric Poueche5efa0c2000-04-13 19:31:58 +0000123 DEBUG_Printf(DBG_CHN_MESG, "Invalid display number\n");
Alexandre Julliardc6c09441997-01-12 18:32:19 +0000124 return TRUE;
125 }
126 if( displaynum == -1 )
127 {
128 for(i=0; i < MAX_DISPLAY; i++ )
129 {
Alexandre Julliard01d63461997-01-20 19:43:45 +0000130 if( displaypoints[i].exp != NULL )
Alexandre Julliardc6c09441997-01-12 18:32:19 +0000131 {
Alexandre Julliard01d63461997-01-20 19:43:45 +0000132 DEBUG_FreeExpr(displaypoints[i].exp);
133 displaypoints[i].exp = NULL;
Alexandre Julliardc6c09441997-01-12 18:32:19 +0000134 }
135 }
136 }
Alexandre Julliard01d63461997-01-20 19:43:45 +0000137 else if( displaypoints[displaynum - 1].exp != NULL )
Alexandre Julliardc6c09441997-01-12 18:32:19 +0000138 {
Alexandre Julliard01d63461997-01-20 19:43:45 +0000139 DEBUG_FreeExpr(displaypoints[displaynum - 1].exp);
140 displaypoints[displaynum - 1].exp = NULL;
Alexandre Julliardc6c09441997-01-12 18:32:19 +0000141 }
142 return TRUE;
143}