Skip to content

Commit

Permalink
fix(am-dbg): fix tail mode with filters (#85)
Browse files Browse the repository at this point in the history
  • Loading branch information
pancsta committed Jul 12, 2024
1 parent 1ae6374 commit b909432
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 9 deletions.
10 changes: 6 additions & 4 deletions tools/debugger/debugger.go
Original file line number Diff line number Diff line change
Expand Up @@ -968,7 +968,7 @@ func (d *Debugger) filterClientTxs() {

d.C.msgTxsFiltered = nil
for i := range d.C.MsgTxs {
if d.filterTx(i, auto, empty, canceled) {
if d.filterTx(d.C, i, auto, empty, canceled) {
d.C.msgTxsFiltered = append(d.C.msgTxsFiltered, i)
}
}
Expand All @@ -980,8 +980,10 @@ func (d *Debugger) isFiltered() bool {
}

// filterTx returns true when a TX passed the passed filters.
func (d *Debugger) filterTx(idx int, auto, empty, canceled bool) bool {
tx := d.C.MsgTxs[idx]
func (d *Debugger) filterTx(
c *Client, idx int, auto, empty, canceled bool,
) bool {
tx := c.MsgTxs[idx]

if auto && tx.IsAuto {
return false
Expand All @@ -991,7 +993,7 @@ func (d *Debugger) filterTx(idx int, auto, empty, canceled bool) bool {
}

// empty
parsed := d.C.msgTxsParsed[idx]
parsed := c.msgTxsParsed[idx]
txEmpty := true
if empty && len(parsed.StatesAdded) == 0 &&
len(parsed.StatesRemoved) == 0 {
Expand Down
16 changes: 11 additions & 5 deletions tools/debugger/handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ func (d *Debugger) TailModeState(_ *am.Event) {
d.C.CursorTx = d.filterTxCursor(d.C, len(d.C.MsgTxs), true)
// needed bc tail mode if carried over via SelectingClient
d.updateTxBars()
d.updateTimelines()
d.draw()
}

Expand Down Expand Up @@ -473,6 +474,7 @@ func (d *Debugger) ClientMsgEnter(e *am.Event) bool {

func (d *Debugger) ClientMsgState(e *am.Event) {
msgs := e.Args["msgs_tx"].([]*telemetry.DbgMsgTx)
mach := d.Mach

updateTailMode := false
updateFirstTx := false
Expand All @@ -490,24 +492,28 @@ func (d *Debugger) ClientMsgState(e *am.Event) {
}

// TODO scalable storage
index := len(c.MsgTxs)
idx := len(c.MsgTxs)
c.MsgTxs = append(c.MsgTxs, msg)
// parse the msg
d.parseMsg(c, len(c.MsgTxs)-1)
d.parseMsg(c, idx)
filterOK := d.filterTx(c, idx, mach.Is1(ss.FilterCanceledTx),
mach.Is1(ss.FilterAutoTx), mach.Is1(ss.FilterEmptyTx))
if filterOK {
c.msgTxsFiltered = append(c.msgTxsFiltered, idx)
}

// update the UI
// TODO debounce UI updates

if c == d.C {
err := d.appendLogEntry(index)
err := d.appendLogEntry(idx)
if err != nil {
d.Mach.Log("Error: log append %s\n", err)
// d.Mach.AddErr(err)
return
}
if d.Mach.Is1(ss.TailMode) {
updateTailMode = true
c.CursorTx = d.filterTxCursor(c, len(c.MsgTxs), true)
c.CursorStep = 0
}

Expand All @@ -521,7 +527,7 @@ func (d *Debugger) ClientMsgState(e *am.Event) {
d.updateSidebar(false)
// UI updates for the selected client
if updateTailMode {
// force the latest tx
d.C.CursorTx = d.filterTxCursor(d.C, len(d.C.MsgTxs), true)
d.updateViews(false)
}

Expand Down

0 comments on commit b909432

Please sign in to comment.