Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
pubx
delve
提交
197c1656
D
delve
项目概览
pubx
/
delve
通知
0
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
delve
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
197c1656
编写于
9月 26, 2015
作者:
F
Florin Patan
提交者:
Derek Parker
10月 09, 2015
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
proc/breakpoint Add breakpoint statistics
This adds support for breakpoints statistics Fixes #247
上级
f35d4b92
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
67 addition
and
21 deletion
+67
-21
proc/breakpoints.go
proc/breakpoints.go
+8
-5
proc/proc.go
proc/proc.go
+4
-0
proc/proc_test.go
proc/proc_test.go
+4
-0
service/api/conversions.go
service/api/conversions.go
+19
-10
service/api/types.go
service/api/types.go
+4
-0
terminal/command.go
terminal/command.go
+28
-6
未找到文件。
proc/breakpoints.go
浏览文件 @
197c1656
...
...
@@ -17,14 +17,16 @@ type Breakpoint struct {
Temp
bool
// Whether this is a temp breakpoint (for next'ing).
// Breakpoint information
Tracepoint
bool
// Tracepoint flag
Stacktrace
int
// Number of stack frames to retrieve
Goroutine
bool
// Retrieve goroutine information
Variables
[]
string
// Variables to evaluate
Tracepoint
bool
// Tracepoint flag
Stacktrace
int
// Number of stack frames to retrieve
Goroutine
bool
// Retrieve goroutine information
Variables
[]
string
// Variables to evaluate
HitCount
map
[
int
]
uint64
// Number of times a breakpoint has been reached in a certain goroutine
TotalHitCount
uint64
// Number of times a breakpoint has been reached
}
func
(
bp
*
Breakpoint
)
String
()
string
{
return
fmt
.
Sprintf
(
"Breakpoint %d at %#v %s:%d
"
,
bp
.
ID
,
bp
.
Addr
,
bp
.
File
,
bp
.
Line
)
return
fmt
.
Sprintf
(
"Breakpoint %d at %#v %s:%d
(%d)"
,
bp
.
ID
,
bp
.
Addr
,
bp
.
File
,
bp
.
Line
,
bp
.
TotalHitCount
)
}
// Clear this breakpoint appropriately depending on whether it is a
...
...
@@ -74,6 +76,7 @@ func (dbp *Process) setBreakpoint(tid int, addr uint64, temp bool) (*Breakpoint,
Line
:
l
,
Addr
:
addr
,
Temp
:
temp
,
HitCount
:
map
[
int
]
uint64
{},
}
if
temp
{
...
...
proc/proc.go
浏览文件 @
197c1656
...
...
@@ -646,6 +646,10 @@ func (dbp *Process) handleBreakpointOnThread(id int) (*Thread, error) {
if
err
=
thread
.
SetPC
(
bp
.
Addr
);
err
!=
nil
{
return
nil
,
err
}
if
g
,
err
:=
thread
.
GetG
();
err
==
nil
{
thread
.
CurrentBreakpoint
.
HitCount
[
g
.
Id
]
++
}
thread
.
CurrentBreakpoint
.
TotalHitCount
++
return
thread
,
nil
}
if
dbp
.
halt
{
...
...
proc/proc_test.go
浏览文件 @
197c1656
...
...
@@ -178,6 +178,10 @@ func TestBreakpoint(t *testing.T) {
t
.
Fatal
(
err
)
}
if
bp
.
TotalHitCount
!=
1
{
t
.
Fatalf
(
"Breakpoint should be hit once, got %d
\n
"
,
bp
.
TotalHitCount
)
}
if
pc
-
1
!=
bp
.
Addr
&&
pc
!=
bp
.
Addr
{
f
,
l
,
_
:=
p
.
goSymTable
.
PCToLine
(
pc
)
t
.
Fatalf
(
"Break not respected:
\n
PC:%#v %s:%d
\n
FN:%#v
\n
"
,
pc
,
f
,
l
,
bp
.
Addr
)
...
...
service/api/conversions.go
浏览文件 @
197c1656
...
...
@@ -2,23 +2,32 @@ package api
import
(
"debug/gosym"
"strconv"
"github.com/derekparker/delve/proc"
)
// convertBreakpoint converts an internal breakpoint to an API Breakpoint.
func
ConvertBreakpoint
(
bp
*
proc
.
Breakpoint
)
*
Breakpoint
{
return
&
Breakpoint
{
ID
:
bp
.
ID
,
FunctionName
:
bp
.
FunctionName
,
File
:
bp
.
File
,
Line
:
bp
.
Line
,
Addr
:
bp
.
Addr
,
Tracepoint
:
bp
.
Tracepoint
,
Stacktrace
:
bp
.
Stacktrace
,
Goroutine
:
bp
.
Goroutine
,
Variables
:
bp
.
Variables
,
b
:=
&
Breakpoint
{
ID
:
bp
.
ID
,
FunctionName
:
bp
.
FunctionName
,
File
:
bp
.
File
,
Line
:
bp
.
Line
,
Addr
:
bp
.
Addr
,
Tracepoint
:
bp
.
Tracepoint
,
Stacktrace
:
bp
.
Stacktrace
,
Goroutine
:
bp
.
Goroutine
,
Variables
:
bp
.
Variables
,
TotalHitCount
:
bp
.
TotalHitCount
,
}
b
.
HitCount
=
map
[
string
]
uint64
{}
for
idx
:=
range
bp
.
HitCount
{
b
.
HitCount
[
strconv
.
Itoa
(
idx
)]
=
bp
.
HitCount
[
idx
]
}
return
b
}
// convertThread converts an internal thread to an API Thread.
...
...
service/api/types.go
浏览文件 @
197c1656
...
...
@@ -42,6 +42,10 @@ type Breakpoint struct {
Goroutine
bool
`json:"goroutine"`
// variables to evaluate
Variables
[]
string
`json:"variables,omitempty"`
// number of times a breakpoint has been reached in a certain goroutine
HitCount
map
[
string
]
uint64
`json:"hitCount"`
// number of times a breakpoint has been reached
TotalHitCount
uint64
`json:"totalHitCount"`
}
// Thread is a thread within the debugged process.
...
...
terminal/command.go
浏览文件 @
197c1656
...
...
@@ -481,7 +481,7 @@ func breakpoints(t *Term, args ...string) error {
if
bp
.
Tracepoint
{
thing
=
"Tracepoint"
}
fmt
.
Printf
(
"%s %d at %#v %s:%d
\n
"
,
thing
,
bp
.
ID
,
bp
.
Addr
,
shortenFilePath
(
bp
.
File
),
bp
.
Line
)
fmt
.
Printf
(
"%s %d at %#v %s:%d
(%d)
\n
"
,
thing
,
bp
.
ID
,
bp
.
Addr
,
shortenFilePath
(
bp
.
File
),
bp
.
Line
,
bp
.
TotalHitCount
)
var
attrs
[]
string
if
bp
.
Stacktrace
>
0
{
...
...
@@ -767,12 +767,34 @@ func printcontext(t *Term, state *api.DebuggerState) error {
if
state
.
CurrentThread
.
Function
!=
nil
{
fn
=
state
.
CurrentThread
.
Function
}
if
state
.
Breakpoint
!=
nil
&&
state
.
Breakpoint
.
Tracepoint
{
var
args
[]
string
for
_
,
arg
:=
range
state
.
CurrentThread
.
Function
.
Args
{
args
=
append
(
args
,
arg
.
Value
)
if
state
.
Breakpoint
!=
nil
{
args
:=
""
if
state
.
Breakpoint
.
Tracepoint
{
var
arg
[]
string
for
_
,
ar
:=
range
state
.
CurrentThread
.
Function
.
Args
{
arg
=
append
(
arg
,
ar
.
Value
)
}
args
=
strings
.
Join
(
arg
,
", "
)
}
if
hitCount
,
ok
:=
state
.
Breakpoint
.
HitCount
[
strconv
.
Itoa
(
state
.
SelectedGoroutine
.
ID
)];
ok
{
fmt
.
Printf
(
"> %s(%s) %s:%d (hits goroutine(%d):%d total:%d)
\n
"
,
fn
.
Name
,
args
,
shortenFilePath
(
state
.
CurrentThread
.
File
),
state
.
CurrentThread
.
Line
,
state
.
SelectedGoroutine
.
ID
,
hitCount
,
state
.
Breakpoint
.
TotalHitCount
)
}
else
{
fmt
.
Printf
(
"> %s(%s) %s:%d (hits total:%d)
\n
"
,
fn
.
Name
,
args
,
shortenFilePath
(
state
.
CurrentThread
.
File
),
state
.
CurrentThread
.
Line
,
state
.
Breakpoint
.
TotalHitCount
)
}
fmt
.
Printf
(
"> %s(%s) %s:%d
\n
"
,
fn
.
Name
,
strings
.
Join
(
args
,
", "
),
shortenFilePath
(
state
.
CurrentThread
.
File
),
state
.
CurrentThread
.
Line
)
}
else
{
fmt
.
Printf
(
"> %s() %s:%d
\n
"
,
fn
.
Name
,
shortenFilePath
(
state
.
CurrentThread
.
File
),
state
.
CurrentThread
.
Line
)
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录