Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
avocado
提交
bf201a18
A
avocado
项目概览
openeuler
/
avocado
通知
0
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
A
avocado
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
bf201a18
编写于
11月 25, 2014
作者:
L
Lucas Meneghel Rodrigues
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #266 from clebergnu/gdb_path_v2
GDB: support for setting gdb/gdbserver paths [v2]
上级
d38f352e
55b6acc3
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
66 addition
and
16 deletion
+66
-16
avocado/gdb.py
avocado/gdb.py
+22
-13
avocado/plugins/gdb.py
avocado/plugins/gdb.py
+25
-0
avocado/runtime.py
avocado/runtime.py
+6
-0
avocado/utils/process.py
avocado/utils/process.py
+3
-3
man/avocado.rst
man/avocado.rst
+10
-0
未找到文件。
avocado/gdb.py
浏览文件 @
bf201a18
...
...
@@ -165,16 +165,19 @@ class GDB(object):
Wraps a GDB subprocess for easier manipulation
"""
GDB_PATH
=
'/usr/bin/gdb'
GDB_ARGS
=
[
GDB_PATH
,
'--interpreter=mi'
,
'--quiet'
]
REQUIRED_ARGS
=
[
'--interpreter=mi'
,
'--quiet'
]
DEFAULT_BREAK
=
'main'
def
__init__
(
self
):
self
.
process
=
subprocess
.
Popen
(
self
.
GDB_ARGS
,
def
__init__
(
self
,
path
=
'/usr/bin/gdb'
,
*
extra_args
):
self
.
path
=
path
args
=
[
self
.
path
]
args
+=
self
.
REQUIRED_ARGS
args
+=
extra_args
self
.
process
=
subprocess
.
Popen
(
args
,
stdin
=
subprocess
.
PIPE
,
stdout
=
subprocess
.
PIPE
,
stderr
=
subprocess
.
PIPE
,
...
...
@@ -443,14 +446,22 @@ class GDBServer(object):
"""
#: The default arguments used when starting the GDB server process
ARGS
=
[
'/usr/bin/gdbserver'
,
'--multi'
]
REQUIRED_ARGS
=
[
'--multi'
]
#: The range from which a port to GDB server will try to be allocated from
PORT_RANGE
=
(
20000
,
20999
)
def
__init__
(
self
):
self
.
port
=
network
.
find_free_port
(
*
self
.
PORT_RANGE
)
def
__init__
(
self
,
path
=
'/usr/bin/gdbserver'
,
port
=
None
,
*
extra_args
):
self
.
path
=
path
args
=
[
self
.
path
]
args
+=
self
.
REQUIRED_ARGS
if
port
is
None
:
self
.
port
=
network
.
find_free_port
(
*
self
.
PORT_RANGE
)
else
:
self
.
port
=
port
args
.
append
(
":%s"
%
self
.
port
)
prefix
=
'avocado_gdbserver_%s_'
%
self
.
port
_
,
self
.
stdout_path
=
tempfile
.
mkstemp
(
prefix
=
prefix
+
'stdout_'
)
...
...
@@ -458,8 +469,6 @@ class GDBServer(object):
_
,
self
.
stderr_path
=
tempfile
.
mkstemp
(
prefix
=
prefix
+
'stderr_'
)
self
.
stderr
=
open
(
self
.
stderr_path
,
'w'
)
args
=
self
.
ARGS
[:]
args
.
append
(
":%s"
%
self
.
port
)
self
.
process
=
subprocess
.
Popen
(
args
,
stdin
=
subprocess
.
PIPE
,
stdout
=
self
.
stdout
,
...
...
avocado/plugins/gdb.py
浏览文件 @
bf201a18
...
...
@@ -15,6 +15,7 @@
"""Run tests with GDB goodies enabled."""
from
avocado
import
runtime
from
avocado.utils
import
process
from
avocado.plugins
import
plugin
...
...
@@ -43,6 +44,28 @@ class GDB(plugin.Plugin):
' inferior process received a fatal signal '
'such as SIGSEGV or SIGABRT'
))
default_gdb_path
=
'/usr/bin/gdb'
try
:
system_gdb_path
=
process
.
find_command
(
'gdb'
)
except
process
.
CmdNotFoundError
:
system_gdb_path
=
default_gdb_path
gdb_grp
.
add_argument
(
'--gdb-path'
,
default
=
system_gdb_path
,
metavar
=
'PATH'
,
help
=
(
'Path to the GDB executable, should you '
'need to use a custom GDB version. Defaults '
'to "%(default)s"'
))
default_gdbserver_path
=
'/usr/bin/gdbserver'
try
:
system_gdbserver_path
=
process
.
find_command
(
'gdbserver'
)
except
process
.
CmdNotFoundError
:
system_gdbserver_path
=
default_gdbserver_path
gdb_grp
.
add_argument
(
'--gdbserver-path'
,
default
=
system_gdbserver_path
,
metavar
=
'PATH'
,
help
=
(
'Path to the gdbserver executable, should you '
'need to use a custom version. Defaults '
'to "%(default)s"'
))
self
.
configured
=
True
def
activate
(
self
,
app_args
):
...
...
@@ -51,5 +74,7 @@ class GDB(plugin.Plugin):
runtime
.
GDB_RUN_BINARY_NAMES_EXPR
.
append
(
binary
)
if
app_args
.
gdb_enable_core
:
runtime
.
GDB_ENABLE_CORE
=
True
runtime
.
GDB_PATH
=
app_args
.
gdb_path
runtime
.
GDBSERVER_PATH
=
app_args
.
gdbserver_path
except
AttributeError
:
pass
avocado/runtime.py
浏览文件 @
bf201a18
...
...
@@ -25,6 +25,12 @@ GDB_RUN_BINARY_NAMES_EXPR = []
#: that are run inside the GNU debugger
GDB_ENABLE_CORE
=
False
#: Path to the GDB binary
GDB_PATH
=
None
#: Path to the gdbserver binary
GDBSERVER_PATH
=
None
#: Sometimes it's useful for the framework and API to know about the test that
#: is currently running, if one exists
CURRENT_TEST
=
None
avocado/utils/process.py
浏览文件 @
bf201a18
...
...
@@ -553,8 +553,8 @@ class GDBSubProcess(object):
self
.
binary_path
=
os
.
path
.
abspath
(
self
.
cmd
)
self
.
result
=
CmdResult
(
cmd
)
self
.
gdb_server
=
gdb
.
GDBServer
()
self
.
gdb
=
gdb
.
GDB
()
self
.
gdb_server
=
gdb
.
GDBServer
(
runtime
.
GDBSERVER_PATH
)
self
.
gdb
=
gdb
.
GDB
(
runtime
.
GDB_PATH
)
self
.
gdb
.
connect
(
self
.
gdb_server
.
port
)
self
.
gdb
.
set_file
(
self
.
binary
)
...
...
@@ -615,7 +615,7 @@ class GDBSubProcess(object):
script
=
open
(
script_path
,
'w'
)
script
.
write
(
"#!/bin/sh
\n
"
)
script
.
write
(
"%s -x %s
\n
"
%
(
gdb
.
GDB
.
GDB_PATH
,
cmds
))
script
.
write
(
"%s -x %s
\n
"
%
(
runtime
.
GDB_PATH
,
cmds
))
script
.
write
(
"echo -n 'C' > %s
\n
"
%
fifo_path
)
script
.
close
()
os
.
chmod
(
script_path
,
stat
.
S_IRUSR
|
stat
.
S_IWUSR
|
stat
.
S_IXUSR
)
...
...
man/avocado.rst
浏览文件 @
bf201a18
...
...
@@ -286,6 +286,16 @@ while you are debugging it, avocado has no way to know about its status.
Avocado will automatically send a `continue` command to the debugger
when you disconnect from and exit gdb.
If, for some reason you have a custom GDB, or your system does not put
GDB on what avocado believes to be the standard location (`/usr/bin/gdb`),
you can override that with::
$ avocado run --gdb-path=~/code/gdb/gdb --gdb-run-bin=foo:main footest
The same applies to `gdbserver`, which can be chosen with a command line like::
$ avocado run --gdbserver-path=~/code/gdb/gdbserver --gdb-run-bin=foo:main footest
RECORDING TEST REFERENCE OUTPUT
===============================
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录