Debugger program example for initialization program

The following example illustrates how to look at the performance monitor data while the program is executing.

from a debugger at breakpoint (1)

       pm_initialize(filter);
(2)    pm_get_program_pthread(pid, tid, ptid, &prog);
       ... display PM programmation ...

(3)    pm_get_data_pthread(pid, tid, ptid);
       ... display PM data ...

       pm_delete_program_pthread(pid, tid, ptid);
       prog.events[0] = 2; /* change counter 1 to count event number 2 */
       pm_set_program_pthread(pid, tid, ptid, &prog);

continue program

The preceding scenario would also work if the program being executed under the debugger did not have any embedded Performance Monitor API calls. The only difference would be that the calls at (2) and (3) would fail, and that when the program continues, it will be counting only event number 2 in counter 1, and nothing in other counters.