@@ -239,11 +239,42 @@ int disasm_line__scnprintf(struct disasm_line *dl, char *bf, size_t size, bool r
239
239
size_t disasm__fprintf (struct list_head * head , FILE * fp );
240
240
void symbol__calc_percent (struct symbol * sym , struct evsel * evsel );
241
241
242
+ /**
243
+ * struct sym_hist - symbol histogram information for an event
244
+ *
245
+ * @nr_samples: Total number of samples.
246
+ * @period: Sum of sample periods.
247
+ */
242
248
struct sym_hist {
243
249
u64 nr_samples ;
244
250
u64 period ;
245
251
};
246
252
253
+ /**
254
+ * struct cyc_hist - (CPU) cycle histogram for a basic block
255
+ *
256
+ * @start: Start address of current block (if known).
257
+ * @cycles: Sum of cycles for the longest basic block.
258
+ * @cycles_aggr: Total cycles for this address.
259
+ * @cycles_max: Max cycles for this address.
260
+ * @cycles_min: Min cycles for this address.
261
+ * @cycles_spark: History of cycles for the longest basic block.
262
+ * @num: Number of samples for the longest basic block.
263
+ * @num_aggr: Total number of samples for this address.
264
+ * @have_start: Whether the current branch info has a start address.
265
+ * @reset: Number of resets due to a different start address.
266
+ *
267
+ * If sample has branch_stack and cycles info, it can construct basic blocks
268
+ * between two adjacent branches. It'd have start and end addresses but
269
+ * sometimes the start address may not be available. So the cycles are
270
+ * accounted at the end address. If multiple basic blocks end at the same
271
+ * address, it will take the longest one.
272
+ *
273
+ * The @start, @cycles, @cycles_spark and @num fields are used for the longest
274
+ * block only. Other fields are used for all cases.
275
+ *
276
+ * See __symbol__account_cycles().
277
+ */
247
278
struct cyc_hist {
248
279
u64 start ;
249
280
u64 cycles ;
@@ -258,18 +289,24 @@ struct cyc_hist {
258
289
u16 reset ;
259
290
};
260
291
261
- /** struct annotated_source - symbols with hits have this attached as in sannotation
292
+ /**
293
+ * struct annotated_source - symbols with hits have this attached as in annotation
262
294
*
263
- * @histograms: Array of addr hit histograms per event being monitored
264
- * nr_histograms: This may not be the same as evsel->evlist->core.nr_entries if
295
+ * @source: List head for annotated_line (embeded in disasm_line).
296
+ * @histograms: Array of symbol histograms per event to maintain the total number
297
+ * of samples and period.
298
+ * @nr_histograms: This may not be the same as evsel->evlist->core.nr_entries if
265
299
* we have more than a group in a evlist, where we will want
266
300
* to see each group separately, that is why symbol__annotate2()
267
301
* sets src->nr_histograms to evsel->nr_members.
268
- * @lines: If 'print_lines' is specified, per source code line percentages
269
- * @source: source parsed from a disassembler like objdump -dS
270
- * @cyc_hist: Average cycles per basic block
302
+ * @offsets: Array of annotation_line to be accessed by offset.
303
+ * @samples: Hash map of sym_hist_entry. Keyed by event index and offset in symbol.
304
+ * @nr_entries: Number of annotated_line in the source list.
305
+ * @nr_asm_entries: Number of annotated_line with actual asm instruction in the
306
+ * source list.
307
+ * @max_line_len: Maximum length of objdump output in an annotated_line.
271
308
*
272
- * lines is allocated, percentages calculated and all sorted by percentage
309
+ * disasm_lines are allocated, percentages calculated and all sorted by percentage
273
310
* when the annotation is about to be presented, so the percentages are for
274
311
* one of the entries in the histogram array, i.e. for the event/counter being
275
312
* presented. It is deallocated right after symbol__{tui,tty,etc}_annotate
@@ -286,6 +323,24 @@ struct annotated_source {
286
323
u16 max_line_len ;
287
324
};
288
325
326
+ /**
327
+ * struct annotated_branch - basic block and IPC information for a symbol.
328
+ *
329
+ * @hit_cycles: Total executed cycles.
330
+ * @hit_insn: Total number of instructions executed.
331
+ * @total_insn: Number of instructions in the function.
332
+ * @cover_insn: Number of distinct, actually executed instructions.
333
+ * @cycles_hist: Array of cyc_hist for each instruction.
334
+ * @max_coverage: Maximum number of covered basic block (used for block-range).
335
+ *
336
+ * This struct is used by two different codes when the sample has branch stack
337
+ * and cycles information. annotation__compute_ipc() calculates average IPC
338
+ * using @hit_insn / @hit_cycles. The actual coverage can be calculated using
339
+ * @cover_insn / @total_insn. The @cycles_hist can give IPC for each (longest)
340
+ * basic block ends at the given address.
341
+ * process_basic_block() calculates coverage of instructions (or basic blocks)
342
+ * in the function.
343
+ */
289
344
struct annotated_branch {
290
345
u64 hit_cycles ;
291
346
u64 hit_insn ;
0 commit comments