Bug 13272 - printf "quoting" broken
Summary: printf "quoting" broken
Status: RESOLVED FIXED
Alias: None
Product: systemtap
Classification: Unclassified
Component: translator (show other bugs)
Version: unspecified
: P2 normal
Target Milestone: ---
Assignee: Josh Stone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-10-07 12:48 UTC by Mark Wielaard
Modified: 2011-10-07 17:18 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Mark Wielaard 2011-10-07 12:48:52 UTC
Since the new PR3217: Compiled printf support went in the following is broken:

$ stap -e 'probe begin { printf("\"quote\\this\"\n"); exit(); }'
"quote\this"

Now results in:

$ /usr/local/install/systemtap/bin/stap -e 'probe begin { printf("\"quote\\this\"\n"); exit(); }'
/tmp/staprnCOab/stap_b365e1c33dd4dbc9188f04b4ec90e45b_817.c: In function ‘probe_1989’:
/tmp/staprnCOab/stap_b365e1c33dd4dbc9188f04b4ec90e45b_817.c:104:21: error: expected ‘)’ before ‘quote’
/tmp/staprnCOab/stap_b365e1c33dd4dbc9188f04b4ec90e45b_817.c:104:21: error: stray ‘\’ in program
/tmp/staprnCOab/stap_b365e1c33dd4dbc9188f04b4ec90e45b_817.c:104:21: error: stray ‘\’ in program
make[1]: *** [/tmp/staprnCOab/stap_b365e1c33dd4dbc9188f04b4ec90e45b_817.o] Error 1
make: *** [_module_/tmp/staprnCOab] Error 2
Warning: make exited with status: 2
Pass 4: compilation failed.  Try again with another '--vp 0001' option.

This can also be seen in the buildok.exo testsuite:
FAIL: buildok/printf.stp
Comment 1 Josh Stone 2011-10-07 17:18:23 UTC
commit 1386d8fc1a768df68e830e4af8482cdf060612a1
Author: Josh Stone <jistone@redhat.com>
Date:   Fri Oct 7 09:48:43 2011 -0700

    PR13272: Fix quoted strings in the printf shortcut path
    
    For printf strings with no arguments, we usually skip all the printf
    path altogether and just use _stp_print.  However, the compiled-printf
    changes affected the level of string escaping, which broke for a case
    like printf("\"quote\\this\"\n").  We must make sure that this shortcut
    path uses an output-quoted string literal.
    
    * translate.cxx (c_unparser::visit_print_format): Generate an output-
      quoted format_string too, for use by the _stp_print shortcut.
      (preprocess_print_format): The "%s\n" case shouldn't alter components.
    * testsuite/buildok/printf.stp: Add "%s" and "%s\n" shortcut tests too.