Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
HugeYuan
delve
提交
c96d0a5a
D
delve
项目概览
HugeYuan
/
delve
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
delve
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
c96d0a5a
编写于
7月 13, 2015
作者:
D
Derek Parker
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add pid flag to trace subcommand
上级
3cee10d8
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
26 addition
and
15 deletion
+26
-15
cmd/dlv/main.go
cmd/dlv/main.go
+21
-15
proc/proc.go
proc/proc.go
+5
-0
未找到文件。
cmd/dlv/main.go
浏览文件 @
c96d0a5a
...
@@ -85,27 +85,31 @@ starts and attaches to it, and enables you to immediately begin debugging your p
...
@@ -85,27 +85,31 @@ starts and attaches to it, and enables you to immediately begin debugging your p
rootCommand
.
AddCommand
(
runCommand
)
rootCommand
.
AddCommand
(
runCommand
)
// 'trace' subcommand.
// 'trace' subcommand.
var
traceAttachPid
int
traceCommand
:=
&
cobra
.
Command
{
traceCommand
:=
&
cobra
.
Command
{
Use
:
"trace [regexp]"
,
Use
:
"trace [regexp]
[flags]
"
,
Short
:
"Compile and begin tracing program."
,
Short
:
"Compile and begin tracing program."
,
Long
:
"Trace program execution. Will set a tracepoint on every function matching [regexp] and output information when tracepoint is hit."
,
Long
:
"Trace program execution. Will set a tracepoint on every function matching [regexp] and output information when tracepoint is hit."
,
Run
:
func
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
Run
:
func
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
status
:=
func
()
int
{
status
:=
func
()
int
{
const
debugname
=
"debug"
const
debugname
=
"debug"
goBuild
:=
exec
.
Command
(
"go"
,
"build"
,
"-o"
,
debugname
,
"-gcflags"
,
"-N -l"
)
var
processArgs
[]
string
goBuild
.
Stderr
=
os
.
Stderr
if
traceAttachPid
==
0
{
err
:=
goBuild
.
Run
()
goBuild
:=
exec
.
Command
(
"go"
,
"build"
,
"-o"
,
debugname
,
"-gcflags"
,
"-N -l"
)
if
err
!=
nil
{
goBuild
.
Stderr
=
os
.
Stderr
return
1
err
:=
goBuild
.
Run
()
}
if
err
!=
nil
{
fp
,
err
:=
filepath
.
Abs
(
"./"
+
debugname
)
return
1
if
err
!=
nil
{
}
fmt
.
Fprintf
(
os
.
Stderr
,
err
.
Error
())
fp
,
err
:=
filepath
.
Abs
(
"./"
+
debugname
)
return
1
if
err
!=
nil
{
}
fmt
.
Fprintf
(
os
.
Stderr
,
err
.
Error
())
defer
os
.
Remove
(
fp
)
return
1
}
defer
os
.
Remove
(
fp
)
processArgs
:=
append
([]
string
{
"./"
+
debugname
},
args
...
)
processArgs
=
append
([]
string
{
"./"
+
debugname
},
args
...
)
}
// Make a TCP listener
// Make a TCP listener
listener
,
err
:=
net
.
Listen
(
"tcp"
,
Addr
)
listener
,
err
:=
net
.
Listen
(
"tcp"
,
Addr
)
if
err
!=
nil
{
if
err
!=
nil
{
...
@@ -118,6 +122,7 @@ starts and attaches to it, and enables you to immediately begin debugging your p
...
@@ -118,6 +122,7 @@ starts and attaches to it, and enables you to immediately begin debugging your p
server
:=
rpc
.
NewServer
(
&
service
.
Config
{
server
:=
rpc
.
NewServer
(
&
service
.
Config
{
Listener
:
listener
,
Listener
:
listener
,
ProcessArgs
:
processArgs
,
ProcessArgs
:
processArgs
,
AttachPid
:
traceAttachPid
,
},
Log
)
},
Log
)
if
err
:=
server
.
Run
();
err
!=
nil
{
if
err
:=
server
.
Run
();
err
!=
nil
{
fmt
.
Fprintln
(
os
.
Stderr
,
err
)
fmt
.
Fprintln
(
os
.
Stderr
,
err
)
...
@@ -158,7 +163,7 @@ starts and attaches to it, and enables you to immediately begin debugging your p
...
@@ -158,7 +163,7 @@ starts and attaches to it, and enables you to immediately begin debugging your p
}
}
fmt
.
Printf
(
"%s(%s) %s:%d
\n
"
,
fname
,
strings
.
Join
(
args
,
", "
),
state
.
CurrentThread
.
File
,
state
.
CurrentThread
.
Line
)
fmt
.
Printf
(
"%s(%s) %s:%d
\n
"
,
fname
,
strings
.
Join
(
args
,
", "
),
state
.
CurrentThread
.
File
,
state
.
CurrentThread
.
Line
)
case
<-
sigChan
:
case
<-
sigChan
:
server
.
Stop
(
tr
ue
)
server
.
Stop
(
tr
aceAttachPid
==
0
)
return
1
return
1
}
}
}
}
...
@@ -167,6 +172,7 @@ starts and attaches to it, and enables you to immediately begin debugging your p
...
@@ -167,6 +172,7 @@ starts and attaches to it, and enables you to immediately begin debugging your p
os
.
Exit
(
status
)
os
.
Exit
(
status
)
},
},
}
}
traceCommand
.
Flags
()
.
IntVarP
(
&
traceAttachPid
,
"pid"
,
"p"
,
0
,
"Pid to attach to."
)
rootCommand
.
AddCommand
(
traceCommand
)
rootCommand
.
AddCommand
(
traceCommand
)
// 'test' subcommand.
// 'test' subcommand.
...
...
proc/proc.go
浏览文件 @
c96d0a5a
...
@@ -90,6 +90,11 @@ func Attach(pid int) (*Process, error) {
...
@@ -90,6 +90,11 @@ func Attach(pid int) (*Process, error) {
// Detach from the process being debugged, optionally killing it.
// Detach from the process being debugged, optionally killing it.
func
(
dbp
*
Process
)
Detach
(
kill
bool
)
(
err
error
)
{
func
(
dbp
*
Process
)
Detach
(
kill
bool
)
(
err
error
)
{
if
dbp
.
Running
()
{
if
err
=
dbp
.
Halt
();
err
!=
nil
{
return
}
}
if
!
kill
{
if
!
kill
{
// Clean up any breakpoints we've set.
// Clean up any breakpoints we've set.
for
_
,
bp
:=
range
dbp
.
Breakpoints
{
for
_
,
bp
:=
range
dbp
.
Breakpoints
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录