Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
HugeYuan
delve
提交
aa8ad889
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,体验更适合开发者的 AI 搜索 >>
提交
aa8ad889
编写于
2月 02, 2015
作者:
D
Derek Parker
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Improve documentation
上级
e001bbff
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
42 addition
and
12 deletion
+42
-12
proctl/breakpoints_linux_amd64.go
proctl/breakpoints_linux_amd64.go
+13
-0
proctl/proctl.go
proctl/proctl.go
+14
-9
proctl/threads.go
proctl/threads.go
+15
-3
未找到文件。
proctl/breakpoints_linux_amd64.go
浏览文件 @
aa8ad889
...
...
@@ -36,6 +36,8 @@ type BreakPoint struct {
temp
bool
}
// Returned when trying to set a breakpoint at
// an address that already has a breakpoint set for it.
type
BreakPointExistsError
struct
{
file
string
line
int
...
...
@@ -46,6 +48,16 @@ func (bpe BreakPointExistsError) Error() string {
return
fmt
.
Sprintf
(
"Breakpoint exists at %s:%d at %x"
,
bpe
.
file
,
bpe
.
line
,
bpe
.
addr
)
}
// InvalidAddressError represents the result of
// attempting to set a breakpoint at an invalid address.
type
InvalidAddressError
struct
{
address
uint64
}
func
(
iae
InvalidAddressError
)
Error
()
string
{
return
fmt
.
Sprintf
(
"Invalid address %#v
\n
"
,
iae
.
address
)
}
func
PtracePokeUser
(
tid
int
,
off
,
addr
uintptr
)
error
{
_
,
_
,
err
:=
sys
.
Syscall6
(
sys
.
SYS_PTRACE
,
sys
.
PTRACE_POKEUSR
,
uintptr
(
tid
),
uintptr
(
off
),
uintptr
(
addr
),
0
,
0
)
if
err
!=
syscall
.
Errno
(
0
)
{
...
...
@@ -63,6 +75,7 @@ func PtracePeekUser(tid int, off uintptr) (uintptr, error) {
return
val
,
nil
}
// Returns whether or not a breakpoint has been set for the given address.
func
(
dbp
*
DebuggedProcess
)
BreakpointExists
(
addr
uint64
)
bool
{
for
_
,
bp
:=
range
dbp
.
HWBreakPoints
{
if
bp
!=
nil
&&
bp
.
Addr
==
addr
{
...
...
proctl/proctl.go
浏览文件 @
aa8ad889
...
...
@@ -37,12 +37,15 @@ type DebuggedProcess struct {
halt
bool
}
// A ManualStopError happens when the user triggers a
// manual stop via SIGERM.
type
ManualStopError
struct
{}
func
(
mse
ManualStopError
)
Error
()
string
{
return
"Manual stop requested"
}
// Attach to an existing process with the given PID.
func
Attach
(
pid
int
)
(
*
DebuggedProcess
,
error
)
{
dbp
,
err
:=
newDebugProcess
(
pid
,
true
)
if
err
!=
nil
{
...
...
@@ -65,6 +68,9 @@ func Attach(pid int) (*DebuggedProcess, error) {
return
dbp
,
nil
}
// Create and begin debugging a new process. First entry in
// `cmd` is the program to run, and then rest are the arguments
// to be supplied to that process.
func
Launch
(
cmd
[]
string
)
(
*
DebuggedProcess
,
error
)
{
proc
:=
exec
.
Command
(
cmd
[
0
])
proc
.
Args
=
cmd
...
...
@@ -120,6 +126,8 @@ func newDebugProcess(pid int, attach bool) (*DebuggedProcess, error) {
return
&
dbp
,
nil
}
// Attach to a newly created thread, and store that thread in our list of
// known threads.
func
(
dbp
*
DebuggedProcess
)
AttachThread
(
tid
int
)
(
*
ThreadContext
,
error
)
{
if
thread
,
ok
:=
dbp
.
Threads
[
tid
];
ok
{
return
thread
,
nil
...
...
@@ -146,6 +154,8 @@ func (dbp *DebuggedProcess) AttachThread(tid int) (*ThreadContext, error) {
return
dbp
.
addThread
(
tid
)
}
// Returns whether or not Delve thinks the debugged
// process is currently executing.
func
(
dbp
*
DebuggedProcess
)
Running
()
bool
{
return
dbp
.
running
}
...
...
@@ -204,6 +214,8 @@ func (dbp *DebuggedProcess) FindLocation(str string) (uint64, error) {
}
}
// Sends out a request that the debugged process halt
// execution. Sends SIGSTOP to all threads.
func
(
dbp
*
DebuggedProcess
)
RequestManualStop
()
{
dbp
.
halt
=
true
for
_
,
th
:=
range
dbp
.
Threads
{
...
...
@@ -215,7 +227,8 @@ func (dbp *DebuggedProcess) RequestManualStop() {
dbp
.
running
=
false
}
// Sets a breakpoint in the current thread.
// Sets a breakpoint, adding it to our list of known breakpoints. Uses
// the "current thread" when setting the breakpoint.
func
(
dbp
*
DebuggedProcess
)
Break
(
addr
uint64
)
(
*
BreakPoint
,
error
)
{
return
dbp
.
CurrentThread
.
Break
(
addr
)
}
...
...
@@ -357,14 +370,6 @@ func (dbp *DebuggedProcess) Registers() (Registers, error) {
return
dbp
.
CurrentThread
.
Registers
()
}
type
InvalidAddressError
struct
{
address
uint64
}
func
(
iae
InvalidAddressError
)
Error
()
string
{
return
fmt
.
Sprintf
(
"Invalid address %#v
\n
"
,
iae
.
address
)
}
func
(
dbp
*
DebuggedProcess
)
CurrentPC
()
(
uint64
,
error
)
{
return
dbp
.
CurrentThread
.
CurrentPC
()
}
...
...
proctl/threads.go
浏览文件 @
aa8ad889
...
...
@@ -3,19 +3,27 @@ package proctl
import
(
"encoding/binary"
"fmt"
sys
"golang.org/x/sys/unix"
"github.com/derekparker/delve/dwarf/frame"
)
// ThreadContext represents a single thread of execution in the
// traced program.
// ThreadContext represents a single thread in the traced process
// Id represents the thread id, Process holds a reference to the
// DebuggedProcess struct that contains info on the process as
// a whole, and Status represents the last result of a `wait` call
// on this thread.
type
ThreadContext
struct
{
Id
int
Process
*
DebuggedProcess
Status
*
sys
.
WaitStatus
}
// An interface for a generic register type. The
// interface encapsulates the generic values / actions
// we need independant of arch. The concrete register types
// will be different depending on OS/Arch.
type
Registers
interface
{
PC
()
uint64
SP
()
uint64
...
...
@@ -32,7 +40,7 @@ func (thread *ThreadContext) Registers() (Registers, error) {
return
regs
,
nil
}
// Returns the current PC for this thread
id
.
// Returns the current PC for this thread.
func
(
thread
*
ThreadContext
)
CurrentPC
()
(
uint64
,
error
)
{
regs
,
err
:=
thread
.
Registers
()
if
err
!=
nil
{
...
...
@@ -76,6 +84,10 @@ func (thread *ThreadContext) Clear(addr uint64) (*BreakPoint, error) {
return
thread
.
Process
.
clearBreakpoint
(
thread
.
Id
,
addr
)
}
// Continue the execution of this thread. This method takes
// software breakpoints into consideration and ensures that
// we step over any breakpoints. It will restore the instruction,
// step, and then restore the breakpoint and continue.
func
(
thread
*
ThreadContext
)
Continue
()
error
{
// Check whether we are stopped at a breakpoint, and
// if so, single step over it before continuing.
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录