()
| 100 | } |
| 101 | |
| 102 | func (this *BrkEvent) ParseContextStack() { |
| 103 | this.Stackinfo = "" |
| 104 | if this.rec.ExtraOptions.UnwindStack { |
| 105 | // 读取完整的栈数据和寄存器数据 并解析为 UnwindBuf 结构体 |
| 106 | this.UnwindBuffer = &UnwindBuf{} |
| 107 | err := this.UnwindBuffer.ParseContext(this.buf) |
| 108 | if err != nil { |
| 109 | panic(fmt.Sprintf("UnwindStack ParseContext failed, err:%v", err)) |
| 110 | } |
| 111 | if this.mconf.ManualStack { |
| 112 | CacheMaps(this.Pid) |
| 113 | maps_helper.SetLogger(this.logger) |
| 114 | info, err := maps_helper.GetStack(this.GetPid(), this.UnwindBuffer) |
| 115 | if err != nil { |
| 116 | this.logger.Printf("Error when GetStack:%v", err) |
| 117 | } else { |
| 118 | this.Stackinfo = info |
| 119 | } |
| 120 | return |
| 121 | } |
| 122 | content, err := util.ReadMapsByPid(this.GetPid()) |
| 123 | if err != nil { |
| 124 | // 直接读取 maps 失败 那么从 mmap2 事件中获取 |
| 125 | // 根据测试结果 有这样的情况 -> 即 fork 产生的子进程 那么应该查找其父进程 mmap2 事件 |
| 126 | maps_helper.SetLogger(this.logger) |
| 127 | info, err := maps_helper.GetStack(this.GetPid(), this.UnwindBuffer) |
| 128 | if err != nil { |
| 129 | this.logger.Printf("Error when GetStack:%v", err) |
| 130 | } else { |
| 131 | this.Stackinfo = info |
| 132 | } |
| 133 | return |
| 134 | } |
| 135 | this.Stackinfo = ParseStack(content, this.GetOpt(), this.UnwindBuffer) |
| 136 | } else if this.rec.ExtraOptions.ShowRegs { |
| 137 | err := this.RegsBuffer.ParseContext(this.buf) |
| 138 | if err != nil { |
| 139 | panic(fmt.Sprintf("UnwindStack ParseContext failed, err:%v", err)) |
| 140 | } |
| 141 | } |
| 142 | return |
| 143 | } |
no test coverage detected