Lines Matching full:pkeys
512 void freeDataKeys(DataKeys* pKeys) {
513 if (pKeys == nullptr) return;
515 free(pKeys->fileData);
516 free(pKeys->threads);
517 free(pKeys->methods);
518 free(pKeys);
590 int64_t parseVersion(DataKeys* pKeys, int64_t offset, int32_t verbose) {
593 char* data = pKeys->fileData + offset;
594 char* dataEnd = pKeys->fileData + pKeys->fileLen;
628 return data - pKeys->fileData;
634 int64_t parseThreads(DataKeys* pKeys, int64_t offset) {
637 char* data = pKeys->fileData + offset;
638 char* dataEnd = pKeys->fileData + pKeys->fileLen;
653 pKeys->threads = new ThreadEntry[count];
654 if (pKeys->threads == nullptr) return -1;
667 pKeys->threads[i].threadId = atoi(data);
668 pKeys->threads[i].threadName = data + tab + 1;
673 pKeys->numThreads = count;
674 return data - pKeys->fileData;
680 int64_t parseMethods(DataKeys* pKeys, int64_t offset) {
683 char* data = pKeys->fileData + offset;
684 char* dataEnd = pKeys->fileData + pKeys->fileLen;
703 pKeys->methods = new MethodEntry[count];
704 if (pKeys->methods == nullptr) return -1;
705 initMethodEntry(&pKeys->methods[TOPLEVEL_INDEX], -2, "(toplevel)", nullptr, nullptr,
707 initMethodEntry(&pKeys->methods[UNKNOWN_INDEX], -1, "(unknown)", nullptr, nullptr,
757 initMethodEntry(&pKeys->methods[i], id, data + tab1 + 1,
761 initMethodEntry(&pKeys->methods[i], id, data + tab1 + 1,
765 initMethodEntry(&pKeys->methods[i], id, data + tab1 + 1, nullptr, nullptr, nullptr,
772 pKeys->numMethods = count;
773 return data - pKeys->fileData;
779 int64_t parseEnd(DataKeys* pKeys, int64_t offset) {
782 char* data = pKeys->fileData + offset;
783 char* dataEnd = pKeys->fileData + pKeys->fileLen;
789 return data - pKeys->fileData;
800 void sortThreadList(DataKeys* pKeys) {
801 qsort(pKeys->threads, pKeys->numThreads, sizeof(pKeys->threads[0]), compareThreads);
815 void sortMethodList(DataKeys* pKeys) {
816 qsort(pKeys->methods, pKeys->numMethods, sizeof(MethodEntry), compareMethods);
824 DataKeys* pKeys = new DataKeys();
825 memset(pKeys, 0, sizeof(DataKeys));
826 if (pKeys == nullptr) return nullptr;
834 freeDataKeys(pKeys);
837 pKeys->fileLen = ftell(fp);
838 if (pKeys->fileLen == 0) {
840 freeDataKeys(pKeys);
845 pKeys->fileData = new char[pKeys->fileLen];
846 if (pKeys->fileData == nullptr) {
847 fprintf(stderr, "ERROR: unable to alloc %" PRIu64 " bytes\n", pKeys->fileLen);
848 freeDataKeys(pKeys);
852 if (fread(pKeys->fileData, 1, pKeys->fileLen, fp) != (size_t)pKeys->fileLen) {
853 fprintf(stderr, "ERROR: unable to read %" PRIu64 " bytes from trace file\n", pKeys->fileLen);
854 freeDataKeys(pKeys);
859 offset = parseVersion(pKeys, offset, verbose);
860 offset = parseThreads(pKeys, offset);
861 offset = parseMethods(pKeys, offset);
862 offset = parseEnd(pKeys, offset);
864 freeDataKeys(pKeys);
869 pKeys->fileData = reinterpret_cast<char*>(realloc(pKeys->fileData, offset));
870 pKeys->fileLen = offset;
874 sortThreadList(pKeys);
875 sortMethodList(pKeys);
881 printf("Threads (%d):\n", pKeys->numThreads);
882 for (int32_t i = 0; i < pKeys->numThreads; i++) {
883 printf("%2d %s\n", pKeys->threads[i].threadId, pKeys->threads[i].threadName);
892 printf("Methods (%d):\n", pKeys->numMethods);
893 for (int32_t i = 0; i < pKeys->numMethods; i++) {
895 pKeys->methods[i].methodId, pKeys->methods[i].className,
896 pKeys->methods[i].methodName, pKeys->methods[i].signature);
901 return pKeys;
970 MethodEntry* lookupMethod(DataKeys* pKeys, int64_t methodId) {
972 int32_t hi = pKeys->numMethods - 1;
977 int64_t id = pKeys->methods[mid].methodId;
979 return &pKeys->methods[mid];
1048 DataKeys* pKeys = parseKeys(dataFp, 1);
1049 if (pKeys == nullptr) {
1057 freeDataKeys(pKeys);
1099 MethodEntry* method = lookupMethod(pKeys, methodId);
1126 freeDataKeys(pKeys);