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