Skip to content
This repository was archived by the owner on Mar 25, 2025. It is now read-only.

Commit f4b56b7

Browse files
fix proc stat status parse error
1 parent b31f11d commit f4b56b7

1 file changed

Lines changed: 11 additions & 8 deletions

File tree

src/perfmonUtil/process.go

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,9 @@ func getStatusOnPid(client *adb.Device, pid string) (status *entity.ProcessStatu
109109
for scanner.Scan() {
110110
line := scanner.Text()
111111
fields := strings.Fields(line)
112+
if len(fields) < 2 {
113+
continue
114+
}
112115
var fieldName = strings.TrimRight(fields[0], ":")
113116
var value = strings.Join(fields[1:], " ")
114117
switch fieldName {
@@ -256,7 +259,7 @@ func newProcessStat(statStr string) (*entity.ProcessStat, error) {
256259
if err1 != nil {
257260
return nil, err1
258261
}
259-
processStat.Cmajflt = num
262+
processStat.Majflt = num
260263
case 13:
261264
num, err1 := strconv.Atoi(value)
262265
if err1 != nil {
@@ -280,43 +283,43 @@ func newProcessStat(statStr string) (*entity.ProcessStat, error) {
280283
if err1 != nil {
281284
return nil, err1
282285
}
283-
processStat.Priority = num
286+
processStat.Cstime = num
284287
case 17:
285288
num, err1 := strconv.Atoi(value)
286289
if err1 != nil {
287290
return nil, err1
288291
}
289-
processStat.Nice = num
292+
processStat.Priority = num
290293
case 18:
291294
num, err1 := strconv.Atoi(value)
292295
if err1 != nil {
293296
return nil, err1
294297
}
295-
processStat.Num_threads = num
298+
processStat.Nice = num
296299
case 19:
297300
num, err1 := strconv.Atoi(value)
298301
if err1 != nil {
299302
return nil, err1
300303
}
301-
processStat.Itrealvalue = num
304+
processStat.Num_threads = num
302305
case 20:
303306
num, err1 := strconv.Atoi(value)
304307
if err1 != nil {
305308
return nil, err1
306309
}
307-
processStat.Starttime = num
310+
processStat.Itrealvalue = num
308311
case 21:
309312
num, err1 := strconv.Atoi(value)
310313
if err1 != nil {
311314
return nil, err1
312315
}
313-
processStat.Vsize = num
316+
processStat.Starttime = num
314317
case 22:
315318
num, err1 := strconv.Atoi(value)
316319
if err1 != nil {
317320
return nil, err1
318321
}
319-
processStat.Rss = num
322+
processStat.Vsize = num
320323
case 23:
321324
num, err1 := strconv.Atoi(value)
322325
if err1 != nil {

0 commit comments

Comments
 (0)