!2422 [gstrace解析] 修复异常返回Success的问题
Merge pull request !2422 from Haolan/bugfix_gstrace_03
This commit is contained in:
@ -76,6 +76,7 @@ typedef enum trace_msg_code {
|
||||
TRACE_DISABLE_ERR,
|
||||
TRACE_OPEN_OUTPUT_FILE_ERR,
|
||||
TRACE_OPEN_INPUT_FILE_ERR,
|
||||
TRACE_OPEN_TMP_FILE_ERR,
|
||||
TRACE_WRITE_BUFFER_HEADER_ERR,
|
||||
TRACE_WRITE_CFG_HEADER_ERR,
|
||||
TRACE_WRITE_BUFFER_ERR,
|
||||
|
||||
@ -137,7 +137,7 @@ public:
|
||||
void outputStat(FILE* fp) override;
|
||||
void putIfUnexisted(pid_t pid, pid_t tid);
|
||||
void putFuncStatIfUnexisted(uint32_t func_id, func_stat* func_stat_map);
|
||||
void mergeFiles(const char* outPath, size_t len);
|
||||
trace_msg_code mergeFiles(const char* outPath, size_t len);
|
||||
void flushThreadFlows();
|
||||
|
||||
private:
|
||||
|
||||
@ -420,7 +420,7 @@ void DumpFileFlowVisitor::flushThreadFlows()
|
||||
}
|
||||
}
|
||||
|
||||
void DumpFileFlowVisitor::mergeFiles(const char* outPath, size_t len)
|
||||
trace_msg_code DumpFileFlowVisitor::mergeFiles(const char* outPath, size_t len)
|
||||
{
|
||||
FILE* fpOut = NULL;
|
||||
map_flow::iterator it;
|
||||
@ -430,8 +430,7 @@ void DumpFileFlowVisitor::mergeFiles(const char* outPath, size_t len)
|
||||
|
||||
fpOut = trace_fopen(outPath, "w+");
|
||||
if (fpOut == NULL) {
|
||||
printf("Cannot open file %s\n", outPath);
|
||||
goto exit;
|
||||
return TRACE_OPEN_OUTPUT_FILE_ERR;
|
||||
}
|
||||
|
||||
if (!this->m_analyze) {
|
||||
@ -446,8 +445,9 @@ void DumpFileFlowVisitor::mergeFiles(const char* outPath, size_t len)
|
||||
// Open the file with read mode
|
||||
FILE* fpIn = trace_fopen(tmpPath, "r");
|
||||
if (NULL == fpIn) {
|
||||
printf("Cannot open file %s\n", tmpPath);
|
||||
goto exit;
|
||||
(void)trace_fclose(fpOut);
|
||||
free(buffer);
|
||||
return TRACE_OPEN_TMP_FILE_ERR;
|
||||
}
|
||||
|
||||
while ((charRead = getline(&buffer, &bufSize, fpIn)) != -1) {
|
||||
@ -463,10 +463,9 @@ void DumpFileFlowVisitor::mergeFiles(const char* outPath, size_t len)
|
||||
} else {
|
||||
outputStat(fpOut);
|
||||
}
|
||||
|
||||
exit:
|
||||
free(buffer);
|
||||
(void)trace_fclose(fpOut);
|
||||
return TRACE_OK;
|
||||
}
|
||||
|
||||
// If the ThreadFlow for a given tid is not existed, then insert one to it.
|
||||
@ -1283,9 +1282,11 @@ static trace_msg_code formatDumpFileToFlow(const char* inputFile, size_t input_l
|
||||
DumpFileParser parser(inputFile, input_len);
|
||||
DumpFileFlowVisitor visitor(false);
|
||||
parser.acceptVisitor(&visitor);
|
||||
ret = parser.parse();
|
||||
if ((ret = parser.parse()) != TRACE_OK){
|
||||
return ret;
|
||||
}
|
||||
visitor.flushThreadFlows();
|
||||
visitor.mergeFiles(outputFile, output_len);
|
||||
ret = visitor.mergeFiles(outputFile, output_len);
|
||||
|
||||
return ret;
|
||||
}
|
||||
@ -1298,8 +1299,10 @@ static trace_msg_code anlyzeDumpFile(
|
||||
DumpFileParser parser(inputFile, input_len);
|
||||
DumpFileFlowVisitor visitor(true, stepSize, outputFile, output_len);
|
||||
parser.acceptVisitor(&visitor);
|
||||
ret = parser.parse();
|
||||
visitor.mergeFiles(outputFile, output_len);
|
||||
if ((ret = parser.parse()) != TRACE_OK){
|
||||
return ret;
|
||||
}
|
||||
ret = visitor.mergeFiles(outputFile, output_len);
|
||||
|
||||
return ret;
|
||||
}
|
||||
@ -1450,6 +1453,7 @@ trace_msg_t trace_message[] = {
|
||||
{TRACE_DISABLE_ERR, "Trace is disable."},
|
||||
{TRACE_OPEN_OUTPUT_FILE_ERR, "Failed to open trace output file."},
|
||||
{TRACE_OPEN_INPUT_FILE_ERR, "Failed to open trace input file."},
|
||||
{TRACE_OPEN_TMP_FILE_ERR, "Failed to open temp file."},
|
||||
{TRACE_WRITE_BUFFER_HEADER_ERR, "Failed to write trace buffer header."},
|
||||
{TRACE_WRITE_CFG_HEADER_ERR, "Failed to write trace config header."},
|
||||
{TRACE_WRITE_BUFFER_ERR, "Failed to write trace buffer."},
|
||||
|
||||
Reference in New Issue
Block a user