Alexandre Julliard | 808cb04 | 1995-08-17 17:11:36 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Debugger memory handling |
| 3 | * |
| 4 | * Copyright 1993 Eric Youngdale |
| 5 | * Copyright 1995 Alexandre Julliard |
Eric Pouech | d33bcb6 | 2000-03-15 19:57:20 +0000 | [diff] [blame] | 6 | * Copyright 2000 Eric Pouech |
Alexandre Julliard | 0799c1a | 2002-03-09 23:29:33 +0000 | [diff] [blame] | 7 | * |
| 8 | * This library is free software; you can redistribute it and/or |
| 9 | * modify it under the terms of the GNU Lesser General Public |
| 10 | * License as published by the Free Software Foundation; either |
| 11 | * version 2.1 of the License, or (at your option) any later version. |
| 12 | * |
| 13 | * This library is distributed in the hope that it will be useful, |
| 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 16 | * Lesser General Public License for more details. |
| 17 | * |
| 18 | * You should have received a copy of the GNU Lesser General Public |
| 19 | * License along with this library; if not, write to the Free Software |
| 20 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
Alexandre Julliard | 808cb04 | 1995-08-17 17:11:36 +0000 | [diff] [blame] | 21 | */ |
| 22 | |
Marcus Meissner | b0d52b0 | 1999-02-28 19:59:00 +0000 | [diff] [blame] | 23 | #include "config.h" |
Alexandre Julliard | 5769d1d | 2002-04-26 19:05:15 +0000 | [diff] [blame] | 24 | #include "wine/port.h" |
| 25 | |
Alexandre Julliard | 808cb04 | 1995-08-17 17:11:36 +0000 | [diff] [blame] | 26 | #include <stdlib.h> |
Eric Pouech | 527eea9 | 2000-03-08 16:44:54 +0000 | [diff] [blame] | 27 | #include <string.h> |
Patrik Stridvall | 3b23362 | 2000-03-24 21:19:02 +0000 | [diff] [blame] | 28 | |
Alexandre Julliard | 808cb04 | 1995-08-17 17:11:36 +0000 | [diff] [blame] | 29 | #include "debugger.h" |
Eric Pouech | 527eea9 | 2000-03-08 16:44:54 +0000 | [diff] [blame] | 30 | #include "winbase.h" |
Alexandre Julliard | 808cb04 | 1995-08-17 17:11:36 +0000 | [diff] [blame] | 31 | |
Ulrich Weigand | b3ec4b9 | 1999-11-13 20:58:45 +0000 | [diff] [blame] | 32 | #ifdef __i386__ |
Alexandre Julliard | 954a413 | 2000-09-24 03:15:50 +0000 | [diff] [blame] | 33 | #define IS_VM86_MODE() (DEBUG_context.EFlags & V86_FLAG) |
Ulrich Weigand | 1cbf27a | 2000-06-04 01:33:21 +0000 | [diff] [blame] | 34 | #endif |
Alexandre Julliard | af0bae5 | 1995-10-03 17:06:08 +0000 | [diff] [blame] | 35 | |
Eric Pouech | 527eea9 | 2000-03-08 16:44:54 +0000 | [diff] [blame] | 36 | static void DEBUG_Die(const char* msg) |
Alexandre Julliard | af0bae5 | 1995-10-03 17:06:08 +0000 | [diff] [blame] | 37 | { |
Eric Pouech | e5efa0c | 2000-04-13 19:31:58 +0000 | [diff] [blame] | 38 | DEBUG_Printf(DBG_CHN_MESG, msg); |
Eric Pouech | 527eea9 | 2000-03-08 16:44:54 +0000 | [diff] [blame] | 39 | exit(1); |
Alexandre Julliard | af0bae5 | 1995-10-03 17:06:08 +0000 | [diff] [blame] | 40 | } |
| 41 | |
Eric Pouech | 527eea9 | 2000-03-08 16:44:54 +0000 | [diff] [blame] | 42 | void* DEBUG_XMalloc(size_t size) |
| 43 | { |
| 44 | void *res = malloc(size ? size : 1); |
| 45 | if (res == NULL) |
| 46 | DEBUG_Die("Memory exhausted.\n"); |
| 47 | memset(res, 0, size); |
| 48 | return res; |
| 49 | } |
| 50 | |
| 51 | void* DEBUG_XReAlloc(void *ptr, size_t size) |
| 52 | { |
| 53 | void* res = realloc(ptr, size); |
| 54 | if ((res == NULL) && size) |
| 55 | DEBUG_Die("Memory exhausted.\n"); |
| 56 | return res; |
| 57 | } |
| 58 | |
| 59 | char* DEBUG_XStrDup(const char *str) |
| 60 | { |
| 61 | char *res = strdup(str); |
| 62 | if (!res) |
| 63 | DEBUG_Die("Memory exhausted.\n"); |
| 64 | return res; |
| 65 | } |
| 66 | |
Alexandre Julliard | 954a413 | 2000-09-24 03:15:50 +0000 | [diff] [blame] | 67 | enum dbg_mode DEBUG_GetSelectorType( WORD sel ) |
| 68 | { |
| 69 | #ifdef __i386__ |
| 70 | LDT_ENTRY le; |
| 71 | |
| 72 | if (IS_VM86_MODE()) return MODE_VM86; |
| 73 | if (sel == 0) return MODE_32; |
| 74 | if (GetThreadSelectorEntry( DEBUG_CurrThread->handle, sel, &le)) |
| 75 | return le.HighWord.Bits.Default_Big ? MODE_32 : MODE_16; |
| 76 | /* selector doesn't exist */ |
| 77 | return MODE_INVALID; |
| 78 | #else |
| 79 | return MODE_32; |
| 80 | #endif |
| 81 | } |
Ulrich Weigand | 1cbf27a | 2000-06-04 01:33:21 +0000 | [diff] [blame] | 82 | #ifdef __i386__ |
Eric Pouech | 527eea9 | 2000-03-08 16:44:54 +0000 | [diff] [blame] | 83 | void DEBUG_FixAddress( DBG_ADDR *addr, DWORD def) |
| 84 | { |
| 85 | if (addr->seg == 0xffffffff) addr->seg = def; |
Alexandre Julliard | 954a413 | 2000-09-24 03:15:50 +0000 | [diff] [blame] | 86 | if (DEBUG_IsSelectorSystem(addr->seg)) addr->seg = 0; |
Eric Pouech | 527eea9 | 2000-03-08 16:44:54 +0000 | [diff] [blame] | 87 | } |
| 88 | |
| 89 | /* Determine if sel is a system selector (i.e. not managed by Wine) */ |
| 90 | BOOL DEBUG_IsSelectorSystem(WORD sel) |
| 91 | { |
Alexandre Julliard | 954a413 | 2000-09-24 03:15:50 +0000 | [diff] [blame] | 92 | if (IS_VM86_MODE()) return FALSE; /* no system selectors in vm86 mode */ |
| 93 | return !(sel & 4) || ((sel >> 3) < 17); |
Eric Pouech | 527eea9 | 2000-03-08 16:44:54 +0000 | [diff] [blame] | 94 | } |
| 95 | #endif /* __i386__ */ |
| 96 | |
Ulrich Weigand | 1cbf27a | 2000-06-04 01:33:21 +0000 | [diff] [blame] | 97 | DWORD DEBUG_ToLinear( const DBG_ADDR *addr ) |
| 98 | { |
| 99 | #ifdef __i386__ |
| 100 | LDT_ENTRY le; |
| 101 | |
Alexandre Julliard | 954a413 | 2000-09-24 03:15:50 +0000 | [diff] [blame] | 102 | if (IS_VM86_MODE()) return (DWORD)(LOWORD(addr->seg) << 4) + addr->off; |
| 103 | |
Ulrich Weigand | 1cbf27a | 2000-06-04 01:33:21 +0000 | [diff] [blame] | 104 | if (DEBUG_IsSelectorSystem(addr->seg)) |
| 105 | return addr->off; |
| 106 | |
| 107 | if (GetThreadSelectorEntry( DEBUG_CurrThread->handle, addr->seg, &le)) { |
| 108 | return (le.HighWord.Bits.BaseHi << 24) + (le.HighWord.Bits.BaseMid << 16) + le.BaseLow + addr->off; |
| 109 | } |
| 110 | return 0; |
| 111 | #else |
| 112 | return addr->off; |
| 113 | #endif |
| 114 | } |
| 115 | |
Eric Pouech | 527eea9 | 2000-03-08 16:44:54 +0000 | [diff] [blame] | 116 | void DEBUG_GetCurrentAddress( DBG_ADDR *addr ) |
| 117 | { |
Eric Pouech | 527eea9 | 2000-03-08 16:44:54 +0000 | [diff] [blame] | 118 | #ifdef __i386__ |
| 119 | addr->seg = DEBUG_context.SegCs; |
| 120 | |
Alexandre Julliard | 954a413 | 2000-09-24 03:15:50 +0000 | [diff] [blame] | 121 | if (DEBUG_IsSelectorSystem(addr->seg)) |
Eric Pouech | 527eea9 | 2000-03-08 16:44:54 +0000 | [diff] [blame] | 122 | addr->seg = 0; |
| 123 | addr->off = DEBUG_context.Eip; |
Eric Pouech | 911436b | 2000-06-18 19:30:24 +0000 | [diff] [blame] | 124 | #elif defined(__sparc__) |
| 125 | addr->seg = 0; |
| 126 | addr->off = DEBUG_context.pc; |
Eric Pouech | 527eea9 | 2000-03-08 16:44:54 +0000 | [diff] [blame] | 127 | #else |
Eric Pouech | 911436b | 2000-06-18 19:30:24 +0000 | [diff] [blame] | 128 | # error You must define GET_IP for this CPU |
Eric Pouech | 527eea9 | 2000-03-08 16:44:54 +0000 | [diff] [blame] | 129 | #endif |
| 130 | } |
| 131 | |
Eric Pouech | e5efa0c | 2000-04-13 19:31:58 +0000 | [diff] [blame] | 132 | void DEBUG_InvalAddr( const DBG_ADDR* addr ) |
| 133 | { |
| 134 | DEBUG_Printf(DBG_CHN_MESG,"*** Invalid address "); |
| 135 | DEBUG_PrintAddress(addr, DEBUG_CurrThread->dbg_mode, FALSE); |
| 136 | DEBUG_Printf(DBG_CHN_MESG,"\n"); |
| 137 | if (DBG_IVAR(ExtDbgOnInvalidAddress)) DEBUG_ExternalDebugger(); |
| 138 | } |
| 139 | |
Eric Pouech | 527eea9 | 2000-03-08 16:44:54 +0000 | [diff] [blame] | 140 | void DEBUG_InvalLinAddr( void* addr ) |
| 141 | { |
| 142 | DBG_ADDR address; |
| 143 | |
Eric Pouech | 527eea9 | 2000-03-08 16:44:54 +0000 | [diff] [blame] | 144 | address.seg = 0; |
| 145 | address.off = (unsigned long)addr; |
Eric Pouech | e5efa0c | 2000-04-13 19:31:58 +0000 | [diff] [blame] | 146 | DEBUG_InvalAddr( &address ); |
Eric Pouech | 527eea9 | 2000-03-08 16:44:54 +0000 | [diff] [blame] | 147 | } |
Alexandre Julliard | af0bae5 | 1995-10-03 17:06:08 +0000 | [diff] [blame] | 148 | |
| 149 | /*********************************************************************** |
Alexandre Julliard | 808cb04 | 1995-08-17 17:11:36 +0000 | [diff] [blame] | 150 | * DEBUG_ReadMemory |
| 151 | * |
| 152 | * Read a memory value. |
| 153 | */ |
Eric Pouech | 04c16b8 | 2000-04-30 12:21:15 +0000 | [diff] [blame] | 154 | /* FIXME: this function is now getting closer and closer to |
| 155 | * DEBUG_ExprGetValue. They should be merged... |
| 156 | */ |
| 157 | int DEBUG_ReadMemory( const DBG_VALUE* val ) |
Alexandre Julliard | 808cb04 | 1995-08-17 17:11:36 +0000 | [diff] [blame] | 158 | { |
Eric Pouech | 04c16b8 | 2000-04-30 12:21:15 +0000 | [diff] [blame] | 159 | int value = 0; /* to clear any unused byte */ |
| 160 | int os = DEBUG_GetObjectSize(val->type); |
| 161 | |
| 162 | assert(sizeof(value) >= os); |
| 163 | |
| 164 | /* FIXME: only works on little endian systems */ |
| 165 | |
| 166 | if (val->cookie == DV_TARGET) { |
| 167 | DBG_ADDR addr = val->addr; |
| 168 | void* lin; |
| 169 | |
Ulrich Weigand | 1cbf27a | 2000-06-04 01:33:21 +0000 | [diff] [blame] | 170 | #ifdef __i386__ |
Eric Pouech | 04c16b8 | 2000-04-30 12:21:15 +0000 | [diff] [blame] | 171 | DEBUG_FixAddress( &addr, DEBUG_context.SegDs ); |
Ulrich Weigand | 1cbf27a | 2000-06-04 01:33:21 +0000 | [diff] [blame] | 172 | #endif |
Eric Pouech | 04c16b8 | 2000-04-30 12:21:15 +0000 | [diff] [blame] | 173 | lin = (void*)DEBUG_ToLinear( &addr ); |
| 174 | |
| 175 | DEBUG_READ_MEM_VERBOSE(lin, &value, os); |
| 176 | } else { |
| 177 | if (val->addr.off) |
| 178 | memcpy(&value, (void*)val->addr.off, os); |
| 179 | } |
Eric Pouech | 527eea9 | 2000-03-08 16:44:54 +0000 | [diff] [blame] | 180 | return value; |
Alexandre Julliard | 808cb04 | 1995-08-17 17:11:36 +0000 | [diff] [blame] | 181 | } |
| 182 | |
| 183 | |
| 184 | /*********************************************************************** |
| 185 | * DEBUG_WriteMemory |
| 186 | * |
| 187 | * Store a value in memory. |
| 188 | */ |
Eric Pouech | 04c16b8 | 2000-04-30 12:21:15 +0000 | [diff] [blame] | 189 | void DEBUG_WriteMemory( const DBG_VALUE* val, int value ) |
Alexandre Julliard | 808cb04 | 1995-08-17 17:11:36 +0000 | [diff] [blame] | 190 | { |
Eric Pouech | 04c16b8 | 2000-04-30 12:21:15 +0000 | [diff] [blame] | 191 | int os = DEBUG_GetObjectSize(val->type); |
Alexandre Julliard | 808cb04 | 1995-08-17 17:11:36 +0000 | [diff] [blame] | 192 | |
Eric Pouech | 04c16b8 | 2000-04-30 12:21:15 +0000 | [diff] [blame] | 193 | assert(sizeof(value) >= os); |
| 194 | |
| 195 | /* FIXME: only works on little endian systems */ |
| 196 | |
| 197 | if (val->cookie == DV_TARGET) { |
| 198 | DBG_ADDR addr = val->addr; |
| 199 | void* lin; |
| 200 | |
Ulrich Weigand | 1cbf27a | 2000-06-04 01:33:21 +0000 | [diff] [blame] | 201 | #ifdef __i386__ |
Eric Pouech | 04c16b8 | 2000-04-30 12:21:15 +0000 | [diff] [blame] | 202 | DEBUG_FixAddress( &addr, DEBUG_context.SegDs ); |
Ulrich Weigand | 1cbf27a | 2000-06-04 01:33:21 +0000 | [diff] [blame] | 203 | #endif |
Eric Pouech | 04c16b8 | 2000-04-30 12:21:15 +0000 | [diff] [blame] | 204 | lin = (void*)DEBUG_ToLinear( &addr ); |
| 205 | DEBUG_WRITE_MEM_VERBOSE(lin, &value, os); |
| 206 | } else { |
| 207 | memcpy((void*)val->addr.off, &value, os); |
| 208 | } |
Alexandre Julliard | 808cb04 | 1995-08-17 17:11:36 +0000 | [diff] [blame] | 209 | } |
| 210 | |
Eric Pouech | 71189b5 | 2000-07-25 12:51:56 +0000 | [diff] [blame] | 211 | /*********************************************************************** |
| 212 | * DEBUG_GrabAddress |
| 213 | * |
| 214 | * Get the address from a value |
| 215 | */ |
| 216 | BOOL DEBUG_GrabAddress( DBG_VALUE* value, BOOL fromCode ) |
| 217 | { |
| 218 | assert(value->cookie == DV_TARGET || value->cookie == DV_HOST); |
| 219 | |
| 220 | #ifdef __i386__ |
| 221 | DEBUG_FixAddress( &value->addr, |
| 222 | (fromCode) ? DEBUG_context.SegCs : DEBUG_context.SegDs); |
| 223 | #endif |
| 224 | |
| 225 | /* |
| 226 | * Dereference pointer to get actual memory address we need to be |
| 227 | * reading. We will use the same segment as what we have already, |
| 228 | * and hope that this is a sensible thing to do. |
| 229 | */ |
| 230 | if (value->type != NULL) { |
Eric Pouech | 02ecb68 | 2001-12-21 20:29:58 +0000 | [diff] [blame] | 231 | if (value->type == DEBUG_GetBasicType(DT_BASIC_CONST_INT)) { |
Eric Pouech | 71189b5 | 2000-07-25 12:51:56 +0000 | [diff] [blame] | 232 | /* |
| 233 | * We know that we have the actual offset stored somewhere |
| 234 | * else in 32-bit space. Grab it, and we |
| 235 | * should be all set. |
| 236 | */ |
| 237 | unsigned int seg2 = value->addr.seg; |
| 238 | value->addr.seg = 0; |
| 239 | value->addr.off = DEBUG_GetExprValue(value, NULL); |
| 240 | value->addr.seg = seg2; |
| 241 | } else { |
| 242 | struct datatype * testtype; |
| 243 | |
| 244 | if (DEBUG_TypeDerefPointer(value, &testtype) == 0) |
| 245 | return FALSE; |
Eric Pouech | 02ecb68 | 2001-12-21 20:29:58 +0000 | [diff] [blame] | 246 | if (testtype != NULL || value->type == DEBUG_GetBasicType(DT_BASIC_CONST_INT)) |
Eric Pouech | 71189b5 | 2000-07-25 12:51:56 +0000 | [diff] [blame] | 247 | value->addr.off = DEBUG_GetExprValue(value, NULL); |
| 248 | } |
| 249 | } else if (!value->addr.seg && !value->addr.off) { |
| 250 | DEBUG_Printf(DBG_CHN_MESG,"Invalid expression\n"); |
| 251 | return FALSE; |
| 252 | } |
| 253 | return TRUE; |
| 254 | } |
Alexandre Julliard | 808cb04 | 1995-08-17 17:11:36 +0000 | [diff] [blame] | 255 | |
| 256 | /*********************************************************************** |
| 257 | * DEBUG_ExamineMemory |
| 258 | * |
| 259 | * Implementation of the 'x' command. |
| 260 | */ |
Eric Pouech | d33bcb6 | 2000-03-15 19:57:20 +0000 | [diff] [blame] | 261 | void DEBUG_ExamineMemory( const DBG_VALUE *_value, int count, char format ) |
Alexandre Julliard | 808cb04 | 1995-08-17 17:11:36 +0000 | [diff] [blame] | 262 | { |
Eric Pouech | d33bcb6 | 2000-03-15 19:57:20 +0000 | [diff] [blame] | 263 | DBG_VALUE value = *_value; |
Alexandre Julliard | c6c0944 | 1997-01-12 18:32:19 +0000 | [diff] [blame] | 264 | int i; |
| 265 | unsigned char * pnt; |
Alexandre Julliard | 808cb04 | 1995-08-17 17:11:36 +0000 | [diff] [blame] | 266 | |
Eric Pouech | 71189b5 | 2000-07-25 12:51:56 +0000 | [diff] [blame] | 267 | if (!DEBUG_GrabAddress(&value, (format == 'i'))) return; |
Alexandre Julliard | c6c0944 | 1997-01-12 18:32:19 +0000 | [diff] [blame] | 268 | |
Alexandre Julliard | 808cb04 | 1995-08-17 17:11:36 +0000 | [diff] [blame] | 269 | if (format != 'i' && count > 1) |
| 270 | { |
Eric Pouech | d33bcb6 | 2000-03-15 19:57:20 +0000 | [diff] [blame] | 271 | DEBUG_PrintAddress( &value.addr, DEBUG_CurrThread->dbg_mode, FALSE ); |
Eric Pouech | e5efa0c | 2000-04-13 19:31:58 +0000 | [diff] [blame] | 272 | DEBUG_Printf(DBG_CHN_MESG,": "); |
Alexandre Julliard | 808cb04 | 1995-08-17 17:11:36 +0000 | [diff] [blame] | 273 | } |
| 274 | |
Eric Pouech | d33bcb6 | 2000-03-15 19:57:20 +0000 | [diff] [blame] | 275 | pnt = (void*)DEBUG_ToLinear( &value.addr ); |
Alexandre Julliard | 808cb04 | 1995-08-17 17:11:36 +0000 | [diff] [blame] | 276 | |
| 277 | switch(format) |
| 278 | { |
Alexandre Julliard | 8da12c4 | 1999-01-17 16:55:11 +0000 | [diff] [blame] | 279 | case 'u': { |
Eric Pouech | 527eea9 | 2000-03-08 16:44:54 +0000 | [diff] [blame] | 280 | WCHAR wch; |
Alexandre Julliard | 8da12c4 | 1999-01-17 16:55:11 +0000 | [diff] [blame] | 281 | if (count == 1) count = 256; |
| 282 | while (count--) |
| 283 | { |
Eric Pouech | 4a07ed8 | 2000-05-09 22:32:01 +0000 | [diff] [blame] | 284 | if (!DEBUG_READ_MEM_VERBOSE(pnt, &wch, sizeof(wch)) || !wch) |
Eric Pouech | 527eea9 | 2000-03-08 16:44:54 +0000 | [diff] [blame] | 285 | break; |
| 286 | pnt += sizeof(wch); |
Eric Pouech | 04c16b8 | 2000-04-30 12:21:15 +0000 | [diff] [blame] | 287 | DEBUG_Printf(DBG_CHN_MESG, "%c", (char)wch); |
Alexandre Julliard | 8da12c4 | 1999-01-17 16:55:11 +0000 | [diff] [blame] | 288 | } |
Eric Pouech | e5efa0c | 2000-04-13 19:31:58 +0000 | [diff] [blame] | 289 | DEBUG_Printf(DBG_CHN_MESG,"\n"); |
Alexandre Julliard | 8da12c4 | 1999-01-17 16:55:11 +0000 | [diff] [blame] | 290 | return; |
| 291 | } |
Eric Pouech | 527eea9 | 2000-03-08 16:44:54 +0000 | [diff] [blame] | 292 | case 's': { |
| 293 | char ch; |
| 294 | |
Alexandre Julliard | 808cb04 | 1995-08-17 17:11:36 +0000 | [diff] [blame] | 295 | if (count == 1) count = 256; |
Alexandre Julliard | af0bae5 | 1995-10-03 17:06:08 +0000 | [diff] [blame] | 296 | while (count--) |
| 297 | { |
Eric Pouech | 4a07ed8 | 2000-05-09 22:32:01 +0000 | [diff] [blame] | 298 | if (!DEBUG_READ_MEM_VERBOSE(pnt, &ch, sizeof(ch)) || !ch) |
Eric Pouech | 527eea9 | 2000-03-08 16:44:54 +0000 | [diff] [blame] | 299 | break; |
| 300 | pnt++; |
Eric Pouech | 04c16b8 | 2000-04-30 12:21:15 +0000 | [diff] [blame] | 301 | DEBUG_Output(DBG_CHN_MESG, &ch, 1); |
Alexandre Julliard | af0bae5 | 1995-10-03 17:06:08 +0000 | [diff] [blame] | 302 | } |
Eric Pouech | e5efa0c | 2000-04-13 19:31:58 +0000 | [diff] [blame] | 303 | DEBUG_Printf(DBG_CHN_MESG,"\n"); |
Alexandre Julliard | 808cb04 | 1995-08-17 17:11:36 +0000 | [diff] [blame] | 304 | return; |
Eric Pouech | 527eea9 | 2000-03-08 16:44:54 +0000 | [diff] [blame] | 305 | } |
Alexandre Julliard | 808cb04 | 1995-08-17 17:11:36 +0000 | [diff] [blame] | 306 | case 'i': |
Eric Pouech | 71189b5 | 2000-07-25 12:51:56 +0000 | [diff] [blame] | 307 | while (count-- && DEBUG_DisassembleInstruction( &value.addr )); |
Alexandre Julliard | 808cb04 | 1995-08-17 17:11:36 +0000 | [diff] [blame] | 308 | return; |
Eric Pouech | 527eea9 | 2000-03-08 16:44:54 +0000 | [diff] [blame] | 309 | #define DO_DUMP2(_t,_l,_f,_vv) { \ |
| 310 | _t _v; \ |
| 311 | for(i=0; i<count; i++) { \ |
| 312 | if (!DEBUG_READ_MEM_VERBOSE(pnt, &_v, sizeof(_t))) break; \ |
Eric Pouech | e5efa0c | 2000-04-13 19:31:58 +0000 | [diff] [blame] | 313 | DEBUG_Printf(DBG_CHN_MESG,_f,(_vv)); \ |
Eric Pouech | d33bcb6 | 2000-03-15 19:57:20 +0000 | [diff] [blame] | 314 | pnt += sizeof(_t); value.addr.off += sizeof(_t); \ |
Eric Pouech | 527eea9 | 2000-03-08 16:44:54 +0000 | [diff] [blame] | 315 | if ((i % (_l)) == (_l)-1) { \ |
Eric Pouech | e5efa0c | 2000-04-13 19:31:58 +0000 | [diff] [blame] | 316 | DEBUG_Printf(DBG_CHN_MESG,"\n"); \ |
Eric Pouech | d33bcb6 | 2000-03-15 19:57:20 +0000 | [diff] [blame] | 317 | DEBUG_PrintAddress( &value.addr, DEBUG_CurrThread->dbg_mode, FALSE );\ |
Eric Pouech | e5efa0c | 2000-04-13 19:31:58 +0000 | [diff] [blame] | 318 | DEBUG_Printf(DBG_CHN_MESG,": ");\ |
Eric Pouech | 527eea9 | 2000-03-08 16:44:54 +0000 | [diff] [blame] | 319 | } \ |
| 320 | } \ |
Eric Pouech | e5efa0c | 2000-04-13 19:31:58 +0000 | [diff] [blame] | 321 | DEBUG_Printf(DBG_CHN_MESG,"\n"); \ |
Eric Pouech | 527eea9 | 2000-03-08 16:44:54 +0000 | [diff] [blame] | 322 | } \ |
| 323 | return |
| 324 | #define DO_DUMP(_t,_l,_f) DO_DUMP2(_t,_l,_f,_v) |
| 325 | |
| 326 | case 'x': DO_DUMP(int, 4, " %8.8x"); |
| 327 | case 'd': DO_DUMP(unsigned int, 4, " %10d"); |
| 328 | case 'w': DO_DUMP(unsigned short, 8, " %04x"); |
| 329 | case 'c': DO_DUMP2(char, 32, " %c", (_v < 0x20) ? ' ' : _v); |
| 330 | case 'b': DO_DUMP2(char, 16, " %02x", (_v) & 0xff); |
Alexandre Julliard | 808cb04 | 1995-08-17 17:11:36 +0000 | [diff] [blame] | 331 | } |
| 332 | } |