2 * Debugger memory handling
4 * Copyright 1993 Eric Youngdale
5 * Copyright 1995 Alexandre Julliard
13 /***********************************************************************
16 * Read a memory value.
18 int DEBUG_ReadMemory( const DBG_ADDR *address )
20 DBG_ADDR addr = *address;
22 DBG_FIX_ADDR_SEG( &addr, DS_reg(DEBUG_context) );
23 return *(int *)DBG_ADDR_TO_LIN( &addr );
27 /***********************************************************************
30 * Store a value in memory.
32 void DEBUG_WriteMemory( const DBG_ADDR *address, int value )
34 DBG_ADDR addr = *address;
36 DBG_FIX_ADDR_SEG( &addr, DS_reg(DEBUG_context) );
37 *(int *)DBG_ADDR_TO_LIN( &addr ) = value;
41 /***********************************************************************
44 * Implementation of the 'x' command.
46 void DEBUG_ExamineMemory( const DBG_ADDR *address, int count, char format )
48 DBG_ADDR addr = *address;
51 unsigned short int * wdump;
54 DBG_FIX_ADDR_SEG( &addr, (format == 'i') ?
55 CS_reg(DEBUG_context) : DS_reg(DEBUG_context) );
57 if (format != 'i' && count > 1)
59 DEBUG_PrintAddress( &addr, dbg_mode );
63 pnt = DBG_ADDR_TO_LIN( &addr );
68 if (count == 1) count = 256;
69 while(*pnt && count--) fputc( *pnt++, stderr );
76 DEBUG_PrintAddress( &addr, dbg_mode );
78 DEBUG_Disasm( &addr );
83 dump = (unsigned int *)pnt;
84 for(i=0; i<count; i++)
86 fprintf(stderr," %8.8x", *dump++);
90 DEBUG_PrintAddress( &addr, dbg_mode );
98 dump = (unsigned int *)pnt;
99 for(i=0; i<count; i++)
101 fprintf(stderr," %d", *dump++);
104 fprintf(stderr,"\n");
105 DEBUG_PrintAddress( &addr, dbg_mode );
106 fprintf(stderr,": ");
109 fprintf(stderr,"\n");
113 wdump = (unsigned short *)pnt;
114 for(i=0; i<count; i++)
116 fprintf(stderr," %04x", *wdump++);
119 fprintf(stderr,"\n");
120 DEBUG_PrintAddress( &addr, dbg_mode );
121 fprintf(stderr,": ");
124 fprintf(stderr,"\n");
128 for(i=0; i<count; i++)
134 fprintf(stderr," %c", *pnt++);
136 if ((i % 32) == 31) {
137 fprintf(stderr,"\n");
138 DEBUG_PrintAddress( &addr, dbg_mode );
139 fprintf(stderr,": ");
142 fprintf(stderr,"\n");
146 for(i=0; i<count; i++)
148 fprintf(stderr," %02x", (*pnt++) & 0xff);
150 if ((i % 16) == 15) {
151 fprintf(stderr,"\n");
152 DEBUG_PrintAddress( &addr, dbg_mode );
153 fprintf(stderr,": ");
156 fprintf(stderr,"\n");