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 ALL = 0xffffffff 23 }; 24 25 Context(Syscall *sc, char *data, MemoryReader &reader, 26 uint32 flags, bool decimal) 27 : fSyscall(sc), fData(data), fReader(reader), 28 fFlags(flags), fDecimal(decimal) {} 29 30 Parameter *GetSibling(int32 index) const { 31 return fSyscall->ParameterAt(index); 32 } 33 34 const void *GetValue(Parameter *param) const { 35 return fData + param->Offset(); 36 } 37 38 MemoryReader &Reader() { return fReader; } 39 bool GetContents(uint32 what) const { return fFlags & what; } 40 41 string FormatSigned(int64 value, int bytes = 8) const; 42 string FormatUnsigned(uint64 value) const; 43 string FormatFlags(uint64 value) const; 44 45 string FormatPointer(const void *address) const; 46 47 private: 48 Syscall *fSyscall; 49 char *fData; 50 MemoryReader &fReader; 51 uint32 fFlags; 52 bool fDecimal; 53 }; 54 55 #endif // STRACE_CONTEXT_H 56