2 * Debugger memory handling
4 * Copyright 1993 Eric Youngdale
5 * Copyright 1995 Alexandre Julliard
6 * Copyright 2000-2005 Eric Pouech
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.
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.
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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
28 #include "wine/debug.h"
30 WINE_DEFAULT_DEBUG_CHANNEL(winedbg
);
32 void* be_cpu_linearize(HANDLE hThread
, const ADDRESS64
* addr
)
34 assert(addr
->Mode
== AddrModeFlat
);
35 return (void*)(DWORD_PTR
)addr
->Offset
;
38 BOOL
be_cpu_build_addr(HANDLE hThread
, const dbg_ctx_t
*ctx
, ADDRESS64
* addr
,
39 unsigned seg
, DWORD64 offset
)
41 addr
->Mode
= AddrModeFlat
;
42 addr
->Segment
= 0; /* don't need segment */
43 addr
->Offset
= offset
;
47 void* memory_to_linear_addr(const ADDRESS64
* addr
)
49 return dbg_curr_process
->be_cpu
->linearize(dbg_curr_thread
->handle
, addr
);
52 BOOL
memory_get_current_pc(ADDRESS64
* addr
)
54 assert(dbg_curr_process
->be_cpu
->get_addr
);
55 return dbg_curr_process
->be_cpu
->get_addr(dbg_curr_thread
->handle
, &dbg_context
,
56 be_cpu_addr_pc
, addr
);
59 BOOL
memory_get_current_stack(ADDRESS64
* addr
)
61 assert(dbg_curr_process
->be_cpu
->get_addr
);
62 return dbg_curr_process
->be_cpu
->get_addr(dbg_curr_thread
->handle
, &dbg_context
,
63 be_cpu_addr_stack
, addr
);
66 static void memory_report_invalid_addr(const void* addr
)
70 address
.Mode
= AddrModeFlat
;
72 address
.Offset
= (ULONG_PTR
)addr
;
73 dbg_printf("*** Invalid address ");
74 print_address(&address
, FALSE
);
78 /***********************************************************************
81 * Read a memory value.
83 BOOL
memory_read_value(const struct dbg_lvalue
* lvalue
, DWORD size
, void* result
)
87 if (lvalue
->in_debuggee
)
89 void* linear
= memory_to_linear_addr(&lvalue
->addr
);
90 if (!(ret
= dbg_read_memory(linear
, result
, size
)))
91 memory_report_invalid_addr(linear
);
95 if (lvalue
->addr
.Offset
)
97 memcpy(result
, (void*)(DWORD_PTR
)lvalue
->addr
.Offset
, size
);
104 /***********************************************************************
107 * Store a value in memory.
109 BOOL
memory_write_value(const struct dbg_lvalue
* lvalue
, DWORD size
, void* value
)
114 if (!types_get_info(&lvalue
->type
, TI_GET_LENGTH
, &os
)) return FALSE
;
117 dbg_printf("Size mismatch in memory_write_value, got %I64u from type while expecting %lu\n",
122 /* FIXME: only works on little endian systems */
123 if (lvalue
->in_debuggee
)
125 void* linear
= memory_to_linear_addr(&lvalue
->addr
);
126 if (!(ret
= dbg_write_memory(linear
, value
, size
)))
127 memory_report_invalid_addr(linear
);
131 memcpy((void*)(DWORD_PTR
)lvalue
->addr
.Offset
, value
, size
);
136 /* transfer a block of memory
137 * the two lvalue:s are expected to be of same size
139 BOOL
memory_transfer_value(const struct dbg_lvalue
* to
, const struct dbg_lvalue
* from
)
141 DWORD64 size_to
, size_from
;
146 if (to
->bitlen
|| from
->bitlen
) return FALSE
;
147 if (!types_get_info(&to
->type
, TI_GET_LENGTH
, &size_to
) ||
148 !types_get_info(&from
->type
, TI_GET_LENGTH
, &size_from
) ||
149 size_from
!= size_to
) return FALSE
;
150 /* optimize debugger to debugger transfer */
151 if (!to
->in_debuggee
&& !from
->in_debuggee
)
153 memcpy(memory_to_linear_addr(&to
->addr
), memory_to_linear_addr(&from
->addr
), size_from
);
156 if (size_to
> sizeof(tmp
))
158 ptr
= malloc(size_from
);
159 if (!ptr
) return FALSE
;
161 ret
= memory_read_value(from
, size_from
, ptr
) &&
162 memory_write_value(to
, size_from
, ptr
);
163 if (size_to
> sizeof(tmp
)) free(ptr
);
167 /***********************************************************************
170 * Implementation of the 'x' command.
172 void memory_examine(const struct dbg_lvalue
*lvalue
, int count
, char format
)
179 types_extract_as_address(lvalue
, &addr
);
180 linear
= memory_to_linear_addr(&addr
);
182 if (format
!= 'i' && count
> 1)
184 print_address(&addr
, FALSE
);
191 if (count
== 1) count
= 256;
192 memory_get_string(dbg_curr_process
, linear
,
193 TRUE
, TRUE
, buffer
, min(count
, sizeof(buffer
)));
194 dbg_printf("%s\n", buffer
);
197 if (count
== 1) count
= 256;
198 memory_get_string(dbg_curr_process
, linear
,
199 TRUE
, FALSE
, buffer
, min(count
, sizeof(buffer
)));
200 dbg_printf("%s\n", buffer
);
203 while (count
-- && memory_disasm_one_insn(&addr
));
209 if (!dbg_read_memory(linear
, &guid
, sizeof(guid
)))
211 memory_report_invalid_addr(linear
);
214 dbg_printf("{%08lx-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x}\n",
215 guid
.Data1
, guid
.Data2
, guid
.Data3
,
216 guid
.Data4
[0], guid
.Data4
[1], guid
.Data4
[2], guid
.Data4
[3],
217 guid
.Data4
[4], guid
.Data4
[5], guid
.Data4
[6], guid
.Data4
[7]);
218 linear
= (char*)linear
+ sizeof(guid
);
219 addr
.Offset
+= sizeof(guid
);
222 print_address(&addr
, FALSE
);
228 #define DO_DUMP2(_t,_l,_f,_vv) { \
230 for (i = 0; i < count; i++) { \
231 if (!dbg_read_memory(linear, &_v, sizeof(_t))) \
232 { memory_report_invalid_addr(linear); break; } \
233 dbg_printf(_f, (_vv)); \
234 addr.Offset += sizeof(_t); \
235 linear = (char*)linear + sizeof(_t); \
236 if ((i % (_l)) == (_l) - 1 && i != count - 1) \
239 print_address(&addr, FALSE); \
245 #define DO_DUMP(_t,_l,_f) DO_DUMP2(_t,_l,_f,_v)
247 case 'x': DO_DUMP(int, 4, " %8.8x"); break;
248 case 'd': DO_DUMP(unsigned int, 4, " %4.4d"); break;
249 case 'w': DO_DUMP(unsigned short, 8, " %04x"); break;
251 if (sizeof(DWORD_PTR
) == 4)
253 DO_DUMP(DWORD_PTR
, 4, " %8.8Ix");
257 DO_DUMP(DWORD_PTR
, 2, " %16.16Ix");
260 case 'c': DO_DUMP2(char, 32, " %c", (_v
< 0x20) ? ' ' : _v
); break;
261 case 'b': DO_DUMP2(char, 16, " %02x", (_v
) & 0xff); break;
265 BOOL
memory_fetch_integer(const struct dbg_lvalue
* lvalue
, unsigned size
,
266 BOOL is_signed
, dbg_lgint_t
* ret
)
268 /* size must fit in ret and be a power of two */
269 if (size
> sizeof(*ret
) || (size
& (size
- 1))) return FALSE
;
273 struct dbg_lvalue alt_lvalue
= *lvalue
;
276 /* FIXME: this test isn't sufficient, depending on start of bitfield
277 * (ie a 64 bit field can spread across 9 bytes)
279 if (lvalue
->bitlen
> 8 * sizeof(dbg_lgint_t
)) return FALSE
;
280 alt_lvalue
.addr
.Offset
+= lvalue
->bitstart
>> 3;
282 * Bitfield operation. We have to extract the field.
284 if (!memory_read_value(&alt_lvalue
, sizeof(*ret
), ret
)) return FALSE
;
285 mask
= ~(dbg_lguint_t
)0 << lvalue
->bitlen
;
286 *ret
>>= lvalue
->bitstart
& 7;
290 * OK, now we have the correct part of the number.
291 * Check to see whether the basic type is signed or not, and if so,
292 * we need to sign extend the number.
294 if (types_get_info(&lvalue
->type
, TI_GET_BASETYPE
, &bt
) &&
295 (bt
== btInt
|| bt
== btLong
) && (*ret
& (1 << (lvalue
->bitlen
- 1))))
302 /* we are on little endian CPU */
303 memset(ret
, 0, sizeof(*ret
)); /* clear unread bytes */
304 if (!memory_read_value(lvalue
, size
, ret
)) return FALSE
;
306 /* propagate sign information */
307 if (is_signed
&& size
< 8 && (*ret
>> (size
* 8 - 1)) != 0)
309 dbg_lguint_t neg
= -1;
310 *ret
|= neg
<< (size
* 8);
316 BOOL
memory_store_integer(const struct dbg_lvalue
* lvalue
, dbg_lgint_t val
)
319 if (!types_get_info(&lvalue
->type
, TI_GET_LENGTH
, &size
)) return FALSE
;
322 struct dbg_lvalue alt_lvalue
= *lvalue
;
323 dbg_lguint_t mask
, dst
;
325 /* FIXME: this test isn't sufficient, depending on start of bitfield
326 * (ie a 64 bit field can spread across 9 bytes)
328 if (lvalue
->bitlen
> 8 * sizeof(dbg_lgint_t
)) return FALSE
;
329 /* mask is 1 where bitfield is present, 0 outside */
330 mask
= (~(dbg_lguint_t
)0 >> (sizeof(val
) * 8 - lvalue
->bitlen
)) << (lvalue
->bitstart
& 7);
331 alt_lvalue
.addr
.Offset
+= lvalue
->bitstart
>> 3;
332 val
<<= lvalue
->bitstart
& 7;
333 if (!memory_read_value(&alt_lvalue
, (unsigned)size
, &dst
)) return FALSE
;
334 val
= (dst
& ~mask
) | (val
& mask
);
335 return memory_write_value(&alt_lvalue
, (unsigned)size
, &val
);
337 /* this is simple if we're on a little endian CPU */
338 return memory_write_value(lvalue
, (unsigned)size
, &val
);
341 BOOL
memory_fetch_float(const struct dbg_lvalue
* lvalue
, double *ret
)
344 if (!types_get_info(&lvalue
->type
, TI_GET_LENGTH
, &size
)) return FALSE
;
345 /* FIXME: this assumes that debuggee and debugger use the same
346 * representation for reals
348 if (size
> sizeof(*ret
)) return FALSE
;
349 if (!memory_read_value(lvalue
, size
, ret
)) return FALSE
;
351 if (size
== sizeof(float)) *ret
= *(float*)ret
;
352 else if (size
!= sizeof(double)) return FALSE
;
357 BOOL
memory_store_float(const struct dbg_lvalue
* lvalue
, double *ret
)
360 if (!types_get_info(&lvalue
->type
, TI_GET_LENGTH
, &size
)) return FALSE
;
361 /* FIXME: this assumes that debuggee and debugger use the same
362 * representation for reals
364 if (size
> sizeof(*ret
)) return FALSE
;
365 if (size
== sizeof(float))
368 return memory_write_value(lvalue
, size
, &f
);
370 if (size
!= sizeof(double)) return FALSE
;
371 return memory_write_value(lvalue
, size
, ret
);
374 BOOL
memory_get_string(struct dbg_process
* pcs
, void* addr
, BOOL in_debuggee
,
375 BOOL unicode
, char* buffer
, int size
)
381 if (!addr
) return FALSE
;
386 if (!unicode
) ret
= pcs
->process_io
->read(pcs
->handle
, addr
, buffer
, size
, &sz
);
389 buffW
= HeapAlloc(GetProcessHeap(), 0, size
* sizeof(WCHAR
));
390 ret
= pcs
->process_io
->read(pcs
->handle
, addr
, buffW
, size
* sizeof(WCHAR
), &sz
);
391 WideCharToMultiByte(CP_ACP
, 0, buffW
, sz
/ sizeof(WCHAR
), buffer
, size
,
393 HeapFree(GetProcessHeap(), 0, buffW
);
395 if (size
) buffer
[size
-1] = 0;
400 lstrcpynA(buffer
, addr
, size
);
405 BOOL
memory_get_string_indirect(struct dbg_process
* pcs
, void* addr
, BOOL unicode
, WCHAR
* buffer
, int size
)
412 pcs
->process_io
->read(pcs
->handle
, addr
, &ad
, pcs
->be_cpu
->pointer_size
, &sz
) && sz
== pcs
->be_cpu
->pointer_size
&& ad
)
418 ret
= pcs
->process_io
->read(pcs
->handle
, ad
, buffer
, size
* sizeof(WCHAR
), &sz
) && sz
!= 0;
421 if ((buff
= HeapAlloc(GetProcessHeap(), 0, size
)))
423 ret
= pcs
->process_io
->read(pcs
->handle
, ad
, buff
, size
, &sz
) && sz
!= 0;
424 MultiByteToWideChar(CP_ACP
, 0, buff
, sz
, buffer
, size
);
425 HeapFree(GetProcessHeap(), 0, buff
);
429 if (size
) buffer
[size
-1] = 0;
436 * Convert an address offset to hex string. If mode == 32, treat offset as
437 * 32 bits (discard upper 32 bits), if mode == 64 use all 64 bits, if mode == 0
438 * treat as either 32 or 64 bits, depending on whether we're running as
441 char* memory_offset_to_string(char *str
, DWORD64 offset
, unsigned mode
)
443 if (mode
!= 32 && mode
!= 64)
453 sprintf(str
, "0x%08x", (unsigned int) offset
);
455 sprintf(str
, "%#016I64x", offset
);
460 static void dbg_print_sdecimal(dbg_lgint_t sv
)
462 dbg_printf("%I64d", sv
);
465 static void dbg_print_hex(DWORD size
, dbg_lgint_t sv
)
470 /* clear unneeded high bits, esp. sign extension */
471 dbg_printf("%#I64x", sv
& (~(dbg_lguint_t
)0 >> (8 * (sizeof(dbg_lgint_t
) - size
))));
474 static void print_typed_basic(const struct dbg_lvalue
* lvalue
)
480 DWORD tag
, size
, count
, bt
;
481 struct dbg_type type
= lvalue
->type
;
482 struct dbg_type sub_type
;
483 struct dbg_lvalue sub_lvalue
;
485 if (!types_get_real_type(&type
, &tag
)) return;
490 if (!types_get_info(&type
, TI_GET_LENGTH
, &size64
) ||
491 !types_get_info(&type
, TI_GET_BASETYPE
, &bt
))
493 WINE_ERR("Couldn't get information\n");
494 RaiseException(DEBUG_STATUS_INTERNAL_ERROR
, 0, 0, NULL
);
497 size
= (DWORD
)size64
;
502 if (!memory_fetch_integer(lvalue
, size
, TRUE
, &val_int
)) return;
503 dbg_print_hex(size
, val_int
);
507 if (!memory_fetch_integer(lvalue
, size
, FALSE
, &val_int
)) return;
508 dbg_print_hex(size
, val_int
);
511 if (!memory_fetch_float(lvalue
, &val_real
)) return;
512 dbg_printf("%f", val_real
);
515 if (!memory_fetch_integer(lvalue
, size
, TRUE
, &val_int
)) return;
516 if (size
== 1 && isprint((char)val_int
))
517 dbg_printf("'%c'", (char)val_int
);
519 dbg_print_hex(size
, val_int
);
522 if (!memory_fetch_integer(lvalue
, size
, TRUE
, &val_int
)) return;
523 if (size
== 2 && iswprint((WCHAR
)val_int
))
524 dbg_printf("L'%lc'", (WCHAR
)val_int
);
526 dbg_print_hex(size
, val_int
);
529 if (!memory_fetch_integer(lvalue
, size
, TRUE
, &val_int
)) return;
530 dbg_printf("%s", val_int
? "true" : "false");
533 WINE_FIXME("Unsupported basetype %lu\n", bt
);
537 case SymTagPointerType
:
538 if (!types_array_index(lvalue
, 0, &sub_lvalue
))
540 dbg_printf("Internal symbol error: unable to access memory location %p",
541 memory_to_linear_addr(&lvalue
->addr
));
544 val_ptr
= memory_to_linear_addr(&sub_lvalue
.addr
);
545 if (types_get_real_type(&sub_lvalue
.type
, &tag
) && tag
== SymTagBaseType
&&
546 types_get_info(&sub_lvalue
.type
, TI_GET_BASETYPE
, &bt
) &&
547 types_get_info(&sub_lvalue
.type
, TI_GET_LENGTH
, &size64
))
551 if (!val_ptr
) dbg_printf("0x0");
552 else if ((bt
== btChar
&& size64
== 1) || (bt
== btWChar
&& size64
== 2))
554 if (memory_get_string(dbg_curr_process
, val_ptr
, sub_lvalue
.in_debuggee
,
555 bt
== btWChar
, buffer
, sizeof(buffer
)))
556 dbg_printf("%s\"%s\"", bt
== btWChar
? "L" : "", buffer
);
558 dbg_printf("*** invalid address %p ***", val_ptr
);
562 dbg_printf("%p", val_ptr
);
564 case SymTagArrayType
:
566 if (!memory_read_value(lvalue
, sizeof(val_ptr
), &val_ptr
)) return;
567 dbg_printf("%p", val_ptr
);
573 if (!types_get_info(&type
, TI_GET_LENGTH
, &size64
) ||
574 !memory_fetch_integer(lvalue
, size64
, TRUE
, &val_int
)) return;
576 if (types_get_info(&type
, TI_GET_CHILDRENCOUNT
, &count
))
578 char buffer
[sizeof(TI_FINDCHILDREN_PARAMS
) + 256 * sizeof(DWORD
)];
579 TI_FINDCHILDREN_PARAMS
* fcp
= (TI_FINDCHILDREN_PARAMS
*)buffer
;
587 fcp
->Count
= min(count
, 256);
588 if (types_get_info(&type
, TI_FINDCHILDREN
, fcp
))
590 sub_type
.module
= type
.module
;
591 for (i
= 0; i
< min(fcp
->Count
, count
); i
++)
593 sub_type
.id
= fcp
->ChildId
[i
];
594 if (!types_get_info(&sub_type
, TI_GET_VALUE
, &variant
))
596 switch (V_VT(&variant
))
598 case VT_I1
: ok
= (val_int
== V_I1(&variant
)); break;
599 case VT_I2
: ok
= (val_int
== V_I2(&variant
)); break;
600 case VT_I4
: ok
= (val_int
== V_I4(&variant
)); break;
601 case VT_I8
: ok
= (val_int
== V_I8(&variant
)); break;
602 default: WINE_FIXME("Unsupported variant type (%u)\n", V_VT(&variant
));
604 if (ok
&& types_get_info(&sub_type
, TI_GET_SYMNAME
, &ptr
) && ptr
)
606 dbg_printf("%ls", ptr
);
607 HeapFree(GetProcessHeap(), 0, ptr
);
608 count
= 0; /* so that we'll get away from outer loop */
613 count
-= min(count
, 256);
617 if (!ok
) dbg_print_sdecimal(val_int
);
621 WINE_FIXME("Unsupported tag %lu\n", tag
);
626 /***********************************************************************
629 * Implementation of the 'print' command.
631 void print_basic(const struct dbg_lvalue
* lvalue
, char format
)
633 if (lvalue
->type
.id
== dbg_itype_none
)
635 dbg_printf("Unable to evaluate expression\n");
642 dbg_lgint_t res
= types_extract_as_lgint(lvalue
, &size
, NULL
);
647 dbg_print_hex(size
, res
);
651 dbg_print_sdecimal(res
);
655 dbg_printf("%d = '%c'", (char)(res
& 0xff), (char)(res
& 0xff));
659 dbg_printf("%d = '%lc'", (WCHAR
)(res
& 0xFFFF), (WCHAR
)(res
& 0xFFFF));
666 dbg_printf("Format specifier '%c' is meaningless in 'print' command\n", format
);
669 if (lvalue
->type
.id
== dbg_itype_segptr
)
671 dbg_print_sdecimal(types_extract_as_lgint(lvalue
, NULL
, NULL
));
673 else print_typed_basic(lvalue
);
676 void print_bare_address(const ADDRESS64
* addr
)
678 char hexbuf
[MAX_OFFSET_TO_STR_LEN
];
683 dbg_printf("%s", memory_offset_to_string(hexbuf
, addr
->Offset
, 0));
687 dbg_printf("0x%04x:0x%04x", addr
->Segment
, (unsigned) addr
->Offset
);
690 dbg_printf("0x%04x:%s", addr
->Segment
,
691 memory_offset_to_string(hexbuf
, addr
->Offset
, 32));
694 dbg_printf("Unknown mode %x", addr
->Mode
);
699 /***********************************************************************
702 * Print an 16- or 32-bit address, with the nearest symbol if any.
704 void print_address(const ADDRESS64
* addr
, BOOLEAN with_line
)
706 char buffer
[sizeof(SYMBOL_INFO
) + 256];
707 SYMBOL_INFO
* si
= (SYMBOL_INFO
*)buffer
;
708 DWORD_PTR lin
= (DWORD_PTR
)memory_to_linear_addr(addr
);
713 print_bare_address(addr
);
715 si
->SizeOfStruct
= sizeof(*si
);
716 si
->MaxNameLen
= 256;
718 if (SymFromAddr(dbg_curr_process
->handle
, lin
, &disp64
, si
) && disp64
< si
->Size
)
720 dbg_printf(" %s", si
->Name
);
721 if (disp64
) dbg_printf("+0x%I64x", disp64
);
725 im
.SizeOfStruct
= sizeof(im
);
726 if (!SymGetModuleInfo(dbg_curr_process
->handle
, lin
, &im
)) return;
727 dbg_printf(" %s", im
.ModuleName
);
728 if (lin
> im
.BaseOfImage
)
729 dbg_printf("+0x%Ix", lin
- im
.BaseOfImage
);
735 il
.SizeOfStruct
= sizeof(il
);
736 if (SymGetLineFromAddr64(dbg_curr_process
->handle
, lin
, &disp
, &il
))
737 dbg_printf(" [%s:%lu]", il
.FileName
, il
.LineNumber
);
738 if (im
.SizeOfStruct
== 0) /* don't display again module if address is in module+disp form */
740 im
.SizeOfStruct
= sizeof(im
);
741 if (SymGetModuleInfo(dbg_curr_process
->handle
, lin
, &im
))
742 dbg_printf(" in %s", im
.ModuleName
);
747 BOOL
memory_disasm_one_insn(ADDRESS64
* addr
)
751 print_address(addr
, TRUE
);
753 if (!dbg_read_memory(memory_to_linear_addr(addr
), &ch
, sizeof(ch
)))
755 dbg_printf("-- no code accessible --\n");
758 dbg_curr_process
->be_cpu
->disasm_one_insn(addr
, TRUE
);
763 void memory_disassemble(const struct dbg_lvalue
* xstart
,
764 const struct dbg_lvalue
* xend
, int instruction_count
)
766 static ADDRESS64 last
= {0,0,0};
767 dbg_lgint_t stop
= 0;
770 if (!xstart
&& !xend
)
772 if (!last
.Segment
&& !last
.Offset
) memory_get_current_pc(&last
);
777 types_extract_as_address(xstart
, &last
);
779 stop
= types_extract_as_integer(xend
);
781 for (i
= 0; (instruction_count
== 0 || i
< instruction_count
) &&
782 (stop
== 0 || last
.Offset
<= stop
); i
++)
783 memory_disasm_one_insn(&last
);
786 BOOL
memory_get_register(DWORD regno
, struct dbg_lvalue
* lvalue
, char* buffer
, int len
)
788 const struct dbg_internal_var
* div
;
790 /* negative register values are wine's dbghelp hacks
791 * see dlls/dbghelp/dbghelp_private.h for the details
796 if (buffer
) snprintf(buffer
, len
, "<internal error>");
799 if (buffer
) snprintf(buffer
, len
, "<couldn't compute location>");
802 if (buffer
) snprintf(buffer
, len
, "<is not available>");
805 if (buffer
) snprintf(buffer
, len
, "<couldn't read memory>");
808 if (buffer
) snprintf(buffer
, len
, "<has been optimized away by compiler>");
812 for (div
= dbg_curr_process
->be_cpu
->context_vars
; div
->name
; div
++)
814 if (div
->val
== regno
)
816 if (!stack_get_register_frame(div
, lvalue
))
818 if (buffer
) snprintf(buffer
, len
, "<register %s not accessible in this frame>", div
->name
);
822 if (buffer
) lstrcpynA(buffer
, div
->name
, len
);
826 if (buffer
) snprintf(buffer
, len
, "<unknown register %lu>", regno
);