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>
We may get normal IPv4 address print like 10.10.0.1:5001 and a longer
IPv6 like fc000000000000000000000000000001:5001
Signed-off-by: Zhe Weng <wengzhe@xiaomi.com>
Tested for:
dq: &g_notifier_pending in both good and bad state (tail goes wrong)
sq: &g_sigfreeaction in good state
Signed-off-by: Zhe Weng <wengzhe@xiaomi.com>
Now the dmesg output log in correct time order, from oldest to latest.
The NULL strings are also stripped, if the buffer is never get fully
filled.
Signed-off-by: xuxingliang <xuxingliang@xiaomi.com>
GDB uses remote-register to describe g/G packet. Whatever the target is,
we can always find out the register offset in packet by `maint print
remote-registers`.
In NuttX, we follow the same standard to prepare the packet, in both
coredump and GDB stub.
For example, the CPSR for arm-v7a is at register number of 25, byte
offset of 164. So we define the CPSR in g_reg_offs (164 /4 = 41)th
elementent.
If GDB stub supports qXfer feature, then GDB will ask stub for target
descriptor, which is a standard xml file. If this file is provided, then
the register order is also changed. It's also reflected in 'maint print
remote-registers' output. JLink GDB server supports it for example.
We always use manually added second inferiort to query the original
remote register layout. So it can match with tcbinfo.
Signed-off-by: xuxingliang <xuxingliang@xiaomi.com>
Make sure elf exists before registering our commands. If no elf at the moment, register event to GDB to get notified when user adds the first object file.
Signed-off-by: xuxingliang <xuxingliang@xiaomi.com>
For LTO optimization, we may not be able to parse the macro value. Parse .debug_macro section from elf manually.
Signed-off-by: xuxingliang <xuxingliang@xiaomi.com>
In devices without storage media, you can export data to the
command line and then generate the corresponding gcda file
It can save the result output by calling __gcov_info_to_gcda
The usage is similar to:
https://gcc.gnu.org/onlinedocs/gcc/Freestanding-Environments.html#Profiling-and-Test-Coverage-in-Freestanding-Environments
Usage:
./tools/configure.sh qemu-armv7a:nsh
Modify the configuration
+CONFIG_COVERAGE_ALL=y
+CONFIG_COVERAGE_MINI=y
+CONFIG_SYSTEM_GCOV=y
Run:
qemu-system-arm -cpu cortex-a7 -nographic -smp 4 \
-machine virt,virtualization=off,gic-version=2 \
-net none -chardev stdio,id=con,mux=on -serial chardev:con \
-mon chardev=con,mode=readline -kernel ./nuttx/nuttx -semihosting -s | tee gcov.txt
./nuttx/tools/gcov_convert.py -i ./gcov.txt
./nuttx/tools/gcov.sh -t arm-none-eabi-gcov
Signed-off-by: yinshengkai <yinshengkai@xiaomi.com>