Does anyone know of an easy way to interact with performance monitor counters in Linux? I've been reading stuff by Brendan Gregg about DTrace and the importance of PMCs, and it made it sound like Linux doesn't have the equivalent.
Yes, this is what "perf stat <command>" does. Add more -d options to see more counters, or use -e to ask for specific counter(s) ("perf list" to list them).
Another nice tool is likwid. It lets you select a performance counter group (e.g. L3 CACHE) to monitor while running a program. It also provides derived metrics.
>"When the processor executes the int 3 instruction, control is passed to the breakpoint interrupt handler, which – in the case of Linux – signals the process with a SIGTRAP. You can see this process in the diagram below, where we overwrite the first byte of the mov instruction with 0xcc,"
0xCC is not 3 in decimal however it is 204. AM I missing something or is the actual number 3 obscured in the encoding somewhere?
0xCC is a special opcode for the assembly instruction "INT 3" (trigger interrupt number 3), for exactly this use case of providing an 1-byte opcode for debuggers.
Leave them to complex lambdas declarations or template meta-programming.