Skip to content

Commit

Permalink
pkg/manager: show bug first time
Browse files Browse the repository at this point in the history
This allows to understand if a bug is new
(found in the current run) or old.
  • Loading branch information
dvyukov committed Jan 17, 2025
1 parent bb91bdd commit 953d1c4
Show file tree
Hide file tree
Showing 9 changed files with 40 additions and 1 deletion.
2 changes: 2 additions & 0 deletions pkg/manager/crash.go
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,7 @@ type CrashInfo struct {
type BugInfo struct {
ID string
Title string
FirstTime time.Time
LastTime time.Time
HasRepro bool
HasCRepro bool
Expand All @@ -232,6 +233,7 @@ func (cs *CrashStore) BugInfo(id string, full bool) (*BugInfo, error) {
return nil, err
}
ret.Title = strings.TrimSpace(string(desc))
ret.FirstTime = osutil.CreationTime(stat)
ret.LastTime = stat.ModTime()
files, err := osutil.ListDir(dir)
if err != nil {
Expand Down
2 changes: 2 additions & 0 deletions pkg/manager/html/main.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,15 @@
<tr>
<th><a onclick="return sortTable(this, 'Description', textSort)" href="#">Description</a></th>
<th><a onclick="return sortTable(this, 'Count', numSort)" href="#">Count</a></th>
<th><a onclick="return sortTable(this, 'First Time', textSort, true)" href="#">First Time</a></th>
<th><a onclick="return sortTable(this, 'Last Time', textSort, true)" href="#">Last Time</a></th>
<th><a onclick="return sortTable(this, 'Report', textSort)" href="#">Report</a></th>
</tr>
{{range $c := $.Crashes}}
<tr>
<td class="title"><a href="/crash?id={{$c.ID}}">{{$c.Description}}</a></td>
<td class="stat {{if not $c.Active}}inactive{{end}}">{{$c.Count}}</td>
<td class="time {{if not $c.New}}inactive{{end}}">{{formatTime $c.FirstTime}}</td>
<td class="time {{if not $c.Active}}inactive{{end}}">{{formatTime $c.LastTime}}</td>
<td>
{{if $c.Triaged}}
Expand Down
6 changes: 5 additions & 1 deletion pkg/manager/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,9 @@ func makeUICrashType(info *BugInfo, startTime time.Time, repros map[string]bool)
info.ReproAttempts >= MaxReproAttempts)
return UICrashType{
Description: info.Title,
FirstTime: info.FirstTime,
LastTime: info.LastTime,
New: info.FirstTime.After(startTime),
Active: info.LastTime.After(startTime),
ID: info.ID,
Count: len(info.Crashes),
Expand Down Expand Up @@ -992,8 +994,10 @@ type UICrashPage struct {

type UICrashType struct {
Description string
FirstTime time.Time
LastTime time.Time
Active bool
New bool // was first found in the current run
Active bool // was found in the current run
ID string
Count int
Triaged string
Expand Down
6 changes: 6 additions & 0 deletions pkg/osutil/osutil.go
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,12 @@ func Abs(path string) string {
return filepath.Clean(path)
}

// CreationTime returns file creation time.
// May return zero time, if not known.
func CreationTime(fi os.FileInfo) time.Time {
return creationTime(fi)
}

// MonotonicNano returns monotonic time in nanoseconds from some unspecified point in time.
// Useful mostly to measure time intervals.
// This function should be used inside of tested VMs b/c time.Now may reject to use monotonic time
Expand Down
5 changes: 5 additions & 0 deletions pkg/osutil/osutil_bsd.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,13 @@ package osutil
import (
"os"
"os/exec"
"time"
)

func creationTime(fi os.FileInfo) time.Time {
return time.Time{}
}

func RemoveAll(dir string) error {
return os.RemoveAll(dir)
}
Expand Down
5 changes: 5 additions & 0 deletions pkg/osutil/osutil_darwin.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,13 @@ package osutil
import (
"os"
"os/exec"
"time"
)

func creationTime(fi os.FileInfo) time.Time {
return time.Time{}
}

func RemoveAll(dir string) error {
return os.RemoveAll(dir)
}
Expand Down
5 changes: 5 additions & 0 deletions pkg/osutil/osutil_fuchsia.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,13 @@ import (
"fmt"
"os"
"os/exec"
"time"
)

func creationTime(fi os.FileInfo) time.Time {
return time.Time{}
}

func HandleInterrupts(shutdown chan struct{}) {
}

Expand Down
5 changes: 5 additions & 0 deletions pkg/osutil/osutil_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ import (
"golang.org/x/sys/unix"
)

func creationTime(fi os.FileInfo) time.Time {
st := fi.Sys().(*syscall.Stat_t)
return time.Unix(int64(st.Ctim.Sec), int64(st.Ctim.Nsec)) // nolint: unconvert
}

// RemoveAll is similar to os.RemoveAll, but can handle more cases.
func RemoveAll(dir string) error {
files, _ := os.ReadDir(dir)
Expand Down
5 changes: 5 additions & 0 deletions pkg/osutil/osutil_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,13 @@ import (
"os"
"os/exec"
"syscall"
"time"
)

func creationTime(fi os.FileInfo) time.Time {
return time.Time{}
}

func HandleInterrupts(shutdown chan struct{}) {
}

Expand Down

0 comments on commit 953d1c4

Please sign in to comment.