1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
|
#include "stdafx.h"
#include "StackInfo.h"
#include "Utils/StackInfoSet.h"
#include "Gc/DwarfTable.h"
#include "Code/Binary.h"
#include "LookupHook.h"
namespace code {
namespace eh {
/**
* Function lookup using the Dwarf table.
*/
class DwarfInfo : public StackInfo {
public:
virtual bool translate(void *ip, void *&fnBase, int &offset) const {
FDE *fde = dwarfTable().find(ip);
if (!fde)
return false;
byte *start = (byte *)fde->codeStart();
if (fde->codeSize() != runtime::codeSize(start)) {
// Something is strange...
WARNING(L"This does not seem like code we know...");
return false;
}
fnBase = start;
offset = int((byte *)ip - start);
return true;
}
virtual void format(GenericOutput &to, void *fnBase, int offset) const {
Binary *owner = codeBinary(fnBase);
Str *name = owner->ownerName();
if (name) {
to.put(name->c_str());
} else {
to.put(S("<unnamed Storm function>"));
}
}
};
void activatePosixInfo() {
#ifdef POSIX
initHook();
#endif
static RegisterInfo<DwarfInfo> info;
}
}
}
|