Am Di., 3. Juni 2025 um 19:56 Uhr schrieb Stefan Hajnoczi <stefa...@gmail.com>: > > On Tue, Jun 3, 2025 at 1:00 PM Oleg Tolmatcev <oleg.tolmat...@gmail.com> > wrote: > > > > Am Mo., 2. Juni 2025 um 20:45 Uhr schrieb Stefan Hajnoczi > > <stefa...@gmail.com>: > > > > > > > + try: > > > > + event_filename = os.path.relpath(event.filename) > > > > + except ValueError: > > > > + event_filename = event.filename > > > > + event_filename = PurePath(event_filename).as_posix() > > > > > > Please do this in one place to avoid code duplication in the backends. > > > Perhaps event.filename or a new field can hold the properly formatted > > > value so backends don't need to call relpath() themselves. > > > > I'll move the code to "tracetool/__init__.py". > > > > > I noticed that out_filename is also emitted with #line but, unlike > > > event.filename, no special processing (relpath() or as_posix()) is > > > used there. Is it possible to drop relpath() and avoid the whole > > > issue? > > > > "out_filename" is not a problem because it is a relative path in POSIX > > format. "relpath" was introduced in this commit > > 9d672e290475001fcecdcc9dc79ad088ff89d17f. I can not decide whether it > > should be dropped or not. > > out_filename is the last argument in sys.argv[] and Event.filename > comes from the previous arguments in sys.argv[]. > > Tracetool's sys.argv[] comes from trace/meson.build where the > trace-events filenames are built like this: > trace_events_file = meson.project_source_root() / item / 'trace-events' > > The output filename (sys.argv[-1]) happens to be built as a relative path: > fmt = '@0@-' + group_name + '.@1@' > ... > output: fmt.format('trace', 'h') > > It's inconsistent that out_filename is assumed to be a relative POSIX > filename whereas the trace-events filenames are made relative by the > code. > > I think it's more robust for tracetool to make filenames relative than > to assume whoever is invoking tracetool.py has already done that. It's > also easier for meson.build to be able to pass an absolute path if it > wants. > > That line of thinking results in the following: > 1. Add a posix_relpath() helper function to tracetool/__init__.py. > 2. Use posix_relpath() whenever a #line filename is required. > 3. Also use posix_relpath() on #line out_filename for consistency. > > How does that sound?
Sounds good. Oleg