On Tue, Sep 29, 2020 at 03:20:22PM +0200, Bartosz Golaszewski wrote: > On Mon, Sep 28, 2020 at 3:42 PM Kent Gibson <warthog618@xxxxxxxxx> wrote: > > > > On Tue, Sep 22, 2020 at 11:50:51AM +0200, Bartosz Golaszewski wrote: > > > On Tue, Sep 22, 2020 at 9:41 AM Arnd Bergmann <arnd@xxxxxxxx> wrote: > > > > > > > > On Tue, Sep 22, 2020 at 4:34 AM Kent Gibson <warthog618@xxxxxxxxx> wrote: > > > > > +/** > > > > > > > > Having different-sized members in the union makes it hard for > > > > something like strace to print the contents. How about just making > > > > them all __aligned_u64 even when 32 bits are sufficient? > > > > > > > > > > Ah yes, adding support for GPIO ioctl()'s to strace has been on my > > > TODO list for 3 years now. :( > > > > > > > I'm looking at doing this as it would be useful to have. > > > > Just starting with the v1 uAPI, as v2 isn't merged yet. > > > > I think I've got it basically done, but I thought I'd run it past you > > before sending a patch to the strace list. > > > > Successful calls currently look like this: > > > > ioctl(3, GPIO_GET_CHIPINFO_IOCTL, {name="gpiochip1", label="gpio-mockup-B", lines=8}) = 0 > > > > ioctl(3, GPIO_GET_LINEHANDLE_IOCTL, {lines=8, lineoffsets=[3, 2, 1, 0, 4, 5, 6, 7], flags=GPIOHANDLE_REQUEST_INPUT, default_values=[0, 0, 0, 0, 0, 0, 0, 0], consumer_label="", fd=7}) = 0 > > > > ioctl(0, GPIO_GET_LINEEVENT_IOCTL, {lineoffset=2, handleflags=GPIOHANDLE_REQUEST_INPUT, eventflags=GPIOEVENT_REQUEST_BOTH_EDGES, consumer_label="high to low", fd=3}) = 0 > > > > ioctl(3, GPIO_GET_LINEINFO_IOCTL, {line_offset=1, flags=GPIOLINE_FLAG_KERNEL|GPIOLINE_FLAG_IS_OUT, name="gpio-mockup-A-1", consumer="output atv-lo to as-is atv-hi"}) = 0 > > > > ioctl(7, GPIOHANDLE_GET_LINE_VALUES_IOCTL, {values=[1, 1, 0, 1, 1, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ...]}) = 0 > > > > ioctl(7, GPIOHANDLE_SET_LINE_VALUES_IOCTL, {values=[1, 1, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ...]}) = 0 > > > > ioctl(7, GPIOHANDLE_SET_CONFIG_IOCTL, {flags=GPIOHANDLE_REQUEST_ACTIVE_LOW, default_values=[0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ...]}) = 0 > > > > ioctl(3, GPIO_GET_LINEINFO_WATCH_IOCTL, {line_offset=3, flags=0, name="gpio-mockup-A-3", consumer=""}) = 0 > > > > ioctl(3, GPIO_GET_LINEINFO_UNWATCH_IOCTL, {offset=3}) = 0 > > > > For unsuccessful calls it only prints the input fields, and drops the > > output fields. e.g. > > > > ioctl(3, GPIO_GET_LINEINFO_WATCH_IOCTL, {line_offset=3}) = -1 EPERM (Operation not permitted) > > > > Does that work for you? > > > > Kent, > > This is perfect! Thanks for doing this! For the error cases: I'm not > sure how strace handles this for other ioctls() - maybe we could print > something like 'flags=N/A'? Unless what you did is the standard way, > then leave it. > I think that is pretty standard, but I will double check. Just debugging the uAPI v2 decoding now, though I wont submit that until the uAPI is in an -rc. It may be useful for debugging in the meantime, so I'll push a copy to my github fork[1] shortly - the v1 decoding is there already. I've noticed a few things I want to tidy up in the v1 decoding before I submit that though. Should have it ready to submit in the next few days. Cheers, Kent. [1] https://github.com/warthog618/strace/tree/gpio