Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
HugeYuan
delve
提交
04da3fcb
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,发现更多精彩内容 >>
提交
04da3fcb
编写于
12月 19, 2014
作者:
D
Derek Parker
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Don't assume pointer size
上级
8e40467c
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
13 addition
and
11 deletion
+13
-11
proctl/variables.go
proctl/variables.go
+13
-11
未找到文件。
proctl/variables.go
浏览文件 @
04da3fcb
...
...
@@ -25,6 +25,8 @@ type M struct {
curg
uintptr
}
const
ptrsize
uintptr
=
unsafe
.
Sizeof
(
int
(
1
))
// Parses and returns select info on the internal M
// data structures used by the Go scheduler.
func
(
thread
*
ThreadContext
)
AllM
()
([]
*
M
,
error
)
{
...
...
@@ -34,7 +36,7 @@ func (thread *ThreadContext) AllM() ([]*M, error) {
if
err
!=
nil
{
return
nil
,
err
}
mptr
,
err
:=
thread
.
readMemory
(
uintptr
(
allmaddr
),
8
)
mptr
,
err
:=
thread
.
readMemory
(
uintptr
(
allmaddr
),
ptrsize
)
if
err
!=
nil
{
return
nil
,
err
}
...
...
@@ -72,7 +74,7 @@ func (thread *ThreadContext) AllM() ([]*M, error) {
if
err
!=
nil
{
return
nil
,
err
}
curgBytes
,
err
:=
thread
.
readMemory
(
uintptr
(
curgAddr
),
8
)
curgBytes
,
err
:=
thread
.
readMemory
(
uintptr
(
curgAddr
),
ptrsize
)
if
err
!=
nil
{
return
nil
,
fmt
.
Errorf
(
"could not read curg %#v %s"
,
curgAddr
,
err
)
}
...
...
@@ -83,7 +85,7 @@ func (thread *ThreadContext) AllM() ([]*M, error) {
if
err
!=
nil
{
return
nil
,
err
}
procidBytes
,
err
:=
thread
.
readMemory
(
uintptr
(
procidAddr
),
8
)
procidBytes
,
err
:=
thread
.
readMemory
(
uintptr
(
procidAddr
),
ptrsize
)
if
err
!=
nil
{
return
nil
,
fmt
.
Errorf
(
"could not read procid %#v %s"
,
procidAddr
,
err
)
}
...
...
@@ -121,7 +123,7 @@ func (thread *ThreadContext) AllM() ([]*M, error) {
if
err
!=
nil
{
return
nil
,
err
}
mptr
,
err
=
thread
.
readMemory
(
uintptr
(
alllinkAddr
),
8
)
mptr
,
err
=
thread
.
readMemory
(
uintptr
(
alllinkAddr
),
ptrsize
)
if
err
!=
nil
{
return
nil
,
fmt
.
Errorf
(
"could not read alllink %#v %s"
,
alllinkAddr
,
err
)
}
...
...
@@ -193,11 +195,11 @@ func (dbp *DebuggedProcess) PrintGoroutinesInfo() error {
return
err
}
fmt
.
Printf
(
"[%d goroutines]
\n
"
,
allglen
)
faddr
,
err
:=
dbp
.
CurrentThread
.
readMemory
(
uintptr
(
allgentryaddr
),
8
)
faddr
,
err
:=
dbp
.
CurrentThread
.
readMemory
(
uintptr
(
allgentryaddr
),
ptrsize
)
allg
:=
binary
.
LittleEndian
.
Uint64
(
faddr
)
for
i
:=
uint64
(
0
);
i
<
allglen
;
i
++
{
err
=
printGoroutineInfo
(
dbp
,
allg
+
(
i
*
8
),
reader
)
err
=
printGoroutineInfo
(
dbp
,
allg
+
(
i
*
uint64
(
ptrsize
)
),
reader
)
if
err
!=
nil
{
return
err
}
...
...
@@ -207,7 +209,7 @@ func (dbp *DebuggedProcess) PrintGoroutinesInfo() error {
}
func
printGoroutineInfo
(
dbp
*
DebuggedProcess
,
addr
uint64
,
reader
*
dwarf
.
Reader
)
error
{
gaddrbytes
,
err
:=
dbp
.
CurrentThread
.
readMemory
(
uintptr
(
addr
),
8
)
gaddrbytes
,
err
:=
dbp
.
CurrentThread
.
readMemory
(
uintptr
(
addr
),
ptrsize
)
if
err
!=
nil
{
return
fmt
.
Errorf
(
"error derefing *G %s"
,
err
)
}
...
...
@@ -224,11 +226,11 @@ func printGoroutineInfo(dbp *DebuggedProcess, addr uint64, reader *dwarf.Reader)
return
err
}
goidbytes
,
err
:=
dbp
.
CurrentThread
.
readMemory
(
uintptr
(
goidaddr
),
8
)
goidbytes
,
err
:=
dbp
.
CurrentThread
.
readMemory
(
uintptr
(
goidaddr
),
ptrsize
)
if
err
!=
nil
{
return
fmt
.
Errorf
(
"error reading goid %s"
,
err
)
}
schedbytes
,
err
:=
dbp
.
CurrentThread
.
readMemory
(
uintptr
(
schedaddr
+
8
),
8
)
schedbytes
,
err
:=
dbp
.
CurrentThread
.
readMemory
(
uintptr
(
schedaddr
+
uint64
(
ptrsize
)),
ptrsize
)
if
err
!=
nil
{
return
fmt
.
Errorf
(
"error reading sched %s"
,
err
)
}
...
...
@@ -463,7 +465,7 @@ func (thread *ThreadContext) extractValue(instructions []byte, off int64, typ in
offaddr
:=
uintptr
(
offset
)
switch
t
:=
typ
.
(
type
)
{
case
*
dwarf
.
PtrType
:
addr
,
err
:=
thread
.
readMemory
(
offaddr
,
8
)
addr
,
err
:=
thread
.
readMemory
(
offaddr
,
ptrsize
)
if
err
!=
nil
{
return
""
,
err
}
...
...
@@ -577,7 +579,7 @@ func (thread *ThreadContext) readIntArray(addr uintptr, t *dwarf.ArrayType) (str
members
=
append
(
members
,
number
)
}
return
fmt
.
Sprintf
(
"[%d]int %d"
,
t
.
ByteSize
/
8
,
members
),
nil
return
fmt
.
Sprintf
(
"[%d]int %d"
,
t
.
ByteSize
/
int64
(
ptrsize
)
,
members
),
nil
}
func
(
thread
*
ThreadContext
)
readInt
(
addr
uintptr
,
size
int64
)
(
string
,
error
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录