watch: add numstmts

This commit is contained in:
lyyyuna 2021-08-08 16:16:10 +08:00
parent 0704a4ce67
commit 8b1f28225e
2 changed files with 13 additions and 10 deletions

View File

@ -80,8 +80,8 @@ func init() {
cov := fmt.Sprintf("%s:%d.%d,%d.%d %d %d", block.name,
block.pos[3*i+0], uint16(block.pos[3*i+2]),
block.pos[3*i+1], uint16(block.pos[3*i+2] >> 16),
1,
0)
block.stmts,
1)
err = ws.WriteMessage(websocket.TextMessage, []byte(cov))
if err != nil {
@ -128,13 +128,14 @@ func getRegisterInfo() (*processInfo, error) {
//
type blockInfo struct {
name string
pos []uint32
i int
name string
pos []uint32
i int
stmts int
}
// UploadCoverChangeEvent_{{.Random}} is non-blocking
func UploadCoverChangeEvent_{{.Random}}(name string, pos []uint32, i int) {
func UploadCoverChangeEvent_{{.Random}}(name string, pos []uint32, i int, stmts uint16) {
if watchEnabled == false {
return
@ -143,9 +144,10 @@ func UploadCoverChangeEvent_{{.Random}}(name string, pos []uint32, i int) {
// make sure send is non-blocking
select {
case watchChannel <- &blockInfo{
name: name,
pos: pos,
i: i,
name: name,
pos: pos,
i: i,
stmts: int(stmts),
}:
default:
}

View File

@ -419,7 +419,8 @@ func atomicCounterStmt(f *File, counter string) string {
// watchCounterStmt returns the expression: __count[23]++;UploadCoverChangeEvent(blockname, pos[:], index)
func watchCounterStmt(f *File, counter string) string {
return fmt.Sprintf("%s++; UploadCoverChangeEvent_%v(%s.BlockName, %s.Pos[:], %v)", counter, f.random, f.varVar, f.varVar, len(f.blocks))
index := len(f.blocks)
return fmt.Sprintf("%s++; UploadCoverChangeEvent_%v(%s.BlockName, %s.Pos[:], %v, %s.NumStmt[%v])", counter, f.random, f.varVar, f.varVar, index, f.varVar, index)
}
// QINIU