Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
HugeYuan
delve
提交
819c476a
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(gitcode.net)2024年7月9日维护升级公告
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
819c476a
编写于
5月 08, 2015
作者:
D
Derek Parker
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Do not attempt to automatically read locals/args
上级
48146367
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
150 addition
and
31 deletion
+150
-31
service/client.go
service/client.go
+4
-0
service/debugger/debugger.go
service/debugger/debugger.go
+38
-18
service/rest/client.go
service/rest/client.go
+18
-0
service/rest/integration_test.go
service/rest/integration_test.go
+49
-0
service/rest/server.go
service/rest/server.go
+36
-0
terminal/command.go
terminal/command.go
+5
-13
未找到文件。
service/client.go
浏览文件 @
819c476a
...
...
@@ -51,6 +51,10 @@ type Client interface {
ListSources
(
filter
string
)
([]
string
,
error
)
// ListFunctions lists all functions in the process matching filter.
ListFunctions
(
filter
string
)
([]
string
,
error
)
// ListLocals lists all local variables in scope.
ListLocalVariables
()
([]
api
.
Variable
,
error
)
// ListFunctionArgs lists all arguments to the current function.
ListFunctionArgs
()
([]
api
.
Variable
,
error
)
// ListGoroutines lists all goroutines.
ListGoroutines
()
([]
*
api
.
Goroutine
,
error
)
...
...
service/debugger/debugger.go
浏览文件 @
819c476a
...
...
@@ -390,6 +390,44 @@ func (d *Debugger) PackageVariables(threadID int, filter string) ([]api.Variable
return
vars
,
err
}
func
(
d
*
Debugger
)
LocalVariables
(
threadID
int
)
([]
api
.
Variable
,
error
)
{
vars
:=
[]
api
.
Variable
{}
err
:=
d
.
withProcess
(
func
(
p
*
proctl
.
DebuggedProcess
)
error
{
thread
,
found
:=
p
.
Threads
[
threadID
]
if
!
found
{
return
fmt
.
Errorf
(
"couldn't find thread %d"
,
threadID
)
}
pv
,
err
:=
thread
.
LocalVariables
()
if
err
!=
nil
{
return
err
}
for
_
,
v
:=
range
pv
{
vars
=
append
(
vars
,
convertVar
(
v
))
}
return
nil
})
return
vars
,
err
}
func
(
d
*
Debugger
)
FunctionArguments
(
threadID
int
)
([]
api
.
Variable
,
error
)
{
vars
:=
[]
api
.
Variable
{}
err
:=
d
.
withProcess
(
func
(
p
*
proctl
.
DebuggedProcess
)
error
{
thread
,
found
:=
p
.
Threads
[
threadID
]
if
!
found
{
return
fmt
.
Errorf
(
"couldn't find thread %d"
,
threadID
)
}
pv
,
err
:=
thread
.
FunctionArguments
()
if
err
!=
nil
{
return
err
}
for
_
,
v
:=
range
pv
{
vars
=
append
(
vars
,
convertVar
(
v
))
}
return
nil
})
return
vars
,
err
}
func
(
d
*
Debugger
)
EvalSymbolInThread
(
threadID
int
,
symbol
string
)
(
*
api
.
Variable
,
error
)
{
var
variable
*
api
.
Variable
err
:=
d
.
withProcess
(
func
(
p
*
proctl
.
DebuggedProcess
)
error
{
...
...
@@ -450,24 +488,6 @@ func convertThread(th *proctl.ThreadContext) *api.Thread {
Type
:
fn
.
Type
,
Value
:
fn
.
Value
,
GoType
:
fn
.
GoType
,
Args
:
[]
api
.
Variable
{},
Locals
:
[]
api
.
Variable
{},
}
if
vars
,
err
:=
th
.
LocalVariables
();
err
==
nil
{
for
_
,
v
:=
range
vars
{
function
.
Locals
=
append
(
function
.
Locals
,
convertVar
(
v
))
}
}
else
{
log
.
Printf
(
"error getting locals for function at %s:%d: %s"
,
file
,
line
,
err
)
}
if
vars
,
err
:=
th
.
FunctionArguments
();
err
==
nil
{
for
_
,
v
:=
range
vars
{
function
.
Args
=
append
(
function
.
Args
,
convertVar
(
v
))
}
}
else
{
log
.
Printf
(
"error getting args for function at %s:%d: %s"
,
file
,
line
,
err
)
}
}
}
...
...
service/rest/client.go
浏览文件 @
819c476a
...
...
@@ -230,6 +230,24 @@ func (c *RESTClient) ListPackageVariablesFor(threadID int, filter string) ([]api
return
vars
,
nil
}
func
(
c
*
RESTClient
)
ListLocalVariables
()
([]
api
.
Variable
,
error
)
{
var
vars
[]
api
.
Variable
err
:=
c
.
doGET
(
"/localvars"
,
&
vars
)
if
err
!=
nil
{
return
nil
,
err
}
return
vars
,
nil
}
func
(
c
*
RESTClient
)
ListFunctionArgs
()
([]
api
.
Variable
,
error
)
{
var
vars
[]
api
.
Variable
err
:=
c
.
doGET
(
"/args"
,
&
vars
)
if
err
!=
nil
{
return
nil
,
err
}
return
vars
,
nil
}
func
(
c
*
RESTClient
)
ListGoroutines
()
([]
*
api
.
Goroutine
,
error
)
{
var
goroutines
[]
*
api
.
Goroutine
err
:=
c
.
doGET
(
"/goroutines"
,
&
goroutines
)
...
...
service/rest/integration_test.go
浏览文件 @
819c476a
...
...
@@ -2,6 +2,7 @@ package rest
import
(
"net"
"path/filepath"
"testing"
protest
"github.com/derekparker/delve/proctl/test"
...
...
@@ -268,3 +269,51 @@ func TestClientServer_switchThread(t *testing.T) {
}
})
}
func
TestClientServer_infoLocals
(
t
*
testing
.
T
)
{
withTestClient
(
"testnextprog"
,
t
,
func
(
c
service
.
Client
)
{
fp
,
err
:=
filepath
.
Abs
(
"../../_fixtures/testnextprog.go"
)
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
_
,
err
=
c
.
CreateBreakPoint
(
&
api
.
BreakPoint
{
File
:
fp
,
Line
:
23
})
if
err
!=
nil
{
t
.
Fatalf
(
"Unexpected error: %v"
,
err
)
}
state
,
err
:=
c
.
Continue
()
if
err
!=
nil
{
t
.
Fatalf
(
"Unexpected error: %v, state: %#v"
,
err
,
state
)
}
locals
,
err
:=
c
.
ListLocalVariables
()
if
err
!=
nil
{
t
.
Fatalf
(
"Unexpected error: %v"
,
err
)
}
if
len
(
locals
)
!=
3
{
t
.
Fatalf
(
"Expected 3 locals, got %d %#v"
,
len
(
locals
),
locals
)
}
})
}
func
TestClientServer_infoArgs
(
t
*
testing
.
T
)
{
withTestClient
(
"testnextprog"
,
t
,
func
(
c
service
.
Client
)
{
fp
,
err
:=
filepath
.
Abs
(
"../../_fixtures/testnextprog.go"
)
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
_
,
err
=
c
.
CreateBreakPoint
(
&
api
.
BreakPoint
{
File
:
fp
,
Line
:
47
})
if
err
!=
nil
{
t
.
Fatalf
(
"Unexpected error: %v"
,
err
)
}
state
,
err
:=
c
.
Continue
()
if
err
!=
nil
{
t
.
Fatalf
(
"Unexpected error: %v, state: %#v"
,
err
,
state
)
}
locals
,
err
:=
c
.
ListFunctionArgs
()
if
err
!=
nil
{
t
.
Fatalf
(
"Unexpected error: %v"
,
err
)
}
if
len
(
locals
)
!=
2
{
t
.
Fatalf
(
"Expected 2 function args, got %d %#v"
,
len
(
locals
),
locals
)
}
})
}
service/rest/server.go
浏览文件 @
819c476a
...
...
@@ -88,6 +88,8 @@ func (s *RESTServer) Run() error {
Route
(
ws
.
GET
(
"/sources"
)
.
To
(
s
.
listSources
))
.
Route
(
ws
.
GET
(
"/functions"
)
.
To
(
s
.
listFunctions
))
.
Route
(
ws
.
GET
(
"/vars"
)
.
To
(
s
.
listPackageVars
))
.
Route
(
ws
.
GET
(
"/localvars"
)
.
To
(
s
.
listLocalVars
))
.
Route
(
ws
.
GET
(
"/args"
)
.
To
(
s
.
listFunctionArgs
))
.
Route
(
ws
.
GET
(
"/eval/{symbol}"
)
.
To
(
s
.
evalSymbol
))
.
// TODO: GET might be the wrong verb for this
Route
(
ws
.
GET
(
"/detach"
)
.
To
(
s
.
detach
))
...
...
@@ -293,6 +295,40 @@ func (s *RESTServer) listThreadPackageVars(request *restful.Request, response *r
response
.
WriteEntity
(
vars
)
}
func
(
s
*
RESTServer
)
listLocalVars
(
request
*
restful
.
Request
,
response
*
restful
.
Response
)
{
state
,
err
:=
s
.
debugger
.
State
()
if
err
!=
nil
{
writeError
(
response
,
http
.
StatusInternalServerError
,
err
.
Error
())
return
}
vars
,
err
:=
s
.
debugger
.
LocalVariables
(
state
.
CurrentThread
.
ID
)
if
err
!=
nil
{
writeError
(
response
,
http
.
StatusInternalServerError
,
err
.
Error
())
return
}
response
.
WriteHeader
(
http
.
StatusOK
)
response
.
WriteEntity
(
vars
)
}
func
(
s
*
RESTServer
)
listFunctionArgs
(
request
*
restful
.
Request
,
response
*
restful
.
Response
)
{
state
,
err
:=
s
.
debugger
.
State
()
if
err
!=
nil
{
writeError
(
response
,
http
.
StatusInternalServerError
,
err
.
Error
())
return
}
vars
,
err
:=
s
.
debugger
.
FunctionArguments
(
state
.
CurrentThread
.
ID
)
if
err
!=
nil
{
writeError
(
response
,
http
.
StatusInternalServerError
,
err
.
Error
())
return
}
response
.
WriteHeader
(
http
.
StatusOK
)
response
.
WriteEntity
(
vars
)
}
func
(
s
*
RESTServer
)
evalSymbol
(
request
*
restful
.
Request
,
response
*
restful
.
Response
)
{
symbol
:=
request
.
PathParameter
(
"symbol"
)
if
len
(
symbol
)
==
0
{
...
...
terminal/command.go
浏览文件 @
819c476a
...
...
@@ -364,24 +364,18 @@ func info(client service.Client, args ...string) error {
data
=
funcs
case
"args"
:
state
,
err
:=
client
.
GetState
()
args
,
err
:=
client
.
ListFunctionArgs
()
if
err
!=
nil
{
return
err
}
if
state
.
CurrentThread
==
nil
||
state
.
CurrentThread
.
Function
==
nil
{
return
nil
}
data
=
filterVariables
(
state
.
CurrentThread
.
Function
.
Args
,
filter
)
data
=
filterVariables
(
args
,
filter
)
case
"locals"
:
state
,
err
:=
client
.
GetState
()
locals
,
err
:=
client
.
ListLocalVariables
()
if
err
!=
nil
{
return
err
}
if
state
.
CurrentThread
==
nil
||
state
.
CurrentThread
.
Function
==
nil
{
return
nil
}
data
=
filterVariables
(
state
.
CurrentThread
.
Function
.
Locals
,
filter
)
data
=
filterVariables
(
locals
,
filter
)
case
"vars"
:
regex
:=
""
...
...
@@ -392,9 +386,7 @@ func info(client service.Client, args ...string) error {
if
err
!=
nil
{
return
err
}
for
_
,
v
:=
range
vars
{
data
=
append
(
data
,
fmt
.
Sprintf
(
"%s = %s"
,
v
.
Name
,
v
.
Value
))
}
data
=
filterVariables
(
vars
,
filter
)
default
:
return
fmt
.
Errorf
(
"unsupported info type, must be args, funcs, locals, sources, or vars"
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录