|
@@ -848,19 +848,23 @@ static int __symbol__inc_addr_samples(struct symbol *sym, struct map *map,
|
|
return 0;
|
|
return 0;
|
|
}
|
|
}
|
|
|
|
|
|
-static struct annotation *symbol__get_annotation(struct symbol *sym, bool cycles)
|
|
|
|
|
|
+static struct cyc_hist *symbol__cycles_hist(struct symbol *sym)
|
|
{
|
|
{
|
|
struct annotation *notes = symbol__annotation(sym);
|
|
struct annotation *notes = symbol__annotation(sym);
|
|
|
|
|
|
if (notes->src == NULL) {
|
|
if (notes->src == NULL) {
|
|
- if (symbol__alloc_hist(sym) < 0)
|
|
|
|
|
|
+ notes->src = annotated_source__new();
|
|
|
|
+ if (notes->src == NULL)
|
|
return NULL;
|
|
return NULL;
|
|
|
|
+ goto alloc_cycles_hist;
|
|
}
|
|
}
|
|
- if (!notes->src->cycles_hist && cycles) {
|
|
|
|
- if (symbol__alloc_hist_cycles(sym) < 0)
|
|
|
|
- return NULL;
|
|
|
|
|
|
+
|
|
|
|
+ if (!notes->src->cycles_hist) {
|
|
|
|
+alloc_cycles_hist:
|
|
|
|
+ symbol__alloc_hist_cycles(sym);
|
|
}
|
|
}
|
|
- return notes;
|
|
|
|
|
|
+
|
|
|
|
+ return notes->src->cycles_hist;
|
|
}
|
|
}
|
|
|
|
|
|
static struct annotated_source *symbol__hists(struct symbol *sym)
|
|
static struct annotated_source *symbol__hists(struct symbol *sym)
|
|
@@ -900,13 +904,13 @@ static int symbol__inc_addr_samples(struct symbol *sym, struct map *map,
|
|
static int symbol__account_cycles(u64 addr, u64 start,
|
|
static int symbol__account_cycles(u64 addr, u64 start,
|
|
struct symbol *sym, unsigned cycles)
|
|
struct symbol *sym, unsigned cycles)
|
|
{
|
|
{
|
|
- struct annotation *notes;
|
|
|
|
|
|
+ struct cyc_hist *cycles_hist;
|
|
unsigned offset;
|
|
unsigned offset;
|
|
|
|
|
|
if (sym == NULL)
|
|
if (sym == NULL)
|
|
return 0;
|
|
return 0;
|
|
- notes = symbol__get_annotation(sym, true);
|
|
|
|
- if (notes == NULL)
|
|
|
|
|
|
+ cycles_hist = symbol__cycles_hist(sym);
|
|
|
|
+ if (cycles_hist == NULL)
|
|
return -ENOMEM;
|
|
return -ENOMEM;
|
|
if (addr < sym->start || addr >= sym->end)
|
|
if (addr < sym->start || addr >= sym->end)
|
|
return -ERANGE;
|
|
return -ERANGE;
|
|
@@ -918,7 +922,7 @@ static int symbol__account_cycles(u64 addr, u64 start,
|
|
start = 0;
|
|
start = 0;
|
|
}
|
|
}
|
|
offset = addr - sym->start;
|
|
offset = addr - sym->start;
|
|
- return __symbol__account_cycles(notes->src->cycles_hist,
|
|
|
|
|
|
+ return __symbol__account_cycles(cycles_hist,
|
|
start ? start - sym->start : 0,
|
|
start ? start - sym->start : 0,
|
|
offset, cycles,
|
|
offset, cycles,
|
|
!!start);
|
|
!!start);
|