Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
HugeYuan
delve
提交
798fdd9d
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,发现更多精彩内容 >>
提交
798fdd9d
编写于
5月 23, 2014
作者:
D
Derek Parker
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Implement backend breakpoint functionality
上级
ca7fd6dd
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
91 addition
and
6 deletion
+91
-6
fixtures/continuetestprog
fixtures/continuetestprog
+0
-0
fixtures/continuetestprog.go
fixtures/continuetestprog.go
+19
-0
fixtures/testprog
fixtures/testprog
+0
-0
fixtures/testprog.go
fixtures/testprog.go
+11
-1
proctl/proctl_linux_amd64.go
proctl/proctl_linux_amd64.go
+16
-0
proctl/proctl_test.go
proctl/proctl_test.go
+45
-5
未找到文件。
fixtures/continuetestprog
0 → 100755
浏览文件 @
798fdd9d
文件已添加
fixtures/continuetestprog.go
0 → 100644
浏览文件 @
798fdd9d
package
main
import
(
"fmt"
"time"
)
func
sleepytime
()
{
time
.
Sleep
(
time
.
Millisecond
)
}
func
sayhi
()
{
fmt
.
Println
(
"Hello, World!"
)
}
func
main
()
{
sleepytime
()
sayhi
()
}
fixtures/testprog
浏览文件 @
798fdd9d
无法预览此类型文件
fixtures/testprog.go
浏览文件 @
798fdd9d
...
@@ -5,7 +5,17 @@ import (
...
@@ -5,7 +5,17 @@ import (
"time"
"time"
)
)
func
main
()
{
func
sleepytime
()
{
time
.
Sleep
(
time
.
Millisecond
)
time
.
Sleep
(
time
.
Millisecond
)
}
func
sayhi
()
{
fmt
.
Println
(
"Hello, World!"
)
fmt
.
Println
(
"Hello, World!"
)
}
}
func
main
()
{
for
{
sleepytime
()
sayhi
()
}
}
proctl/proctl_linux_amd64.go
浏览文件 @
798fdd9d
...
@@ -78,6 +78,22 @@ func (dbp *DebuggedProcess) Registers() (*syscall.PtraceRegs, error) {
...
@@ -78,6 +78,22 @@ func (dbp *DebuggedProcess) Registers() (*syscall.PtraceRegs, error) {
return
dbp
.
Regs
,
nil
return
dbp
.
Regs
,
nil
}
}
// Sets a breakpoint in the running process.
func
(
dbp
*
DebuggedProcess
)
Break
(
fname
string
)
error
{
var
(
breakpoint
=
[]
byte
{
'0'
,
'x'
,
'C'
,
'C'
}
fn
=
dbp
.
GoSymTable
.
LookupFunc
(
fname
)
addr
=
uintptr
(
fn
.
LineTable
.
PC
)
)
_
,
err
:=
syscall
.
PtracePokeData
(
dbp
.
Pid
,
addr
,
breakpoint
)
if
err
!=
nil
{
return
err
}
return
nil
}
// Steps through process.
// Steps through process.
func
(
dbp
*
DebuggedProcess
)
Step
()
error
{
func
(
dbp
*
DebuggedProcess
)
Step
()
error
{
err
:=
dbp
.
handleResult
(
syscall
.
PtraceSingleStep
(
dbp
.
Pid
))
err
:=
dbp
.
handleResult
(
syscall
.
PtraceSingleStep
(
dbp
.
Pid
))
...
...
proctl/proctl_test.go
浏览文件 @
798fdd9d
...
@@ -6,8 +6,8 @@ import (
...
@@ -6,8 +6,8 @@ import (
"testing"
"testing"
)
)
func
StartTestProcess
()
(
*
exec
.
Cmd
,
error
)
{
func
StartTestProcess
(
name
string
)
(
*
exec
.
Cmd
,
error
)
{
cmd
:=
exec
.
Command
(
"../fixtures/
testprog"
)
cmd
:=
exec
.
Command
(
"../fixtures/
"
+
name
)
err
:=
cmd
.
Start
()
err
:=
cmd
.
Start
()
if
err
!=
nil
{
if
err
!=
nil
{
...
@@ -18,7 +18,7 @@ func StartTestProcess() (*exec.Cmd, error) {
...
@@ -18,7 +18,7 @@ func StartTestProcess() (*exec.Cmd, error) {
}
}
func
TestAttachProcess
(
t
*
testing
.
T
)
{
func
TestAttachProcess
(
t
*
testing
.
T
)
{
cmd
,
err
:=
StartTestProcess
()
cmd
,
err
:=
StartTestProcess
(
"testprog"
)
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Fatal
(
"Starting test process:"
,
err
)
t
.
Fatal
(
"Starting test process:"
,
err
)
}
}
...
@@ -32,10 +32,12 @@ func TestAttachProcess(t *testing.T) {
...
@@ -32,10 +32,12 @@ func TestAttachProcess(t *testing.T) {
if
!
p
.
ProcessState
.
Sys
()
.
(
syscall
.
WaitStatus
)
.
Stopped
()
{
if
!
p
.
ProcessState
.
Sys
()
.
(
syscall
.
WaitStatus
)
.
Stopped
()
{
t
.
Errorf
(
"Process was not stopped correctly"
)
t
.
Errorf
(
"Process was not stopped correctly"
)
}
}
cmd
.
Process
.
Kill
()
}
}
func
TestStep
(
t
*
testing
.
T
)
{
func
TestStep
(
t
*
testing
.
T
)
{
cmd
,
err
:=
StartTestProcess
()
cmd
,
err
:=
StartTestProcess
(
"testprog"
)
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Fatal
(
"Starting test process:"
,
err
)
t
.
Fatal
(
"Starting test process:"
,
err
)
}
}
...
@@ -71,7 +73,7 @@ func TestStep(t *testing.T) {
...
@@ -71,7 +73,7 @@ func TestStep(t *testing.T) {
}
}
func
TestContinue
(
t
*
testing
.
T
)
{
func
TestContinue
(
t
*
testing
.
T
)
{
cmd
,
err
:=
StartTestProcess
()
cmd
,
err
:=
StartTestProcess
(
"continuetestprog"
)
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Fatal
(
"Starting test process:"
,
err
)
t
.
Fatal
(
"Starting test process:"
,
err
)
}
}
...
@@ -95,3 +97,41 @@ func TestContinue(t *testing.T) {
...
@@ -95,3 +97,41 @@ func TestContinue(t *testing.T) {
t
.
Fatal
(
"Process did not exit successfully"
)
t
.
Fatal
(
"Process did not exit successfully"
)
}
}
}
}
func
TestBreakPoint
(
t
*
testing
.
T
)
{
cmd
,
err
:=
StartTestProcess
(
"testprog"
)
if
err
!=
nil
{
t
.
Fatal
(
"Starting test process:"
,
err
)
}
pid
:=
cmd
.
Process
.
Pid
p
,
err
:=
NewDebugProcess
(
pid
)
if
err
!=
nil
{
t
.
Fatal
(
"NewDebugProcess():"
,
err
)
}
err
=
p
.
Break
(
"main.sleepytime"
)
if
err
!=
nil
{
t
.
Fatal
(
"Break():"
,
err
)
}
sleepytimefunc
:=
p
.
GoSymTable
.
LookupFunc
(
"main.sleepytime"
)
sleepyaddr
:=
sleepytimefunc
.
LineTable
.
PC
err
=
p
.
Continue
()
if
err
!=
nil
{
t
.
Fatal
(
"Continue():"
,
err
)
}
regs
,
err
:=
p
.
Registers
()
if
err
!=
nil
{
t
.
Fatal
(
"Registers():"
,
err
)
}
pc
:=
regs
.
PC
()
if
pc
!=
sleepyaddr
{
t
.
Fatal
(
"Break not respected:
\n
PC:%d
\n
FN:%d
\n
"
,
pc
,
sleepyaddr
)
}
cmd
.
Process
.
Kill
()
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录