Closed Bug 517633 Opened 15 years ago Closed 15 years ago

TM: debug print function that can be called on trace

Categories

(Core :: JavaScript Engine, enhancement)

enhancement
Not set
normal

Tracking

()

RESOLVED FIXED
Tracking Status
status1.9.2 --- beta1-fixed

People

(Reporter: dmandelin, Assigned: dmandelin)

Details

(Whiteboard: fixed-in-tracemonkey)

Attachments

(1 file, 1 obsolete file)

Attached patch WIP (obsolete) — Splinter Review
Every subsystem, no matter how recondite, should have a printf. We have lived for too long without one in TM, or at least I have. This patch adds a method to TraceRecorder that can be called like this:

    tprint("arguments[%u] -> %a", index_ins, v_ins);

The trace will then print to stderr something like this:

    arguments[1] -> [0:12 0x0:0xc 12.000]

Supported format string codes in this first cut are:

    a    print in int, hex, and float format (print "all" decodings)
    d    as printf
    u    as printf
    x    as printf
    f    as printf "lf"
    S    as printf "s"
    s    print as a JS string, with '\x0101'-type stuff for non-ascii
    o    dump using js_DumpObject

For now, I just support calling with 2 replacement args, but that's just because I don't want to bother with the boilerplate until things are a little more firmed up.

It might also be interesting to add format codes for:

    - interpreter data like 'pc'. This is just for convenience because you
      can do it with tprint("%d", cx->fp->regs->pc).

    - machine state like a register value, especially %eip. That would require
      a little more cooperation from nanojit and I'm not immediately sure how
      to do it.
Attached patch PatchSplinter Review
Same as the WIP, I just added support for 0-6 args and picked up a formatting suggestion from brendan.
Attachment #401591 - Attachment is obsolete: true
Attachment #402180 - Flags: review?(lw)
Comment on attachment 402180 [details] [diff] [review]
Patch

This looks way useful, sweet!

>+        case 'S':
>+            GET_ARG();
>+            fprintf(out, "%s", (char *) u.i.lo);

r+ with s/u.i.lo/u.o/.
Attachment #402180 - Flags: review?(lw) → review+
Pushed to TM with fix as 52f9dd8f186a.
Status: NEW → ASSIGNED
Whiteboard: fixed-in-tracemonkey
JS_DEFINE_CALLINFO_3(extern, BOOL, PrintOnTrace, CHARPTR, UINT32, DOUBLEPTR, 0, 0);

../jstracer.cpp: At global scope:
../jstracer.cpp:755: error: extra ‘;’

Fails to compile here. I'll fix.
Fixed with:

http://hg.mozilla.org/tracemonkey/rev/3f86c93729d6

Also, I am now seeing, but don't know how to fix in a spec-conformant way, these two. You can figure that part out :)

../jstracer.cpp:700: warning: ISO C++ does not support the ‘%lf’ printf format
../jstracer.cpp:716: warning: ISO C++ does not support the ‘%lf’ printf format
(In reply to comment #5)
> Fixed with:
> 
> http://hg.mozilla.org/tracemonkey/rev/3f86c93729d6
> 
> Also, I am now seeing, but don't know how to fix in a spec-conformant way,
> these two. You can figure that part out :)
> 
> ../jstracer.cpp:700: warning: ISO C++ does not support the ‘%lf’ printf format
> ../jstracer.cpp:716: warning: ISO C++ does not support the ‘%lf’ printf format

%lf is just bogus, apparently. I need to switch to a better brand of crack. Fixed by 89b3653bed42.
http://hg.mozilla.org/mozilla-central/rev/52f9dd8f186a
Status: ASSIGNED → RESOLVED
Closed: 15 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: