Added __format__ method to support format spec like {:>10} that gdb.Value doesn't support. For such case, gdb.Value is converted to python value firstly and then format natively.
Override all methods/attributes could return gdb.Value to return utils.Value instead.
Signed-off-by: xuxingliang <xuxingliang@xiaomi.com>
Use a class Bactrace to support convert address to backtrace, format to string, accessing element and iterate though them.
Adjust usage in fs and addr2line to make full use of it.
Signed-off-by: xuxingliang <xuxingliang@xiaomi.com>
Add simple time command to test time cost of a command.
Usage:
(gdb) time memleak
...
(gdb) Time elapsed: 1.23456s
Signed-off-by: xuxingliang <xuxingliang@xiaomi.com>
1. Support any type of value as pointer address in container_of
2. Support string as type in offset_of
3. Make sure type is a pointer in container_of, and not a pointer in
offset_of
Signed-off-by: xuxingliang <xuxingliang@xiaomi.com>
We're using `ptr.cast(get_long_type())` a week ago to get the pointer's value, it's alright, but `ptr.address` is not, the `ptr.address` will return **the address of the pointer**.
These values are the address of first element in the queue:
- `int(g_sigfreeaction["head"])`
- `g_sigfreeaction["head"].cast(get_long_type())`
- `g_sigfreeaction["head"].dereference().address`
But:
`int(g_sigfreeaction["head"].address)` is the address of the "head" member, which equals to the address of `g_sigfreeaction`
It's happening in NxSQueue:
g_sigfreeaction = gdb.parse_and_eval("g_sigfreeaction")
print(["%x" % (node) for node in NxSQueue(g_sigfreeaction)])
print(["%x" % (node) for node in NxSQueue(g_sigfreeaction, "sigactq_t", "flink")])
Without this patch:
['f3c0aa10', 'f3c0aa2c', 'f3c0aa48']
['55db90a0', 'f3c0aa10', 'f3c0aa2c']
With this patch:
['f3c0aa10', 'f3c0aa2c', 'f3c0aa48']
['f3c0aa10', 'f3c0aa2c', 'f3c0aa48']
Signed-off-by: Zhe Weng <wengzhe@xiaomi.com>
After we introduced NxDQueue and NxSQueue, we're using them like `NxDQueue(g_active_connections, "struct socket_conn_s", "node")` and leads to `utils.container_of(ptr, str, str)`, so maybe we need to allow str input for `utils.container_of`
Signed-off-by: Zhe Weng <wengzhe@xiaomi.com>
Use json module to save macro info to json file and load directly. It can save 2seconds for x4b projects to load plugin
Signed-off-by: xuxingliang <xuxingliang@xiaomi.com>