1/*
2 * Copyright 2014-2016, Rene Gollent, rene@gollent.com.
3 * Copyright 2012, Ingo Weinhold, ingo_weinhold@gmx.de.
4 * Distributed under the terms of the MIT License.
5 */
6#ifndef UI_UTILS_H
7#define UI_UTILS_H
8
9#include <size_t.h>
10
11#include <image.h>
12
13#include "Types.h"
14
15
16class BString;
17class BVariant;
18class RangeList;
19class StackFrame;
20class Team;
21class TeamMemoryBlock;
22class ValueNodeChild;
23
24
25enum {
26	SIMD_RENDER_FORMAT_INT8 = 0,
27	SIMD_RENDER_FORMAT_INT16,
28	SIMD_RENDER_FORMAT_INT32,
29	SIMD_RENDER_FORMAT_INT64,
30	SIMD_RENDER_FORMAT_FLOAT,
31	SIMD_RENDER_FORMAT_DOUBLE
32};
33
34
35class UiUtils {
36public:
37	static	const char*			ThreadStateToString(int state,
38									int stoppedReason);
39
40	static	const char*			VariantToString(const BVariant& value,
41									char* buffer, size_t bufferSize);
42	static	const char*			FunctionNameForFrame(StackFrame* frame,
43									char* buffer, size_t bufferSize);
44	static	const char*			ImageTypeToString(image_type type,
45									char* buffer, size_t bufferSize);
46	static	const char*			AreaLockingFlagsToString(uint32 flags,
47									char* buffer, size_t bufferSize);
48	static	const BString&			AreaProtectionFlagsToString(uint32 protection,
49									BString& _output);
50
51	static	const char*			ReportNameForTeam(::Team* team,
52									char* buffer, size_t bufferSize);
53
54	static	const char*			CoreFileNameForTeam(::Team* team,
55									char* buffer, size_t bufferSize);
56
57	// this function assumes the value nodes have already been resolved
58	// (if possible).
59	static	void				PrintValueNodeGraph(BString& _output,
60									ValueNodeChild* child,
61									int32 indentLevel, int32 maxDepth);
62
63	static	void				DumpMemory(BString& _output,
64									int32 indentLevel,
65									TeamMemoryBlock* block,
66									target_addr_t address, int32 itemSize,
67									int32 displayWidth, int32 count);
68
69	static	status_t			ParseRangeExpression(
70									const BString& rangeString,
71									int32 lowerBound, int32 upperBound,
72									bool fixedRange,
73									RangeList& _output);
74
75	static	const char*			TypeCodeToString(type_code type);
76
77	static	const BString&		FormatSIMDValue(const BVariant& value,
78									uint32 bitSize, uint32 format,
79									BString& _output);
80
81	static	const char*			SignalNameToString(int32 signal,
82									BString& _output);
83	static	const char*			SignalDispositionToString(int disposition);
84};
85
86
87#endif	// UI_UTILS_H
88