Mirror of the lttng-dev mailing list
 help / color / mirror / Atom feed
From: Gunnar.Strand@ericsson.com (Gunnar Strand)
Subject: [lttng-dev] Bug in lttng-ust tool lttng-gen-tp which replaces all ".c" with ".h" in the path
Date: Tue, 19 Sep 2017 05:35:08 +0200	[thread overview]
Message-ID: <33a474df-f79d-01f4-7654-8adb5d1148ac@ericsson.com> (raw)
In-Reply-To: <20170918162747.tdbrpxopqxlv3jbo@psrcode-TP-X230>

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 2113 bytes --]

Hi,

On 09/18/17 18:27, Jonathan Rajotte-Julien wrote:
> Hi,
>
> On Mon, Sep 18, 2017 at 11:47:28AM +0200, Gunnar Strand wrote:
>> Hi,
>>
>> It does not seem like anonymous bug reporting is supported, so I am
>> submitting the report here instead.
>>
>> I found the following bug in the tools/lttng-gen-tp tool in the lttng-ust
>> component, which is present in the latest commit on master,
>> d0f6cf574ef992620b09c183cb3a0ea771070ea5:
>>
>>   66 class CFile:
>> ...
>>   79     def write(self):
>>   80         outputFile = open(self.outputFilename,"w")
>>   81
>>   82         headerFilename = self.outputFilename.replace(".c",".h")
>>
> I agree with you here. Still, based on basic testing on my side passing a path as
> a template/-o arguments (e.g absolute path) yield more problems [1] than only this replacement.
>
> There is also another occurrence of a buggy replacement on line 129:
>
> def write(self):
> 	cFilename = self.outputFilename.replace(".o",".c")
> 	cc = self._detectCC()
>          if cc == "":
>
> Could you give me the exact command you are using?
>
> [1] The header template use a relative path for inclusion passing an absolute
> path for any parameters will end up in a compilation error for most use-case.

Yes, an absolute path is passed to the command, and in this case and
that is how the issue got exposed for us. We have a workaround in place,
but using relative paths would be the better solution, thanks.

BR
Gunnar


>
> Cheers
>
>> Line 82 replaces all occurrences of ".c" with ".h" which breaks compilation
>> if the path to the source contains ".c" anywhere, eg.:
>> /path/to/my.cigar/source/...
>>
>> Only the last occurrence should be replaced, eg.:
>>
>> if self.outputFilename.endswith(".c"):
>>
>>      headerFilename = self.outputFilename[:-2] + ".h"
>>
>> Or just the second line if the code can assume that the string has a ".c"
>> suffix.
>>
>> BR
>>
>> Gunnar
>>
>> _______________________________________________
>> lttng-dev mailing list
>> lttng-dev at lists.lttng.org
>> https://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev



           reply	other threads:[~2017-09-19  3:35 UTC|newest]

Thread overview: expand[flat|nested]  mbox.gz  Atom feed
 [parent not found: <20170918162747.tdbrpxopqxlv3jbo@psrcode-TP-X230>]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=33a474df-f79d-01f4-7654-8adb5d1148ac@ericsson.com \
    --to=gunnar.strand@ericsson.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox