We now also store the names of syscall parameters. This is used for strace. Well, not yet, but it would make a nice extension. :-)
git-svn-id: file:///srv/svn/repos/haiku/trunk/current@11338 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -43,6 +43,16 @@ struct Type {
|
|||||||
string type;
|
string type;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// NamedType
|
||||||
|
struct NamedType : Type {
|
||||||
|
NamedType(const char *type, const char *name)
|
||||||
|
: Type(type), name(name) {}
|
||||||
|
NamedType(const string &type, const string &name)
|
||||||
|
: Type(type), name(name) {}
|
||||||
|
|
||||||
|
string name;
|
||||||
|
};
|
||||||
|
|
||||||
// Function
|
// Function
|
||||||
class Function {
|
class Function {
|
||||||
public:
|
public:
|
||||||
@@ -58,7 +68,7 @@ public:
|
|||||||
return fName;
|
return fName;
|
||||||
}
|
}
|
||||||
|
|
||||||
void AddParameter(const Type &type)
|
void AddParameter(const NamedType &type)
|
||||||
{
|
{
|
||||||
fParameters.push_back(type);
|
fParameters.push_back(type);
|
||||||
}
|
}
|
||||||
@@ -68,7 +78,7 @@ public:
|
|||||||
return fParameters.size();
|
return fParameters.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
const Type &ParameterAt(int index) const
|
const NamedType &ParameterAt(int index) const
|
||||||
{
|
{
|
||||||
return fParameters[index];
|
return fParameters[index];
|
||||||
}
|
}
|
||||||
@@ -84,9 +94,9 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
string fName;
|
string fName;
|
||||||
vector<Type> fParameters;
|
vector<NamedType> fParameters;
|
||||||
Type fReturnType;
|
Type fReturnType;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Syscall
|
// Syscall
|
||||||
@@ -344,9 +354,10 @@ private:
|
|||||||
file << "static gensyscall_parameter_info " << paramInfoName
|
file << "static gensyscall_parameter_info " << paramInfoName
|
||||||
<< "[] = {" << endl;
|
<< "[] = {" << endl;
|
||||||
for (int k = 0; k < paramCount; k++) {
|
for (int k = 0; k < paramCount; k++) {
|
||||||
file << "\t{ \"" << syscall.ParameterAt(k).type << "\", 0, "
|
const NamedType ¶m = syscall.ParameterAt(k);
|
||||||
<< "sizeof(" << syscall.ParameterAt(k).type << "), 0 },"
|
file << "\t{ \"" << param.type << "\", \"" << param.name
|
||||||
<< endl;
|
<< "\", 0, " << "sizeof(" << syscall.ParameterAt(k).type
|
||||||
|
<< "), 0 }," << endl;
|
||||||
}
|
}
|
||||||
file << "};" << endl;
|
file << "};" << endl;
|
||||||
file << endl;
|
file << endl;
|
||||||
@@ -465,16 +476,19 @@ private:
|
|||||||
// that's OK
|
// that's OK
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
throw ParseException("Error while parsing function "
|
throw ParseException("Error while parsing function parameter.");
|
||||||
"parameter.");
|
|
||||||
}
|
}
|
||||||
type.pop_back(); // last component is the parameter name
|
|
||||||
|
// last component is the parameter name
|
||||||
|
string typeName = type.back();
|
||||||
|
type.pop_back();
|
||||||
|
|
||||||
string typeString(type[0]);
|
string typeString(type[0]);
|
||||||
for (int i = 1; i < (int)type.size(); i++) {
|
for (int i = 1; i < (int)type.size(); i++) {
|
||||||
typeString += " ";
|
typeString += " ";
|
||||||
typeString += type[i];
|
typeString += type[i];
|
||||||
}
|
}
|
||||||
syscall.AddParameter(typeString);
|
syscall.AddParameter(NamedType(typeString, typeName));
|
||||||
}
|
}
|
||||||
|
|
||||||
void _ParseFunctionPointerParameter(Tokenizer &tokenizer, Syscall &syscall,
|
void _ParseFunctionPointerParameter(Tokenizer &tokenizer, Syscall &syscall,
|
||||||
@@ -491,9 +505,13 @@ private:
|
|||||||
while (tokenizer.CheckNextToken("*"))
|
while (tokenizer.CheckNextToken("*"))
|
||||||
type.push_back("*");
|
type.push_back("*");
|
||||||
// now comes the parameter name, if specified -- skip it
|
// now comes the parameter name, if specified -- skip it
|
||||||
|
string typeName;
|
||||||
if (!tokenizer.CheckNextToken(")")) {
|
if (!tokenizer.CheckNextToken(")")) {
|
||||||
tokenizer.GetNextToken();
|
typeName = tokenizer.GetNextToken();
|
||||||
tokenizer.ExpectNextToken(")");
|
tokenizer.ExpectNextToken(")");
|
||||||
|
} else {
|
||||||
|
throw ParseException("Error while parsing function parameter. "
|
||||||
|
"No parameter name.");
|
||||||
}
|
}
|
||||||
type.push_back(")");
|
type.push_back(")");
|
||||||
// the function parameters
|
// the function parameters
|
||||||
@@ -508,7 +526,7 @@ private:
|
|||||||
typeString += " ";
|
typeString += " ";
|
||||||
typeString += type[i];
|
typeString += type[i];
|
||||||
}
|
}
|
||||||
syscall.AddParameter(typeString);
|
syscall.AddParameter(NamedType(typeString, typeName));
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
|
|
||||||
typedef struct gensyscall_parameter_info {
|
typedef struct gensyscall_parameter_info {
|
||||||
const char *type;
|
const char *type;
|
||||||
|
const char *name;
|
||||||
int offset;
|
int offset;
|
||||||
int size;
|
int size;
|
||||||
int actual_size;
|
int actual_size;
|
||||||
|
|||||||
Reference in New Issue
Block a user