Read about our upcoming Code of Conduct on this issue

Commit afe48a33 authored by alex@thinkpad's avatar alex@thinkpad
Browse files

QEMU logging: attempt to identify tail calls by default

(-d calls,notail to disable)

--HG--
branch : qemu
parent f9802bfe5e99
......@@ -62,7 +62,7 @@ What works:
- log hardware devices: ``-d mpu/sflash/sdcf/uart/int``
- log all debug messages from Canon: ``-d debugmsg``
- log all memory accesses: ``-d rom/ram/romr/ramw/etc``
- log all function calls: ``-d calls``, ``-d calls,tail``
- log all function calls: ``-d calls``
- log all DryOS/VxWorks task switches: ``-d tasks``
- track all function calls to provide a stack trace: ``-d callstack``
- export all called functions to IDC script: ``-d idc``
......@@ -890,17 +890,11 @@ Memory access trace (ROM reads, RAM writes) — very verbose:
./run_canon_fw.sh 60D,firmware="boot=0" -d romr,ramw
Call/return trace (not including tail function calls):
Call/return trace, redirected to a log file:
.. code:: shell
./run_canon_fw.sh 60D,firmware="boot=0" -d calls
Also with tail calls, redirected to a log file:
.. code:: shell
./run_canon_fw.sh 60D,firmware="boot=0" -d calls,tail &> calls.log
./run_canon_fw.sh 60D,firmware="boot=0" -d calls &> calls.log
Tip: set your editor to highlight the log file as if it were Python code.
You'll get collapse markers for free :)
......@@ -909,7 +903,7 @@ Also with debug messages, I/O events and interrupts, redirected to file
.. code:: shell
./run_canon_fw.sh 60D,firmware="boot=0" -d debugmsg,calls,tail,io,int &> full.log
./run_canon_fw.sh 60D,firmware="boot=0" -d debugmsg,calls,io,int &> full.log
Filter the logs with grep:
......@@ -1011,7 +1005,7 @@ Printing call stack from GDB
The ``callstack`` option from QEMU (``eos/dbi/logging.c``) can be very useful to find where a function was called from.
This works even when gdb's ``backtrace`` command cannot figure it out from the stack contents, does not require any debugging symbols,
but you need to run the emulation with instrumentation enabled: ``-d callstack`` or ``-d callstack,tail``.
but you need to run the emulation with instrumentation enabled: ``-d callstack``.
Then, in GDB, use ``print_current_location_with_callstack`` to see the call stack for the current DryOS task.
......@@ -1083,7 +1077,7 @@ The instrumentation framework provides the following features:
- log all debug messages from Canon: ``-d debugmsg``
- log all memory accesses: ``-d rom/ram/romr/ramw/etc``
- log all function calls: ``-d calls``, ``-d calls,tail``
- log all function calls: ``-d calls``
- log all DryOS/VxWorks task switches: ``-d tasks``
- track all function calls to provide a stack trace: ``-d callstack``
- export all called functions to IDC script: ``-d idc``
......
......@@ -1501,10 +1501,10 @@ recheck:
/* assume tail call
* fixme: in IDC, these must be defined before their caller,
* as IDA frequently gets them wrong */
if (qemu_loglevel_mask(EOS_LOG_TAIL_CALLS)) {
if (!qemu_loglevel_mask(EOS_LOG_NO_TAIL_CALLS)) {
goto function_call;
}
/* without -d tail, report as jump */
/* with -d notail, report as jump */
}
else
{
......@@ -1523,8 +1523,8 @@ recheck:
* note: most cases appear to be valid tail calls,
* but not identified properly because of
* a missed function call right before this */
if (qemu_loglevel_mask(EOS_LOG_TAIL_CALLS)) {
/* note: many warnings without -d tail */
if (!qemu_loglevel_mask(EOS_LOG_NO_TAIL_CALLS)) {
/* note: many warnings with -d notail */
/* there's also a false warning at first jump */
if (!(id == 0x7F && call_stack_num[id] == 0))
{
......@@ -1539,7 +1539,7 @@ recheck:
if (abs((int)pc - (int)prev_pc) > 0x100)
{
goto function_call;
/* without -d tail, report as jump */
/* with -d notail, report as jump */
}
}
}
......
......@@ -188,7 +188,7 @@ index 0010c44..d85cc6b 100644
}
diff --git a/include/qemu/log.h b/include/qemu/log.h
index 362cbc4..fa5748d 100644
index 362cbc4..7859c5f 100644
--- a/include/qemu/log.h
+++ b/include/qemu/log.h
@@ -12,7 +12,7 @@
......@@ -243,7 +243,7 @@ index 362cbc4..fa5748d 100644
+#define EOS_LOG_RAM_TSKMEM (1LL << 55) /* check task memory ownership assumptions */
+#define EOS_LOG_RAM_SEMCHK (1LL << 56) /* check semaphore usage (like helgrind) */
+#define EOS_LOG_ROMCPY (1LL << 57) /* find memory blocks copied from ROM to RAM */
+#define EOS_LOG_TAIL_CALLS (1LL << 58) /* attempt to identify tail calls */
+#define EOS_LOG_NO_TAIL_CALLS (1LL << 58) /* don't attempt to identify tail calls */
+
/* Returns true if a bit is set in the current loglevel mask
*/
......@@ -324,7 +324,7 @@ index e193658..9de7251 100644
subregion->priority = 0;
memory_region_add_subregion_common(mr, offset, subregion);
diff --git a/qemu-log.c b/qemu-log.c
index 7cb01a8..61583ba 100644
index 7cb01a8..7b57b2e 100644
--- a/qemu-log.c
+++ b/qemu-log.c
@@ -22,7 +22,7 @@
......@@ -409,8 +409,8 @@ index 7cb01a8..61583ba 100644
+ "EOS: reconstruct call stack (implies nochain,singlestep)" },
+ { EOS_LOG_CALLS | EOS_LOG_CALLSTACK | CPU_LOG_TB_NOCHAIN | EOS_LOG_RAM_R, "calls",
+ "EOS: log function calls (implies callstack,nochain,singlestep; monitors RAM reads)" },
+ { EOS_LOG_TAIL_CALLS, "tail",
+ "EOS: identify tail calls (heuristic; to be used with calls or callstack)" },
+ { EOS_LOG_NO_TAIL_CALLS, "notail",
+ "EOS: don't identify tail calls (for troubleshooting)" },
+ { EOS_LOG_IDC | EOS_LOG_CALLSTACK | CPU_LOG_TB_NOCHAIN, "idc",
+ "EOS: export called functions to IDA (implies callstack,nochain,singlestep)" },
+ { EOS_LOG_TASKS, "tasks",
......
......@@ -559,7 +559,7 @@ function test_calls_main {
# fixme: execution under gdb is not deterministic, even with -icount
# ansi2txt used here (only once) because it's very slow
./run_canon_fw.sh $CAM,firmware="boot=0" -snapshot -icount 5 \
-display none -d calls,idc,tasks \
-display none -d calls,notail,idc,tasks \
-serial file:tests/$CAM/$TEST-uart.log \
|& ansi2txt > tests/$CAM/$TEST-raw.log &
......@@ -710,7 +710,7 @@ function test_calls_from {
# log all function calls/returns and export to IDC
./run_canon_fw.sh $CAM,firmware="boot=1" -snapshot \
-display none -d calls,idc \
-display none -d calls,notail,idc \
-serial file:tests/$CAM/$TEST-uart.log \
&> tests/$CAM/$TEST-raw.log &
......@@ -1244,13 +1244,13 @@ function test_calls_cstack {
if [ -f $CAM/patches.gdb ]; then
(
./run_canon_fw.sh $CAM,firmware="boot=0" -snapshot \
-display none -d calls,tasks,debugmsg,v -S -gdb tcp::$GDB_PORT \
-display none -d calls,notail,tasks,debugmsg,v -S -gdb tcp::$GDB_PORT \
-serial file:tests/$CAM/$TEST-uart.log &
arm-none-eabi-gdb -ex "set \$TCP_PORT=$GDB_PORT" -x $CAM/patches.gdb -ex quit &
) &> tests/$CAM/$TEST-raw.log
else
./run_canon_fw.sh $CAM,firmware="boot=0" -snapshot \
-display none -d calls,tasks,debugmsg,v \
-display none -d calls,notail,tasks,debugmsg,v \
-serial file:tests/$CAM/calls-cstack-uart.log \
&> tests/$CAM/$TEST-raw.log &
fi
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment