Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initial implementation of system call events in ProcControlAPI.
- Loading branch information
1 parent
49d12d6
commit 7b8d777
Showing
16 changed files
with
3,565 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,136 @@ | ||
#include "dynutil/h/MachSyscall.h" | ||
#include "dynutil/h/dyntypes.h" | ||
|
||
using namespace std; | ||
using namespace Dyninst; | ||
|
||
bool Platform::operator==(const Platform & p) const | ||
{ | ||
return ((_arch == p._arch) && (_os == p._os)); | ||
} | ||
|
||
|
||
class SyscallInformation | ||
{ | ||
public: | ||
static SyscallInformation * getInstance(); | ||
|
||
MachSyscall::SyscallName findName(Platform, MachSyscall::SyscallIDPlatform); | ||
MachSyscall::SyscallIDPlatform findIDPlatform(Platform, MachSyscall::SyscallIDIndependent); | ||
|
||
private: | ||
SyscallInformation(); | ||
static SyscallInformation * theInstance; | ||
|
||
typedef dyn_hash_map<MachSyscall::SyscallIDIndependent, MachSyscall::SyscallIDPlatform> syscallNumbersMap; | ||
typedef dyn_hash_map<MachSyscall::SyscallIDPlatform, MachSyscall::SyscallName> syscallNamesMap; | ||
|
||
syscallNumbersMap Linux_Arch_x86_syscallNumbers; | ||
syscallNamesMap Linux_Arch_x86_syscallNames; | ||
|
||
syscallNumbersMap Linux_Arch_x86_64_syscallNumbers; | ||
syscallNamesMap Linux_Arch_x86_64_syscallNames; | ||
|
||
syscallNumbersMap Linux_Arch_ppc32_syscallNumbers; | ||
syscallNamesMap Linux_Arch_ppc32_syscallNames; | ||
|
||
syscallNumbersMap Linux_Arch_ppc64_syscallNumbers; | ||
syscallNamesMap Linux_Arch_ppc64_syscallNames; | ||
}; | ||
|
||
SyscallInformation * SyscallInformation::theInstance = NULL; | ||
|
||
SyscallInformation * SyscallInformation::getInstance() | ||
{ | ||
if(SyscallInformation::theInstance == NULL) { | ||
SyscallInformation::theInstance = new SyscallInformation; | ||
} | ||
return SyscallInformation::theInstance; | ||
} | ||
|
||
MachSyscall::SyscallName SyscallInformation::findName(Platform plat, MachSyscall::SyscallIDPlatform id) | ||
{ | ||
syscallNamesMap curMap; | ||
if (plat == Platform(Arch_x86, Linux)) { | ||
curMap = Linux_Arch_x86_syscallNames; | ||
} else if (plat == Platform(Arch_x86_64, Linux)) { | ||
curMap = Linux_Arch_x86_64_syscallNames; | ||
} else if (plat == Platform(Arch_ppc32, Linux)) { | ||
curMap = Linux_Arch_ppc32_syscallNames; | ||
} else if (plat == Platform(Arch_ppc64, Linux)) { | ||
curMap = Linux_Arch_ppc64_syscallNames; | ||
} else { | ||
// We don't know anything about this platform | ||
return "unknownSyscall"; | ||
} | ||
|
||
auto found = curMap.find(id); | ||
if (found == curMap.end()) { | ||
// Well, crap | ||
return "unknownSyscall"; | ||
} | ||
return found->second; | ||
} | ||
|
||
MachSyscall::SyscallIDPlatform SyscallInformation::findIDPlatform(Platform plat, MachSyscall::SyscallIDIndependent id) | ||
{ | ||
syscallNumbersMap curMap; | ||
if (plat == Platform(Arch_x86, Linux)) { | ||
curMap = Linux_Arch_x86_syscallNumbers; | ||
} else if (plat == Platform(Arch_x86_64, Linux)) { | ||
curMap = Linux_Arch_x86_64_syscallNumbers; | ||
} else if (plat == Platform(Arch_ppc32, Linux)) { | ||
curMap = Linux_Arch_ppc32_syscallNumbers; | ||
} else if (plat == Platform(Arch_ppc64, Linux)) { | ||
curMap = Linux_Arch_ppc64_syscallNumbers; | ||
} else { | ||
// We don't know anything about this platform | ||
return -1; | ||
} | ||
|
||
auto found = curMap.find(id); | ||
if (found == curMap.end()) { | ||
// Well, crap | ||
return -1; | ||
} | ||
return found->second; | ||
} | ||
|
||
/* This file is auto-generated from syscalls/generateSyscallInformation.py */ | ||
#include "SyscallInformation.C" | ||
|
||
/* Lookup the system call string name based on platform-specific ID */ | ||
MachSyscall::SyscallName MachSyscall::nameLookup(Platform plat, SyscallIDPlatform id) | ||
{ | ||
return SyscallInformation::getInstance()->findName(plat, id); | ||
} | ||
|
||
MachSyscall MachSyscall::makeFromPlatform(Platform plat, SyscallIDIndependent id) | ||
{ | ||
// 1. Convert SyscallIDIndependent to SyscallIDPlatform | ||
SyscallIDPlatform syscallNumber = SyscallInformation::getInstance()->findIDPlatform(plat, id); | ||
if (syscallNumber == (MachSyscall::SyscallIDPlatform)-1) { | ||
return MachSyscall(plat, -1, "unknownSyscall"); | ||
} | ||
|
||
// 2. MachSyscall::nameLookup(SyscallIDPlatform) | ||
SyscallName syscallName= nameLookup(plat, syscallNumber); | ||
|
||
return MachSyscall(plat, syscallNumber, syscallName); | ||
} | ||
|
||
unsigned long MachSyscall::num() const | ||
{ | ||
return _id; | ||
} | ||
|
||
MachSyscall::SyscallName MachSyscall::name() const | ||
{ | ||
return _name; | ||
} | ||
|
||
bool MachSyscall::operator==(const MachSyscall & m) const | ||
{ | ||
return ((_plat == m._plat) && (_id == m._id)); | ||
} | ||
|
Oops, something went wrong.