//===-- DNBRegisterInfo.cpp -------------------------------------*- C++ -*-===// // // The LLVM Compiler Infrastructure // // This file is distributed under the University of Illinois Open Source // License. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// // // Created by Greg Clayton on 8/3/07. // //===----------------------------------------------------------------------===// #include "DNBRegisterInfo.h" #include "DNBLog.h" #include DNBRegisterValueClass::DNBRegisterValueClass(const DNBRegisterInfo *regInfo) { Clear(); if (regInfo) info = *regInfo; } void DNBRegisterValueClass::Clear() { memset(&info, 0, sizeof(DNBRegisterInfo)); memset(&value, 0, sizeof(value)); } bool DNBRegisterValueClass::IsValid() const { return info.name != NULL && info.type != InvalidRegType && info.size > 0 && info.size <= sizeof(value); } #define PRINT_COMMA_SEPARATOR do { if (pos < end) { if (i > 0) { strncpy(pos, ", ", end - pos); pos += 2; } } } while (0) void DNBRegisterValueClass::Dump(const char *pre, const char *post) const { if (info.name != NULL) { char str[1024]; char *pos; char *end = str + sizeof(str); if (info.format == Hex) { switch (info.size) { case 0: snprintf(str, sizeof(str), "%s", "error: invalid register size of zero."); break; case 1: snprintf(str, sizeof(str), "0x%2.2x", value.uint8); break; case 2: snprintf(str, sizeof(str), "0x%4.4x", value.uint16); break; case 4: snprintf(str, sizeof(str), "0x%8.8x", value.uint32); break; case 8: snprintf(str, sizeof(str), "0x%16.16llx", value.uint64); break; case 16: snprintf(str, sizeof(str), "0x%16.16llx%16.16llx", value.v_uint64[0], value.v_uint64[1]); break; default: strncpy(str, "0x", 3); pos = str + 2; for (uint32_t i=0; i 0) { switch (info.format) { case VectorOfSInt8: snprintf(str, sizeof(str), "%s", "sint8 { "); pos = str + strlen(str); for (uint32_t i=0; i