Obtaining trace from QEMU MBR disk image¶
Let $TRACE_DIR be a destination directory of CTF trace on host. Let
/my_trace be the location of recorded trace on QEMU disk image (collected,
e.g. via perf -m trace -o /my_trace)
The manual way¶
Find out the disk sector size and rootfs partition start (here, start=4096, sector size=512):
fdisk -l $PRTOS_PROJECT/_boot/ia32-generic-qemu/hd0.disk
user $ fdisk -l $PRTOS_PROJECT/_boot/ia32-generic-qemu/hd0.diskDisk _boot/ia32-generic-qemu/hd0.disk: 128 MiB, 134217728 bytes, 262144 sectorsUnits: sectors of 1 * 512 = 512 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal): 512 bytes / 512 bytesDisklabel type: dosDisk identifier: 0x00000000Device Boot Start End Sectors Size Id Type_boot/ia32-generic-qemu/hd0.disk1 * 4096 262143 258048 126M 83 LinuxMount the QEMU image:
mount -o loop,offset=$((4096*512)) _boot/ia32-generic-qemu/hd0.disk /mnt
root # mount -o loop,offset=$((4096*512)) _boot/ia32-generic-qemu/hd0.disk /mntCopy the recorded trace directory to host destination directory:
cp /mnt/my_trace $TRACE_DIR
user $ cp /mnt/my_trace $TRACE_DIRProceed to Step 3: invoke convert.sh.
The automated way using rootfs_convert.sh¶
rootfs_convert.sh is an end-user script that does the above steps but uses
parted instead (as it is more script-friendly), invokes convert.sh
automatically and outputs a ready to view perfetto trace. Invoke
cd $PRTOS_PROJECT/phoenix-rtos-hostutils/trace ./rootfs_convert.sh ../../_boot/ia32-generic-qemu/hd0.disk /my_trace ../../phoenix-rtos-kernel/perf/tsdl/metadata out.pftrace
user $ cd $PRTOS_PROJECT/phoenix-rtos-hostutils/trace
user $ ./rootfs_convert.sh ../../_boot/ia32-generic-qemu/hd0.disk /my_trace ../../phoenix-rtos-kernel/perf/tsdl/metadata out.pftrace