Author Topic: Linux tool (besides strace) for debugging code using epoll/timerfd?  (Read 390 times)

0 Members and 1 Guest are viewing this topic.

Offline berkeTopic starter

  • Frequent Contributor
  • **
  • Posts: 258
  • Country: fr
  • F4WCO
Hi,

I have some single-threaded code that uses sockets, timer FDs and usbdevfs, and I'm using epoll for event notification.  I even have epolls watching other epolls.

Is there anything better than reading strace logs manually (see extract below) and keeping track of FDs and flags using pen and paper to see what's going on?

Code: [Select]
1862  write(2, "[2022-08-07T16:11:09.386Z DEBUG xxx::pax] Number of interfaces: 1\n", 77) = 77
1862  write(2, "[2022-08-07T16:11:09.386Z DEBUG xxx::pax] Bulk endpoint addresses: input 0x81, output 0x01\n", 102) = 102
1862  epoll_create1(0)                  = 9
1862  fcntl(8, F_SETFL, O_RDONLY|O_NONBLOCK|O_LARGEFILE) = 0
1862  epoll_ctl(9, EPOLL_CTL_ADD, 8, {EPOLLERR, {u32=8, u64=8}}) = 0
1862  timerfd_create(CLOCK_MONOTONIC, 0) = 10
1862  epoll_ctl(9, EPOLL_CTL_ADD, 10, {EPOLLIN, {u32=10, u64=10}}) = 0
1862  write(2, "[2022-08-07T16:11:09.386Z DEBUG xxx::rate_controller] New interval: 0.0001 s\n", 88) = 88
1862  timerfd_settime(10, 0, {it_interval={tv_sec=0, tv_nsec=100000}, it_value={tv_sec=0, tv_nsec=100000}}, NULL) = 0
1862  munmap(0x7fc76ce63000, 4096)      = 0
1862  munmap(0x7fc76ce50000, 4096)      = 0
1862  munmap(0x7fc76ce16000, 4096)      = 0
1862  munmap(0x7fc76cdbd000, 4096)      = 0
1862  munmap(0x7fc76cda9000, 4096)      = 0
1862  munmap(0x7fc76cd95000, 8192)      = 0
1862  epoll_ctl(6, EPOLL_CTL_ADD, 9, {EPOLLIN, {u32=9, u64=9}}) = 0
1862  epoll_pwait(7, [{EPOLLIN, {u32=3, u64=3}}], 32, 1000, NULL, 8) = 1
1862  write(2, "[2022-08-07T16:11:09.963Z TRACE xxx::event_loop] Events: [EpollEvent { event: epoll_event { events: 1, u64: 3 }
 }]\n", 126) = 126
1862  write(2, "[2022-08-07T16:11:09.963Z TRACE xxx::event_loop] Event status: EventStatus { server_epoll: true, pax_epoll: fal
se }\n", 127) = 127
1862  epoll_pwait(3, [{EPOLLIN, {u32=5, u64=5}}], 32, 0, NULL, 8) = 1
1862  write(2, "[2022-08-07T16:11:09.963Z TRACE xxx::server] Server events: [EpollEvent { event: epoll_event { events: 1, u64:
5 } }], connections: 0\n", 145) = 145
 

Offline berkeTopic starter

  • Frequent Contributor
  • **
  • Posts: 258
  • Country: fr
  • F4WCO
Re: Linux tool (besides strace) for debugging code using epoll/timerfd?
« Reply #1 on: February 23, 2024, 05:05:14 pm »
I haven't found any tool that explicitly does this, however /proc/*/fdinfo pseudo-files give information about epoll and timer FDs.  For an epoll it looks like this
Code: [Select]
pos:    0
flags:  02
mnt_id: 15
ino:    54
tfd:        3 events:       19 data:                3  pos:0 ino:36 sdev:e
tfd:        8 events:       19 data:                8  pos:0 ino:36 sdev:e
and for a timer FD like this
Code: [Select]
pos:    0
flags:  02
mnt_id: 15
ino:    54
clockid: 1
ticks: 0
settime flags: 00
it_value: (0, 100692056)
it_interval: (0, 250000000)
I was able to figure things out this way.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf