1 /* 2 * Copyright 2007, Haiku Inc. All rights reserved. 3 * Distributed under the terms of the MIT License. 4 * 5 * Authors: 6 * Hugo Santos <hugosantos@gmail.com> 7 * Ingo Weinhold <bonefish@cs.tu-berlin.de> 8 */ 9 #ifndef STRACE_CONTEXT_H 10 #define STRACE_CONTEXT_H 11 12 #include "Syscall.h" 13 14 class Context { 15 public: 16 enum { 17 STRINGS = 1 << 0, 18 ENUMERATIONS = 1 << 1, 19 SIMPLE_STRUCTS = 1 << 2, 20 COMPLEX_STRUCTS = 1 << 3, 21 POINTER_VALUES = 1 << 4, 22 INPUT_VALUES = 1 << 5, 23 OUTPUT_VALUES = 1 << 6, 24 ALL = 0xffffff9f 25 }; 26 27 Context(Syscall *sc, char *data, MemoryReader &reader, 28 uint32 flags, bool decimal, uint64 returnValue = 0) 29 : fSyscall(sc), fData(data), fReader(reader), 30 fFlags(flags), fDecimal(decimal), fReturnValue(returnValue) {} 31 32 Parameter *GetSibling(int32 index) const { 33 return fSyscall->ParameterAt(index); 34 } 35 36 const void *GetValue(Parameter *param) const { 37 return fData + param->Offset(); 38 } 39 40 uint64 GetReturnValue() const { 41 return fReturnValue; 42 } 43 44 MemoryReader &Reader() { return fReader; } 45 bool GetContents(uint32 what) const { return fFlags & what; } 46 47 string FormatSigned(int64 value, int bytes = 8) const; 48 string FormatUnsigned(uint64 value) const; 49 string FormatFlags(uint64 value) const; 50 51 string FormatPointer(const void *address) const; 52 53 private: 54 Syscall *fSyscall; 55 char *fData; 56 MemoryReader &fReader; 57 uint32 fFlags; 58 bool fDecimal; 59 uint64 fReturnValue; 60 }; 61 62 #endif // STRACE_CONTEXT_H 63