[PATCH] record: Add support for interrupt handlers

Chris Johns chrisj at rtems.org
Wed Sep 4 22:28:12 UTC 2019


On 4/9/19 9:46 pm, Sebastian Huber wrote:
> On 04/09/2019 08:06, Chris Johns wrote:
>>> +void LTTNGClient::WriteIRQHandlerExit(PerCPUContext* pcpu, const ClientItem&
>>> item) {
>>> +  pcpu->content_size += kEventIRQHandlerExitBits;
>>> +  pcpu->packet_size += kEventIRQHandlerExitBits;
>>> +
>>> +  EventIRQHandlerExit& ih = pcpu->irq_handler_exit;
>>> +  ih.header.ns = item.ns;
>>> +  ih.irq = static_cast<int32_t>(item.data);
>>> +  fwrite(&ih, sizeof(ih), 1, pcpu->event_stream);
>> https://en.cppreference.com/w/cpp/io  :)
> 
> I had a look a this, it seems the error reporting capabilities of <fstream> are
> quite bad (nothing like strerror(errno)).

Interesting point to make given the return code from `fwrite` is not checked. :)
Also it should be `std::fwrite`.

I did not know `std::fwrite` was documented in the C++ interface, well it is on
cppreference.com.

Further down in this file `std::cerr` is used to report errors which is great so
this is a mix of C and C++ and why I posted the link. I would like to avoid the
cases that exist in covoar where `fprintf(stderr, ...)` is used to print errors.
I see this as C programming in C++.

> A C++ alternative would be:
> 
> https://www.boost.org/doc/libs/1_70_0/libs/filesystem/doc/index.htm

We have discussed boost and my position has not changed.

Chris




More information about the devel mailing list