- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
例如,我知道一个像“0x7f0fdd25d7d0”这样的地址,它代表一个具有已知 python 类类型的 python 对象。无论如何获取对象字段的值?
最佳答案
来自 gdb
文档:
You can use the command
x
(for "examine") to examine memory in any of several formats, independently of your program's data types.
x/nfu addr
x addr
x
Use the
x
command to examine memory.
n
,f
, andu
are all optional parameters that specify how much memory to display and how to format it;addr
is an expression giving the address where you want to start displaying memory. If you use defaults fornfu
, you need not type the slash/
. Several commands set convenient defaults for addr.
n
, the repeat countThe repeat count is a decimal integer; the default is 1. It specifies how much memory (counting by units
u
) to display.
f
, the display formatThe display format is one of the formats used by print,
s
(null-terminated string), ori
(machine instruction). The default isx
(hexadecimal) initially. The default changes each time you use either x or print.
u
, the unit size The unit size is any of
b
Bytes.
h
Halfwords (two bytes).
w
Words (four bytes). This is the initial default.
g
Giant words (eight bytes).Each time you specify a unit size with
x
, that size becomes the default unit the next time you usex
. (For thes
andi
formats, the unit size is ignored and is normally not written.)
addr
, starting display address
addr
is the address where you want GDB to begin displaying memory. The expression need not have a pointer value (though it may); it is always interpreted as an integer address of a byte of memory. See section Expressions, for more information on expressions. The default foraddr
is usually just after the last address examined--but several other commands also set the default address: info breakpoints (to the address of the last breakpoint listed), info line (to the starting address of a line), and print (if you use it to display a value from memory). For example,x/3uh 0x54320
is a request to display three halfwords (h
) of memory, formatted as unsigned decimal integers (u
), starting at address 0x54320.x/4xw $sp
prints the four words (w
) of memory above the stack pointer (here,$sp
; see section Registers) in hexadecimal (x
).Since the letters indicating unit sizes are all distinct from the letters specifying output formats, you do not have to remember whether unit size or format comes first; either order works. The output specifications
4xw
and4wx
mean exactly the same thing. (However, the count n must come first; `wx4' does not work.)Even though the unit size u is ignored for the formats
s
andi
, you might still want to use a count n; for example,3i
specifies that you want to see three machine instructions, including any operands. The command disassemble gives an alternative way of inspecting machine instructions; see section Source and machine code.All the defaults for the arguments to x are designed to make it easy to continue scanning memory with minimal specifications each time you use x. For example, after you have inspected three machine instructions with
x/3i addr
, you can inspect the next seven with justx/7
. If you use RET to repeat the x command, the repeat count n is used again; the other arguments default as for successive uses of x.The addresses and contents printed by the x command are not saved in the value history because there is often too much of them and they would get in the way. Instead, GDB makes these values available for subsequent use in expressions as values of the convenience variables $_ and $. After an x command, the last address examined is available for use in expressions in the convenience variable $_. The contents of that address, as examined, are available in the convenience variable $.
If the
x
command has a repeat count, the address and contents saved are from the last memory unit printed; this is not the same as the last address printed if several units were printed on the last line of output.
来源:ftp://ftp.gnu.org/old-gnu/Manuals/gdb/html_chapter/gdb_9.html#SEC56
关于 gdb
的更多文档:
23.2.2.4 Types In Python
gdb represents types from the inferior using the class gdb.Type.
The following type-related functions are available in the gdb module:
— Function: gdb.lookup_type (name [, block]) This function looks up a type by its name, which must be a string.
If block is given, then name is looked up in that scope. Otherwise, it is searched for globally.
Ordinarily, this function will return an instance of gdb.Type. If the named type cannot be found, it will throw an exception.
If the type is a structure or class type, or an enum type, the fields of that type can be accessed using the Python dictionary syntax. For example, if some_type is a gdb.Type instance holding a structure type, you can access its foo field with:
bar = some_type['foo']
bar will be a gdb.Field object; see below under the description of the Type.fields method for a description of the gdb.Field class.
An instance of Type has the following attributes:
— Variable: Type.code The type code for this type. The type code will be one of the TYPE_CODE_ constants defined below.
— Variable: Type.name The name of this type. If this type has no name, then None is returned.
— Variable: Type.sizeof The size of this type, in target char units. Usually, a target's char type will be an 8-bit byte. However, on some unusual platforms, this type may have a different size.
— Variable: Type.tag The tag name for this type. The tag name is the name after struct, union, or enum in C and C++; not all languages have this concept. If this type has no tag name, then None is returned.
The following methods are provided:
— Function: Type.fields () For structure and union types, this method returns the fields. Range types have two fields, the minimum and maximum values. Enum types have one field per enum constant. Function and method types have one field per parameter. The base types of C++ classes are also represented as fields. If the type has no fields, or does not fit into one of these categories, an empty sequence will be returned.
Each field is a gdb.Field object, with some pre-defined attributes:
bitpos This attribute is not available for enum or static (as in C++ or Java) fields. The value is the position, counting in bits, from the start of the containing type. enumval This attribute is only available for enum fields, and its value is the enumeration member's integer representation. name The name of the field, or None for anonymous fields. artificial This is True if the field is artificial, usually meaning that it was provided by the compiler and not the user. This attribute is always provided, and is False if the field is not artificial. is_base_class This is True if the field represents a base class of a C++ structure. This attribute is always provided, and is False if the field is not a base class of the type that is the argument of fields, or if that type was not a C++ class. bitsize If the field is packed, or is a bitfield, then this will have a non-zero value, which is the size of the field in bits. Otherwise, this will be zero; in this case the field's size is given by its type. type The type of the field. This is usually an instance of Type, but it can be None in some situations. parent_type The type which contains this field. This is an instance of gdb.Type. — Function: Type.array (n1 [, n2]) Return a new gdb.Type object which represents an array of this type. If one argument is given, it is the inclusive upper bound of the array; in this case the lower bound is zero. If two arguments are given, the first argument is the lower bound of the array, and the second argument is the upper bound of the array. An array's length must not be negative, but the bounds can be.
— Function: Type.vector (n1 [, n2]) Return a new gdb.Type object which represents a vector of this type. If one argument is given, it is the inclusive upper bound of the vector; in this case the lower bound is zero. If two arguments are given, the first argument is the lower bound of the vector, and the second argument is the upper bound of the vector. A vector's length must not be negative, but the bounds can be.
The difference between an array and a vector is that arrays behave like in C: when used in expressions they decay to a pointer to the first element whereas vectors are treated as first class values.
— Function: Type.const () Return a new gdb.Type object which represents a const-qualified variant of this type.
— Function: Type.volatile () Return a new gdb.Type object which represents a volatile-qualified variant of this type.
— Function: Type.unqualified () Return a new gdb.Type object which represents an unqualified variant of this type. That is, the result is neither const nor volatile.
— Function: Type.range () Return a Python Tuple object that contains two elements: the low bound of the argument type and the high bound of that type. If the type does not have a range, gdb will raise a gdb.error exception (see Exception Handling).
— Function: Type.reference () Return a new gdb.Type object which represents a reference to this type.
— Function: Type.pointer () Return a new gdb.Type object which represents a pointer to this type.
— Function: Type.strip_typedefs () Return a new gdb.Type that represents the real type, after removing all layers of typedefs.
— Function: Type.target () Return a new gdb.Type object which represents the target type of this type.
For a pointer type, the target type is the type of the pointed-to object. For an array type (meaning C-like arrays), the target type is the type of the elements of the array. For a function or method type, the target type is the type of the return value. For a complex type, the target type is the type of the elements. For a typedef, the target type is the aliased type.
If the type does not have a target, this method will throw an exception.
— Function: Type.template_argument (n [, block]) If this gdb.Type is an instantiation of a template, this will return a new gdb.Value or gdb.Type which represents the value of the nth template argument (indexed starting at 0).
If this gdb.Type is not a template type, or if the type has fewer than n template arguments, this will throw an exception. Ordinarily, only C++ code will have template types.
If block is given, then name is looked up in that scope. Otherwise, it is searched for globally.
— Function: Type.optimized_out () Return gdb.Value instance of this type whose value is optimized out. This allows a frame decorator to indicate that the value of an argument or a local variable is not known.
Each type has a code, which indicates what category this type falls into. The available type categories are represented by constants defined in the gdb module:
gdb.TYPE_CODE_PTR The type is a pointer.
gdb.TYPE_CODE_ARRAY The type is an array.
gdb.TYPE_CODE_STRUCT The type is a structure.
gdb.TYPE_CODE_UNION The type is a union.
gdb.TYPE_CODE_ENUM The type is an enum.
gdb.TYPE_CODE_FLAGS A bit flags type, used for things such as status registers.
gdb.TYPE_CODE_FUNC The type is a function.
gdb.TYPE_CODE_INT The type is an integer type.
gdb.TYPE_CODE_FLT A floating point type.
gdb.TYPE_CODE_VOID The special type void.
gdb.TYPE_CODE_SET A Pascal set type.
gdb.TYPE_CODE_RANGE A range type, that is, an integer type with bounds.
gdb.TYPE_CODE_STRING A string type. Note that this is only used for certain languages with language-defined string types; C strings are not represented this way.
gdb.TYPE_CODE_BITSTRING A string of bits. It is deprecated.
gdb.TYPE_CODE_ERROR An unknown or erroneous type.
gdb.TYPE_CODE_METHOD A method type, as found in C++ or Java.
gdb.TYPE_CODE_METHODPTR A pointer-to-member-function.
gdb.TYPE_CODE_MEMBERPTR A pointer-to-member.
gdb.TYPE_CODE_REF A reference type.
gdb.TYPE_CODE_CHAR A character type.
gdb.TYPE_CODE_BOOL A boolean type.
gdb.TYPE_CODE_COMPLEX A complex float type.
gdb.TYPE_CODE_TYPEDEF A typedef to some other type.
gdb.TYPE_CODE_NAMESPACE A C++ namespace.
gdb.TYPE_CODE_DECFLOAT A decimal floating point type.
gdb.TYPE_CODE_INTERNAL_FUNCTION A function internal to gdb. This is the type used to represent convenience functions. Further support for types is provided in the gdb.types Python module (see gdb.types).
来源:https://sourceware.org/gdb/onlinedocs/gdb/Types-In-Python.html
相关:
关于python - 有没有办法通过给定的对象地址访问 gdb 中的 python 对象?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41628588/
关闭。这个问题是opinion-based 。目前不接受答案。 想要改进这个问题吗?更新问题,以便 editing this post 可以用事实和引文来回答它。 . 已关闭 4 年前。 Improv
PowerShell Web Access 允许您通过 Web 浏览器运行 PowerShell cmdlet。它显示了一个基于 Web 的控制台窗口。 有没有办法运行 cmdlet 而无需在控制台窗
我尝试在无需用户登录的情况下访问 Sharepoint 文件。 我可以通过以下任一方式获取访问 token 方法一: var client = new RestClient("https://logi
我目前正在尝试通过 Chrome 扩展程序访问 Google 服务。我的理解是,对于 JS 应用程序,Google 首选的身份验证机制是 OAuth。我的应用目前已成功通过 OAuth 向服务进行身份
假设我有纯抽象类 IHandler 和派生自它的类: class IHandler { public: virtual int process_input(char input) = 0; };
我有一个带有 ThymeLeaf 和 Dojo 的 Spring 应用程序,这给我带来了问题。当我从我的 HTML 文件中引用 CSS 文件时,它们在 Firebug 中显示为中止。但是,当我通过在地
这个问题已经有答案了: JavaScript property access: dot notation vs. brackets? (17 个回答) 已关闭 6 年前。 为什么这不起作用? func
我想将所有流量重定向到 https,只有 robot.txt 应该可以通过 http 访问。 是否可以为 robot.txt 文件创建异常(exception)? 我的 .htaccess 文件: R
我遇到了 LinkedIn OAuth2: "Unable to verify access token" 中描述的相同问题;但是,那里描述的解决方案并不能解决我的问题。 我能够成功请求访问 toke
问题 我有一个暴露给 *:8080 的 Docker 服务容器. 我无法通过 localhost:8080 访问容器. Chrome /curl无限期挂断。 但是如果我使用任何其他本地IP,我就可以访
我正在使用 Google 的 Oauth 2.0 来获取用户的 access_token,但我不知道如何将它与 imaplib 一起使用来访问收件箱。 最佳答案 下面是带有 oauth 2.0 的 I
我正在做 docker 入门指南:https://docs.docker.com/get-started/part3/#recap-and-cheat-sheet-optional docker-co
我正在尝试使用静态 IP 在 AKS 上创建一个 Web 应用程序,自然找到了一个带有 Nginx ingress controller in Azure's documentation 的解决方案。
这是我在名为 foo.js 的文件中的代码。 console.log('module.exports:', module.exports) console.log('module.id:', modu
我试图理解访问键。我读过https://docs.aws.amazon.com/general/latest/gr/aws-sec-cred-types.html#access-keys-and-se
我正在使用 MGTwitterEngine"将 twitter 集成到我的应用程序中。它在 iOS 4.2 上运行良好。当我尝试从任何 iOS 5 设备访问 twitter 时,我遇到了身份验证 to
我试图理解访问键。我读过https://docs.aws.amazon.com/general/latest/gr/aws-sec-cred-types.html#access-keys-and-se
我正在使用以下 API 列出我的 Facebook 好友。 https://graph.facebook.com/me/friends?access_token= ??? 我想知道访问 token 过
401 Unauthorized - Show headers - { "error": { "errors": [ { "domain": "global", "reas
我已经将我的 django 应用程序部署到 heroku 并使用 Amazon s3 存储桶存储静态文件,我发现从 s3 存储桶到 heroku 获取数据没有问题。但是,当我测试查看内容存储位置时,除
我是一名优秀的程序员,十分优秀!