gpt4 book ai didi

python - "No module named"。 gdb 中的 Python 错误

转载 作者:行者123 更新时间:2023-11-28 18:44:35 31 4
gpt4 key购买 nike

我正在做一个类(class)项目(别担心,这个问题不是家庭作业),最近从部门的机器搬到了我自己的机器上。该项目是构建一个简单的操作系统。为了使任务更容易,我们提供了将 gdb “附加”到我们程序运行的 QEMU 的能力。在我的计算机上运行这个程序而不附加 gdb 工作正常,但是当我开始尝试使用 gdb 时它不运行。需要注意的主要事项(我认为)是它在部门计算机 (gdb 7.4.1-debian) 上运行良好,但在我的计算机 (7.6.1-ubuntu) 上运行良好。

我得到的关于 python 的错误是 gdb 扩展是用 python 编写的,但它们似乎没有被发现。我也遇到语法错误。该程序的运行如下所示:

/usr/bin/qemu-system-i386
GNU gdb (GDB) 7.6.1-ubuntu
Copyright (C) 2013 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
Reading symbols from /home/alfonso/course/cs167/weenix/kernel/weenix.dbg...done.

然后它挂了一会儿,然后给我这个错误:

inittmp.gdb:1: Error in sourced command file:
localhost:1234: Connection timed out.
Traceback (most recent call last):
File "/home/alfonso/course/cs167/weenix/kernel/mm/memcheck.py", line 5, in <module>
import weenix
ImportError: No module named 'weenix'
File "/home/alfonso/course/cs167/weenix/kernel/mm/page.py", line 15
print "pagesize: {0}".format(weenix.kmem.pagesize())
^
SyntaxError: invalid syntax
File "/home/alfonso/course/cs167/weenix/kernel/mm/slab.py", line 40
print "{1:<{0}} {3:>{2}} {5:>{4}} {7:>{6}}".format(
^
SyntaxError: invalid syntax
File "/home/alfonso/course/cs167/weenix/kernel/proc/proc.py", line 17
print weenix.proc.str_proc_tree()
^
SyntaxError: invalid syntax
Traceback (most recent call last):
File "/home/alfonso/course/cs167/weenix/kernel/util/debug.py", line 3, in <module>
import weenix
ImportError: No module named 'weenix'
Traceback (most recent call last):
File "/home/alfonso/course/cs167/weenix/kernel/util/list.py", line 3, in <module>
import weenix
ImportError: No module named 'weenix'
Breakpoint 1 at 0xc0008f04: file util/debug.c, line 190.
Breakpoint 2 at 0xc0007016: file main/kmain.c, line 298.
Breakpoint 3 at 0xc0006cf3: file main/kmain.c, line 129.
init.gdb:6: Error in sourced command file:
The program is not being run.

当然,导入错误和无效语法让我开始考虑我的 PYTHONPATH 和/或包设置,但这是工作正常的东西(测试过)。我唯一能想到的是我忽略了一些配置问题。

如果您愿意,我可以发布 bash 脚本、.gdb 文件和其他文件,但由于这在部门计算机上运行良好,我怀疑这是问题所在。

Python 版本:(部门:“2.7.3”,我:“2.7.5+”)

编辑:经过一番搜索,我意识到最新的 Linux Mint(petra) 使用将 python 解释为 python3 的 gdb。我目前正在寻找一种配置 gdb 的方法,但由于我以前从未做过,如果有人可以指导我这样做,我将不胜感激。

最佳答案

您将 Python 3 用于此 Debug模式。

$ python3 test33.py
File "test33.py", line 1
print "hello".format()
^
SyntaxError: invalid syntax

确保按照您所说的使用 Python 2。

关于python - "No module named"。 gdb 中的 Python 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22076453/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com