Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
pubx
delve
提交
c96d0a5a
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,发现更多精彩内容 >>
提交
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
rootCommand
.
AddCommand
(
runCommand
)
// 'trace' subcommand.
var
traceAttachPid
int
traceCommand
:=
&
cobra
.
Command
{
Use
:
"trace [regexp]"
,
Use
:
"trace [regexp]
[flags]
"
,
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."
,
Run
:
func
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
status
:=
func
()
int
{
const
debugname
=
"debug"
goBuild
:=
exec
.
Command
(
"go"
,
"build"
,
"-o"
,
debugname
,
"-gcflags"
,
"-N -l"
)
goBuild
.
Stderr
=
os
.
Stderr
err
:=
goBuild
.
Run
()
if
err
!=
nil
{
return
1
}
fp
,
err
:=
filepath
.
Abs
(
"./"
+
debugname
)
if
err
!=
nil
{
fmt
.
Fprintf
(
os
.
Stderr
,
err
.
Error
())
return
1
}
defer
os
.
Remove
(
fp
)
var
processArgs
[]
string
if
traceAttachPid
==
0
{
goBuild
:=
exec
.
Command
(
"go"
,
"build"
,
"-o"
,
debugname
,
"-gcflags"
,
"-N -l"
)
goBuild
.
Stderr
=
os
.
Stderr
err
:=
goBuild
.
Run
()
if
err
!=
nil
{
return
1
}
fp
,
err
:=
filepath
.
Abs
(
"./"
+
debugname
)
if
err
!=
nil
{
fmt
.
Fprintf
(
os
.
Stderr
,
err
.
Error
())
return
1
}
defer
os
.
Remove
(
fp
)
processArgs
:=
append
([]
string
{
"./"
+
debugname
},
args
...
)
processArgs
=
append
([]
string
{
"./"
+
debugname
},
args
...
)
}
// Make a TCP listener
listener
,
err
:=
net
.
Listen
(
"tcp"
,
Addr
)
if
err
!=
nil
{
...
...
@@ -118,6 +122,7 @@ starts and attaches to it, and enables you to immediately begin debugging your p
server
:=
rpc
.
NewServer
(
&
service
.
Config
{
Listener
:
listener
,
ProcessArgs
:
processArgs
,
AttachPid
:
traceAttachPid
,
},
Log
)
if
err
:=
server
.
Run
();
err
!=
nil
{
fmt
.
Fprintln
(
os
.
Stderr
,
err
)
...
...
@@ -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
)
case
<-
sigChan
:
server
.
Stop
(
tr
ue
)
server
.
Stop
(
tr
aceAttachPid
==
0
)
return
1
}
}
...
...
@@ -167,6 +172,7 @@ starts and attaches to it, and enables you to immediately begin debugging your p
os
.
Exit
(
status
)
},
}
traceCommand
.
Flags
()
.
IntVarP
(
&
traceAttachPid
,
"pid"
,
"p"
,
0
,
"Pid to attach to."
)
rootCommand
.
AddCommand
(
traceCommand
)
// 'test' subcommand.
...
...
proc/proc.go
浏览文件 @
c96d0a5a
...
...
@@ -90,6 +90,11 @@ func Attach(pid int) (*Process, error) {
// Detach from the process being debugged, optionally killing it.
func
(
dbp
*
Process
)
Detach
(
kill
bool
)
(
err
error
)
{
if
dbp
.
Running
()
{
if
err
=
dbp
.
Halt
();
err
!=
nil
{
return
}
}
if
!
kill
{
// Clean up any breakpoints we've set.
for
_
,
bp
:=
range
dbp
.
Breakpoints
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录