Browse Source

Make trace actually useful

Alois Mahdal 9 years ago
parent
commit
cbbef9c7b1
1 changed files with 13 additions and 1 deletions
  1. 13
    1
      src/include/pretty.sh

+ 13
- 1
src/include/pretty.sh View File

@@ -348,8 +348,20 @@ _pretty__echo_trace() {
348 348
     # Print "decorated" call trace (only in debug mode)
349 349
     #
350 350
     $FFOO_DEBUG || return 0
351
+    local depth
351 352
     echo "== trace =="
352
-    caller | sed -e 's/^/-> /g'
353
+    for depth in $(seq 0 ${#FUNCNAME});
354
+    do
355
+        caller "$depth" || break
356
+    done \
357
+      | tail -n +3 \
358
+      | sed -e '
359
+            s/^\([^ ]\+\) \([^ ]\+\) \(.*\)/\3:\1:\2()/
360
+            #  ^line^,    ^func^,    ^file^
361
+            1   s/^/ -> /g
362
+            2,$ s/^/    /
363
+        ' \
364
+      | tac
353 365
 }
354 366
 
355 367