(dump_name string)
| 31 | } |
| 32 | |
| 33 | func (this *EventParser) ParseDump(dump_name string) { |
| 34 | if dump_name == "" { |
| 35 | return |
| 36 | } |
| 37 | dir, _ := os.Getwd() |
| 38 | dump_path := dir + "/" + dump_name |
| 39 | // 提前打开文件 |
| 40 | f, err := os.Open(dump_path) |
| 41 | if err != nil { |
| 42 | panic("open dump file failed...") |
| 43 | } |
| 44 | |
| 45 | for { |
| 46 | var total_len uint32 |
| 47 | var event_index uint8 |
| 48 | var rec_type uint32 |
| 49 | var rec_len uint32 |
| 50 | if err = binary.Read(f, binary.LittleEndian, &total_len); err != nil { |
| 51 | // 理想情况下应该在这里退出 |
| 52 | if err == io.EOF { |
| 53 | break |
| 54 | } |
| 55 | panic(err) |
| 56 | } |
| 57 | if err = binary.Read(f, binary.LittleEndian, &event_index); err != nil { |
| 58 | panic(err) |
| 59 | } |
| 60 | if err = binary.Read(f, binary.LittleEndian, &rec_type); err != nil { |
| 61 | panic(err) |
| 62 | } |
| 63 | if err = binary.Read(f, binary.LittleEndian, &rec_len); err != nil { |
| 64 | panic(err) |
| 65 | } |
| 66 | // this.logger.Printf("len:%d event:%d type:%d rec_len:%d\n", total_len, event_index, rec_type, rec_len) |
| 67 | rec_raw := make([]byte, rec_len) |
| 68 | if err = binary.Read(f, binary.LittleEndian, &rec_raw); err != nil { |
| 69 | panic(err) |
| 70 | } |
| 71 | // this.logger.Printf("rec_raw:\n%s", util.HexDumpGreen(rec_raw)) |
| 72 | rec := perf.Record{} |
| 73 | rec.RawSample = rec_raw |
| 74 | rec.RecordType = rec_type |
| 75 | |
| 76 | rec.ExtraOptions = &perf.ExtraPerfOptions{ |
| 77 | UnwindStack: this.mconf.UnwindStack, |
| 78 | ShowRegs: this.mconf.ShowRegs, |
| 79 | BrkAddr: this.mconf.BrkAddr, |
| 80 | BrkLen: this.mconf.BrkLen, |
| 81 | BrkType: this.mconf.BrkType, |
| 82 | Sample_stack_user: this.mconf.StackSize, |
| 83 | } |
| 84 | |
| 85 | var te event.IEventStruct |
| 86 | switch event_index { |
| 87 | case common.COMMON_EVENT: |
| 88 | te = &event.CommonEvent{} |
| 89 | case common.BRK_EVENT: |
| 90 | te = &event.BrkEvent{} |
no test coverage detected