Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

adding binary class and name info for more a complete dataset

  • Loading branch information...
commit 1298faf7e525379917564dab4ef383c207a847a0 1 parent 2a4fdb6
Nick Gerner authored
Showing with 51 additions and 1 deletion.
  1. +17 −0 fhat.sh
  2. +34 −1 src/parse.cc
17 fhat.sh
View
@@ -6,9 +6,26 @@ if type -P pv &> /dev/null; then catprog=pv; fi
heapdump=$1
+if [ ! -e $heapdump ]
+then
+ echo "can't open $heapdump" 1>&2
+ exit 0
+fi
+
echo "parsing dump..."
$catprog $heapdump | ~/workspace/fhat/src/parse - classes instances references names
+echo;echo "sorting names..."
+~/workspace/fhat/src/sort names.binary names.sorted u64
+~/workspace/fhat/src/sortcolumns u64 names.binary u64 names.offset.binary names.sorted names.offset.sorted
+
+echo;echo "sorting classes..."
+~/workspace/fhat/src/sort classes.binary classes.sorted u64
+~/workspace/fhat/src/sortcolumns u64 classes.binary u64 classes.name.binary classes.sorted classes.name.sorted
+
+echo;echo "translating class names..."
+$catprog classes.name.sorted | ~/workspace/fhat/src/translate names.sorted - - 1 > classes.name.packed
+
echo;echo "sorting instances..."
~/workspace/fhat/src/sort instances.binary instances.sorted u64
echo;echo "sorting instance columns..."
35 src/parse.cc
View
@@ -420,12 +420,19 @@ FILE *instancesFileBinary = NULL;
FILE *instancesSizeFileBinary = NULL;
FILE *instancesClassFileBinary = NULL;
FILE *classesFile = NULL;
+FILE *classesFileBinary = NULL;
+FILE *classesNameFileBinary = NULL;
FILE *referencesFileBinary = NULL;
FILE *referencesFile = NULL;
FILE *namesFile = NULL;
+FILE *namesFileBinary = NULL;
+FILE *namesNameFileBinary = NULL;
+FILE *namesOffsetFileBinary = NULL;
+u64 namePos=0;
std::map<long int, std::string> nameFromId;
std::map<long int, std::string> classNameFromObjectId;
+std::map<long int, long int> classNameIdFromObjectId;
std::map<long int, StackFrame> stackFrameFromId;
std::map<long int, long int> superIdFromClassId;
std::map<long int, std::vector<FieldInfo> > fieldInfoFromClassId;
@@ -460,12 +467,25 @@ void addClass(unsigned long long id, unsigned long long superId, unsigned long l
if(classesFile) {
fprintf(classesFile, "CL\t%llu\t%llu\t%s\t%lu\n", id, superId, classNameFromObjectId[id].c_str(), size);
}
+ if(classesFileBinary) {
+ assert(classesNameFileBinary);
+ fwrite(&id, sizeof(u64), 1, classesFileBinary);
+ fwrite(&nameId, sizeof(u64), 1, classesNameFileBinary);
+ }
}
void addName(unsigned long long id, const char *name) {
if(namesFile) {
fprintf(namesFile, "NA\t%llu\t%s\n", id, escapeString(name));
}
+ if(namesFileBinary) {
+ assert(namesOffsetFileBinary);
+ assert(namesNameFileBinary);
+ fwrite(&id, sizeof(u64), 1, namesFileBinary);
+ fwrite(&namePos, sizeof(u64), 1, namesOffsetFileBinary);
+ fwrite(name, strlen(name)+1, 1, namesNameFileBinary);
+ namePos += strlen(name)+1;
+ }
}
size_t readValueForType(char type, FILE *input) {
@@ -624,7 +644,7 @@ int readClass(FILE *input) {
}
//output the class definition
- addClass(id, superId, 0, bytesRead);
+ addClass(id, superId, classNameIdFromObjectId[id], bytesRead);
//also output an instance definition so that all the sizes match up
addInstance(id, id, "CL", bytesRead);
for(size_t i=0; i<staticReferences.size();i++) {
@@ -882,6 +902,11 @@ int main(int argc, char **argv) {
}
else {
//classesFile = fopen(argv[2], "w");
+ char fileNameBinary[1024];
+ sprintf(fileNameBinary, "%s.binary", argv[2]);
+ classesFileBinary = fopen(fileNameBinary, "w");
+ sprintf(fileNameBinary, "%s.name.binary", argv[2]);
+ classesNameFileBinary = fopen(fileNameBinary, "w");
}
if(strcmp(argv[3], "-") == 0) {
//instancesFile = stdout;
@@ -910,6 +935,13 @@ int main(int argc, char **argv) {
}
else {
//namesFile = fopen(argv[5], "w");
+ char fileNameBinary[1024];
+ sprintf(fileNameBinary, "%s.binary", argv[5]);
+ namesFileBinary = fopen(fileNameBinary, "w");
+ sprintf(fileNameBinary, "%s.name.binary", argv[5]);
+ namesNameFileBinary = fopen(fileNameBinary, "w");
+ sprintf(fileNameBinary, "%s.offset.binary", argv[5]);
+ namesOffsetFileBinary = fopen(fileNameBinary, "w");
}
@@ -1015,6 +1047,7 @@ int main(int argc, char **argv) {
classNameId = readIdentifier(record+sizeof(int)*2+identifierSize);
assert(nameFromId.find(classNameId) != nameFromId.end());
classNameFromObjectId[classId] = nameFromId[classNameId];
+ classNameIdFromObjectId[classId] = classNameId;
break;
case HPROF_FRAME :
assert(recordLength == identifierSize * 4 + sizeof(int)*2);
Please sign in to comment.
Something went wrong with that request. Please try again.