Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
HugeYuan
delve
提交
4364c728
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 搜索 >>
未验证
提交
4364c728
编写于
3月 05, 2021
作者:
L
Luis Gabriel Gomez
提交者:
GitHub
3月 05, 2021
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
dap: reduce branching on onLaunchRequest mode validations (#2364)
上级
314ae669
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
26 addition
and
14 deletion
+26
-14
service/dap/server.go
service/dap/server.go
+22
-14
service/dap/server_test.go
service/dap/server_test.go
+4
-0
未找到文件。
service/dap/server.go
浏览文件 @
4364c728
...
@@ -432,8 +432,19 @@ func (s *Server) onInitializeRequest(request *dap.InitializeRequest) {
...
@@ -432,8 +432,19 @@ func (s *Server) onInitializeRequest(request *dap.InitializeRequest) {
const
debugBinary
string
=
"./__debug_bin"
const
debugBinary
string
=
"./__debug_bin"
func
(
s
*
Server
)
onLaunchRequest
(
request
*
dap
.
LaunchRequest
)
{
func
(
s
*
Server
)
onLaunchRequest
(
request
*
dap
.
LaunchRequest
)
{
// TODO(polina): Respond with an error if debug session is in progress?
// Validate launch request mode
mode
,
ok
:=
request
.
Arguments
[
"mode"
]
if
!
ok
||
mode
==
""
{
mode
=
"debug"
}
if
!
isValidLaunchMode
(
mode
)
{
s
.
sendErrorResponse
(
request
.
Request
,
FailedToLaunch
,
"Failed to launch"
,
fmt
.
Sprintf
(
"Unsupported 'mode' value %q in debug configuration."
,
mode
))
return
}
// TODO(polina): Respond with an error if debug session is in progress?
program
,
ok
:=
request
.
Arguments
[
"program"
]
.
(
string
)
program
,
ok
:=
request
.
Arguments
[
"program"
]
.
(
string
)
if
!
ok
||
program
==
""
{
if
!
ok
||
program
==
""
{
s
.
sendErrorResponse
(
request
.
Request
,
s
.
sendErrorResponse
(
request
.
Request
,
...
@@ -442,11 +453,6 @@ func (s *Server) onLaunchRequest(request *dap.LaunchRequest) {
...
@@ -442,11 +453,6 @@ func (s *Server) onLaunchRequest(request *dap.LaunchRequest) {
return
return
}
}
mode
,
ok
:=
request
.
Arguments
[
"mode"
]
if
!
ok
||
mode
==
""
{
mode
=
"debug"
}
if
mode
==
"debug"
||
mode
==
"test"
{
if
mode
==
"debug"
||
mode
==
"test"
{
output
,
ok
:=
request
.
Arguments
[
"output"
]
.
(
string
)
output
,
ok
:=
request
.
Arguments
[
"output"
]
.
(
string
)
if
!
ok
||
output
==
""
{
if
!
ok
||
output
==
""
{
...
@@ -486,14 +492,6 @@ func (s *Server) onLaunchRequest(request *dap.LaunchRequest) {
...
@@ -486,14 +492,6 @@ func (s *Server) onLaunchRequest(request *dap.LaunchRequest) {
s
.
binaryToRemove
=
debugname
s
.
binaryToRemove
=
debugname
}
}
// TODO(polina): support "remote" mode
if
mode
!=
"exec"
&&
mode
!=
"debug"
&&
mode
!=
"test"
{
s
.
sendErrorResponse
(
request
.
Request
,
FailedToLaunch
,
"Failed to launch"
,
fmt
.
Sprintf
(
"Unsupported 'mode' value %q in debug configuration."
,
mode
))
return
}
s
.
setLaunchAttachArgs
(
request
)
s
.
setLaunchAttachArgs
(
request
)
var
targetArgs
[]
string
var
targetArgs
[]
string
...
@@ -535,6 +533,16 @@ func (s *Server) onLaunchRequest(request *dap.LaunchRequest) {
...
@@ -535,6 +533,16 @@ func (s *Server) onLaunchRequest(request *dap.LaunchRequest) {
s
.
send
(
&
dap
.
LaunchResponse
{
Response
:
*
newResponse
(
request
.
Request
)})
s
.
send
(
&
dap
.
LaunchResponse
{
Response
:
*
newResponse
(
request
.
Request
)})
}
}
// TODO(polina): support "remote" mode
func
isValidLaunchMode
(
launchMode
interface
{})
bool
{
switch
launchMode
{
case
"exec"
,
"debug"
,
"test"
:
return
true
}
return
false
}
// onDisconnectRequest handles the DisconnectRequest. Per the DAP spec,
// onDisconnectRequest handles the DisconnectRequest. Per the DAP spec,
// it disconnects the debuggee and signals that the debug adaptor
// it disconnects the debuggee and signals that the debug adaptor
// (in our case this TCP server) can be terminated.
// (in our case this TCP server) can be terminated.
...
...
service/dap/server_test.go
浏览文件 @
4364c728
...
@@ -2559,6 +2559,10 @@ func TestBadLaunchRequests(t *testing.T) {
...
@@ -2559,6 +2559,10 @@ func TestBadLaunchRequests(t *testing.T) {
client
.
LaunchRequestWithArgs
(
map
[
string
]
interface
{}{
"mode"
:
"debug"
,
"program"
:
fixture
.
Source
,
"buildFlags"
:
"123"
})
client
.
LaunchRequestWithArgs
(
map
[
string
]
interface
{}{
"mode"
:
"debug"
,
"program"
:
fixture
.
Source
,
"buildFlags"
:
"123"
})
expectFailedToLaunch
(
client
.
ExpectErrorResponse
(
t
))
// Build error
expectFailedToLaunch
(
client
.
ExpectErrorResponse
(
t
))
// Build error
client
.
LaunchRequest
(
""
,
fixture
.
Path
,
stopOnEntry
)
expectFailedToLaunchWithMessage
(
client
.
ExpectErrorResponse
(
t
),
"Failed to launch: Build error: exit status 1"
)
// We failed to launch the program. Make sure shutdown still works.
// We failed to launch the program. Make sure shutdown still works.
client
.
DisconnectRequest
()
client
.
DisconnectRequest
()
dresp
:=
client
.
ExpectDisconnectResponse
(
t
)
dresp
:=
client
.
ExpectDisconnectResponse
(
t
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录