Alexandre Julliard | c6c0944 | 1997-01-12 18:32:19 +0000 | [diff] [blame] | 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> |
Alexandre Julliard | c6c0944 | 1997-01-12 18:32:19 +0000 | [diff] [blame] | 9 | #include <string.h> |
| 10 | #include <limits.h> |
| 11 | #include <sys/types.h> |
Patrik Stridvall | 021bd85 | 1999-07-18 18:40:11 +0000 | [diff] [blame] | 12 | |
Alexandre Julliard | c6c0944 | 1997-01-12 18:32:19 +0000 | [diff] [blame] | 13 | #include "debugger.h" |
Alexandre Julliard | c6c0944 | 1997-01-12 18:32:19 +0000 | [diff] [blame] | 14 | |
| 15 | #include <stdarg.h> |
| 16 | |
| 17 | #define MAX_DISPLAY 25 |
Alexandre Julliard | 01d6346 | 1997-01-20 19:43:45 +0000 | [diff] [blame] | 18 | |
| 19 | struct display |
| 20 | { |
| 21 | struct expr * exp; |
| 22 | int count; |
| 23 | char format; |
| 24 | }; |
| 25 | |
| 26 | static struct display displaypoints[MAX_DISPLAY]; |
Alexandre Julliard | c6c0944 | 1997-01-12 18:32:19 +0000 | [diff] [blame] | 27 | |
| 28 | int |
Alexandre Julliard | 01d6346 | 1997-01-20 19:43:45 +0000 | [diff] [blame] | 29 | DEBUG_AddDisplay(struct expr * exp, int count, char format) |
Alexandre Julliard | c6c0944 | 1997-01-12 18:32:19 +0000 | [diff] [blame] | 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 | { |
Alexandre Julliard | 01d6346 | 1997-01-20 19:43:45 +0000 | [diff] [blame] | 38 | if( displaypoints[i].exp == NULL ) |
Alexandre Julliard | c6c0944 | 1997-01-12 18:32:19 +0000 | [diff] [blame] | 39 | { |
Alexandre Julliard | 01d6346 | 1997-01-20 19:43:45 +0000 | [diff] [blame] | 40 | displaypoints[i].exp = DEBUG_CloneExpr(exp); |
| 41 | displaypoints[i].count = count; |
| 42 | displaypoints[i].format = format; |
Alexandre Julliard | c6c0944 | 1997-01-12 18:32:19 +0000 | [diff] [blame] | 43 | break; |
| 44 | } |
| 45 | } |
| 46 | |
| 47 | return TRUE; |
| 48 | } |
| 49 | |
| 50 | int |
Eric Pouech | d33bcb6 | 2000-03-15 19:57:20 +0000 | [diff] [blame] | 51 | DEBUG_InfoDisplay(void) |
Alexandre Julliard | c6c0944 | 1997-01-12 18:32:19 +0000 | [diff] [blame] | 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 | { |
Alexandre Julliard | 01d6346 | 1997-01-20 19:43:45 +0000 | [diff] [blame] | 60 | if( displaypoints[i].exp != NULL ) |
Alexandre Julliard | c6c0944 | 1997-01-12 18:32:19 +0000 | [diff] [blame] | 61 | { |
Eric Pouech | e5efa0c | 2000-04-13 19:31:58 +0000 | [diff] [blame] | 62 | DEBUG_Printf(DBG_CHN_MESG, "%d : ", i+1); |
Alexandre Julliard | 01d6346 | 1997-01-20 19:43:45 +0000 | [diff] [blame] | 63 | DEBUG_DisplayExpr(displaypoints[i].exp); |
Eric Pouech | e5efa0c | 2000-04-13 19:31:58 +0000 | [diff] [blame] | 64 | DEBUG_Printf(DBG_CHN_MESG, "\n"); |
Alexandre Julliard | c6c0944 | 1997-01-12 18:32:19 +0000 | [diff] [blame] | 65 | } |
| 66 | } |
| 67 | |
| 68 | return TRUE; |
| 69 | } |
| 70 | |
| 71 | int |
Eric Pouech | d33bcb6 | 2000-03-15 19:57:20 +0000 | [diff] [blame] | 72 | DEBUG_DoDisplay(void) |
Alexandre Julliard | c6c0944 | 1997-01-12 18:32:19 +0000 | [diff] [blame] | 73 | { |
Eric Pouech | d33bcb6 | 2000-03-15 19:57:20 +0000 | [diff] [blame] | 74 | DBG_VALUE value; |
| 75 | int i; |
Alexandre Julliard | c6c0944 | 1997-01-12 18:32:19 +0000 | [diff] [blame] | 76 | |
| 77 | /* |
| 78 | * First find a slot where we can store this display. |
| 79 | */ |
| 80 | for(i=0; i < MAX_DISPLAY; i++ ) |
| 81 | { |
Alexandre Julliard | 01d6346 | 1997-01-20 19:43:45 +0000 | [diff] [blame] | 82 | if( displaypoints[i].exp != NULL ) |
Alexandre Julliard | c6c0944 | 1997-01-12 18:32:19 +0000 | [diff] [blame] | 83 | { |
Eric Pouech | d33bcb6 | 2000-03-15 19:57:20 +0000 | [diff] [blame] | 84 | value = DEBUG_EvalExpr(displaypoints[i].exp); |
| 85 | if( value.type == NULL ) |
Alexandre Julliard | c6c0944 | 1997-01-12 18:32:19 +0000 | [diff] [blame] | 86 | { |
Eric Pouech | e5efa0c | 2000-04-13 19:31:58 +0000 | [diff] [blame] | 87 | DEBUG_Printf(DBG_CHN_MESG, "Unable to evaluate expression "); |
Alexandre Julliard | 01d6346 | 1997-01-20 19:43:45 +0000 | [diff] [blame] | 88 | DEBUG_DisplayExpr(displaypoints[i].exp); |
Eric Pouech | e5efa0c | 2000-04-13 19:31:58 +0000 | [diff] [blame] | 89 | DEBUG_Printf(DBG_CHN_MESG, "\nDisabling...\n"); |
Alexandre Julliard | c6c0944 | 1997-01-12 18:32:19 +0000 | [diff] [blame] | 90 | DEBUG_DelDisplay(i); |
| 91 | } |
| 92 | else |
| 93 | { |
Eric Pouech | e5efa0c | 2000-04-13 19:31:58 +0000 | [diff] [blame] | 94 | DEBUG_Printf(DBG_CHN_MESG, "%d : ", i + 1); |
Alexandre Julliard | 01d6346 | 1997-01-20 19:43:45 +0000 | [diff] [blame] | 95 | DEBUG_DisplayExpr(displaypoints[i].exp); |
Eric Pouech | e5efa0c | 2000-04-13 19:31:58 +0000 | [diff] [blame] | 96 | DEBUG_Printf(DBG_CHN_MESG, " = "); |
Alexandre Julliard | 01d6346 | 1997-01-20 19:43:45 +0000 | [diff] [blame] | 97 | if( displaypoints[i].format == 'i' ) |
| 98 | { |
Eric Pouech | d33bcb6 | 2000-03-15 19:57:20 +0000 | [diff] [blame] | 99 | DEBUG_ExamineMemory( &value, |
| 100 | displaypoints[i].count, |
| 101 | displaypoints[i].format); |
Alexandre Julliard | 01d6346 | 1997-01-20 19:43:45 +0000 | [diff] [blame] | 102 | } |
| 103 | else |
| 104 | { |
Eric Pouech | d33bcb6 | 2000-03-15 19:57:20 +0000 | [diff] [blame] | 105 | DEBUG_Print( &value, |
Alexandre Julliard | 01d6346 | 1997-01-20 19:43:45 +0000 | [diff] [blame] | 106 | displaypoints[i].count, |
| 107 | displaypoints[i].format, 0); |
| 108 | } |
Alexandre Julliard | c6c0944 | 1997-01-12 18:32:19 +0000 | [diff] [blame] | 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 | { |
Eric Pouech | e5efa0c | 2000-04-13 19:31:58 +0000 | [diff] [blame] | 123 | DEBUG_Printf(DBG_CHN_MESG, "Invalid display number\n"); |
Alexandre Julliard | c6c0944 | 1997-01-12 18:32:19 +0000 | [diff] [blame] | 124 | return TRUE; |
| 125 | } |
| 126 | if( displaynum == -1 ) |
| 127 | { |
| 128 | for(i=0; i < MAX_DISPLAY; i++ ) |
| 129 | { |
Alexandre Julliard | 01d6346 | 1997-01-20 19:43:45 +0000 | [diff] [blame] | 130 | if( displaypoints[i].exp != NULL ) |
Alexandre Julliard | c6c0944 | 1997-01-12 18:32:19 +0000 | [diff] [blame] | 131 | { |
Alexandre Julliard | 01d6346 | 1997-01-20 19:43:45 +0000 | [diff] [blame] | 132 | DEBUG_FreeExpr(displaypoints[i].exp); |
| 133 | displaypoints[i].exp = NULL; |
Alexandre Julliard | c6c0944 | 1997-01-12 18:32:19 +0000 | [diff] [blame] | 134 | } |
| 135 | } |
| 136 | } |
Alexandre Julliard | 01d6346 | 1997-01-20 19:43:45 +0000 | [diff] [blame] | 137 | else if( displaypoints[displaynum - 1].exp != NULL ) |
Alexandre Julliard | c6c0944 | 1997-01-12 18:32:19 +0000 | [diff] [blame] | 138 | { |
Alexandre Julliard | 01d6346 | 1997-01-20 19:43:45 +0000 | [diff] [blame] | 139 | DEBUG_FreeExpr(displaypoints[displaynum - 1].exp); |
| 140 | displaypoints[displaynum - 1].exp = NULL; |
Alexandre Julliard | c6c0944 | 1997-01-12 18:32:19 +0000 | [diff] [blame] | 141 | } |
| 142 | return TRUE; |
| 143 | } |