TIL - Today I learned
=====================

Little factoids I've learned today.

Entries are ordered from most to least recent, in an "endless file".
Each entry is introduced by the output of: date +'= %F, %A ='

= 2022-11-14, Monday =

You can request the collected latency statistics from a running ping(1)
process by sending it a SIGQUIT signal. (linux)

= 2022-11-13, Sunday =

Useful strace(1) options (linux)

The -e flag can be used for a variety of things:

- To filter the systemcall.  It supports classe of syscalls, e.g.
  `strace -e %file x` is equivalent to
  `strace -e trace=open,stat,chmod,unlink,... x`.
  Hidden jems in the available classes.

- To dump the data of the read/write operations.

- To decode information about the file descriptors (e.g path of the files)
  (see also -y / -yy / -Y)

- To inject syscall behaviours.

The -c flag shows a table of statistics on invoked syscalls.

The -z/-Z flags filter successful and faulty syscalls respectively.

The -r/-T flags measure times between and within syscalls respectively.
Possibly useful for a rough performance assessment.

= 2022-11-08, Tuesday =

A few interesting flags for gcc, mentioned by a work
colleague during a discussion:

-fwhole-program:
  Assume that the current compilation unit represents the
  whole program being compiled. [...]

In short, it will turn every function to static (except for
main), so they can be optimized aggressively.

= 2022-11-08, Tuesday =

Hidden perls in the linker.

--wrap=symbol can be used to easily set mock any function
external to the module.  This is very useful for unit tests,
for example.

= 2022-10-23, Sunday =

The ptrace(2) call (linux), of which I heard of, but never studied before,
allows to trace a child process in the same way as a debugger would.

It can be used to do interesting things, such as dumping the
text of a binary one instruction at the time.

= 2022-01-26, Wednesday =

htobe32(3) - and friends.  I only knew htonl(3) - and friends.

I could not find a trivial extractor for Flattened Image Tree.  I
manually extracted the Flattened Device Tree into a C array, by
means of some shell-fu.  It turns out that the magic number of the
FDT is 0xd00dfeed (big endian).

See also (linux): byteorder(3) endian(3)
See also (freebsd): byteorder(3) byteorder(9)

= 2022-01-26, Wednesday =

Flattened Image Tree (FIT) is a file format based on device tree.
It allows to pack together multi-component images (such as kernel,
bootloaders and device trees) into a single file.

= 2022-01-26, Wednesday =

In Linux, it is possible to interpret a device tree by using the
reference material under Documentation/devicetree/bindings.