// read_string static string read_string(Context &context, void *data) { if (data == NULL || !context.GetContents(Context::STRINGS)) return context.FormatPointer(data); char buffer[256]; int32 bytesRead; status_t error = context.Reader().Read(data, buffer, sizeof(buffer), bytesRead); if (error == B_OK) { // return string("\"") + string(buffer, bytesRead) + "\""; //string result("\""); //result += string(buffer, bytesRead); //result += "\""; //return result; // TODO: Unless I'm missing something obvious, our STL string class is broken. // The appended "\"" doesn't appear in either of the above cases. int32 len = strnlen(buffer, sizeof(buffer)); char largeBuffer[259]; largeBuffer[0] = '"'; memcpy(largeBuffer + 1, buffer, len); largeBuffer[len + 1] = '"'; largeBuffer[len + 2] = '\0'; return largeBuffer; } return context.FormatPointer(data) + " (" + strerror(error) + ")"; }
string TypeHandlerImpl<fd_set *>::GetParameterValue(Context &context, Parameter *, const void *address) { void *data = *(void **)address; if (data != NULL && context.GetContents(Context::SIMPLE_STRUCTS)) return read_fdset(context, data); return context.FormatPointer(data); }
static string format_unsigned_integer_pointer(Context &context, void *address) { Type data; if (obtain_pointer_data(context, &data, address, Context::POINTER_VALUES)) return "[" + context.FormatUnsigned(data) + "]"; return context.FormatPointer(address); }
static string format_pointer_value(Context &context, void *address) { Type data; if (obtain_pointer_data(context, &data, address, Context::COMPLEX_STRUCTS)) return "{" + format_pointer(context, &data) + "}"; return context.FormatPointer(address); }
static string read_fdset(Context &context, void *data) { // default FD_SETSIZE is 1024 unsigned long tmp[1024 / (sizeof(unsigned long) * 8)]; int32 bytesRead; status_t err = context.Reader().Read(data, &tmp, sizeof(tmp), bytesRead); if (err != B_OK) return context.FormatPointer(data); /* implicitly align to unsigned long lower boundary */ int count = bytesRead / sizeof(unsigned long); int added = 0; string r; r.reserve(16); r = "["; for (int i = 0; i < count && added < 8; i++) { for (int j = 0; j < (int)(sizeof(unsigned long) * 8) && added < 8; j++) { if (tmp[i] & (1 << j)) { if (added > 0) r += " "; unsigned int fd = i * sizeof(unsigned long) * 8 + j; r += format_number(fd); added++; } } } if (added >= 8) r += " ..."; r += "]"; return r; }
string TypeHandlerImpl<const void*>::GetReturnValue(Context &context, uint64 value) { return context.FormatPointer((void *)value); }
string TypeHandlerImpl<const void*>::GetParameterValue(Context &context, Parameter *, const void *address) { return context.FormatPointer(*(void **)address); }