@@ -50,21 +50,25 @@ static void hists__reset_col_len(struct hists *hists)
5050 hists__set_col_len (hists , col , 0 );
5151}
5252
53+ static void hists__set_unres_dso_col_len (struct hists * hists , int dso )
54+ {
55+ const unsigned int unresolved_col_width = BITS_PER_LONG / 4 ;
56+
57+ if (hists__col_len (hists , dso ) < unresolved_col_width &&
58+ !symbol_conf .col_width_list_str && !symbol_conf .field_sep &&
59+ !symbol_conf .dso_list )
60+ hists__set_col_len (hists , dso , unresolved_col_width );
61+ }
62+
5363static void hists__calc_col_len (struct hists * hists , struct hist_entry * h )
5464{
65+ const unsigned int unresolved_col_width = BITS_PER_LONG / 4 ;
5566 u16 len ;
5667
5768 if (h -> ms .sym )
58- hists__new_col_len (hists , HISTC_SYMBOL , h -> ms .sym -> namelen );
59- else {
60- const unsigned int unresolved_col_width = BITS_PER_LONG / 4 ;
61-
62- if (hists__col_len (hists , HISTC_DSO ) < unresolved_col_width &&
63- !symbol_conf .col_width_list_str && !symbol_conf .field_sep &&
64- !symbol_conf .dso_list )
65- hists__set_col_len (hists , HISTC_DSO ,
66- unresolved_col_width );
67- }
69+ hists__new_col_len (hists , HISTC_SYMBOL , h -> ms .sym -> namelen + 4 );
70+ else
71+ hists__set_unres_dso_col_len (hists , HISTC_DSO );
6872
6973 len = thread__comm_len (h -> thread );
7074 if (hists__new_col_len (hists , HISTC_COMM , len ))
@@ -74,6 +78,37 @@ static void hists__calc_col_len(struct hists *hists, struct hist_entry *h)
7478 len = dso__name_len (h -> ms .map -> dso );
7579 hists__new_col_len (hists , HISTC_DSO , len );
7680 }
81+
82+ if (h -> branch_info ) {
83+ int symlen ;
84+ /*
85+ * +4 accounts for '[x] ' priv level info
86+ * +2 account of 0x prefix on raw addresses
87+ */
88+ if (h -> branch_info -> from .sym ) {
89+ symlen = (int )h -> branch_info -> from .sym -> namelen + 4 ;
90+ hists__new_col_len (hists , HISTC_SYMBOL_FROM , symlen );
91+
92+ symlen = dso__name_len (h -> branch_info -> from .map -> dso );
93+ hists__new_col_len (hists , HISTC_DSO_FROM , symlen );
94+ } else {
95+ symlen = unresolved_col_width + 4 + 2 ;
96+ hists__new_col_len (hists , HISTC_SYMBOL_FROM , symlen );
97+ hists__set_unres_dso_col_len (hists , HISTC_DSO_FROM );
98+ }
99+
100+ if (h -> branch_info -> to .sym ) {
101+ symlen = (int )h -> branch_info -> to .sym -> namelen + 4 ;
102+ hists__new_col_len (hists , HISTC_SYMBOL_TO , symlen );
103+
104+ symlen = dso__name_len (h -> branch_info -> to .map -> dso );
105+ hists__new_col_len (hists , HISTC_DSO_TO , symlen );
106+ } else {
107+ symlen = unresolved_col_width + 4 + 2 ;
108+ hists__new_col_len (hists , HISTC_SYMBOL_TO , symlen );
109+ hists__set_unres_dso_col_len (hists , HISTC_DSO_TO );
110+ }
111+ }
77112}
78113
79114static void hist_entry__add_cpumode_period (struct hist_entry * he ,
@@ -195,26 +230,14 @@ static u8 symbol__parent_filter(const struct symbol *parent)
195230 return 0 ;
196231}
197232
198- struct hist_entry * __hists__add_entry (struct hists * hists ,
233+ static struct hist_entry * add_hist_entry (struct hists * hists ,
234+ struct hist_entry * entry ,
199235 struct addr_location * al ,
200- struct symbol * sym_parent , u64 period )
236+ u64 period )
201237{
202238 struct rb_node * * p ;
203239 struct rb_node * parent = NULL ;
204240 struct hist_entry * he ;
205- struct hist_entry entry = {
206- .thread = al -> thread ,
207- .ms = {
208- .map = al -> map ,
209- .sym = al -> sym ,
210- },
211- .cpu = al -> cpu ,
212- .ip = al -> addr ,
213- .level = al -> level ,
214- .period = period ,
215- .parent = sym_parent ,
216- .filtered = symbol__parent_filter (sym_parent ),
217- };
218241 int cmp ;
219242
220243 pthread_mutex_lock (& hists -> lock );
@@ -225,7 +248,7 @@ struct hist_entry *__hists__add_entry(struct hists *hists,
225248 parent = * p ;
226249 he = rb_entry (parent , struct hist_entry , rb_node_in );
227250
228- cmp = hist_entry__cmp (& entry , he );
251+ cmp = hist_entry__cmp (entry , he );
229252
230253 if (!cmp ) {
231254 he -> period += period ;
@@ -239,7 +262,7 @@ struct hist_entry *__hists__add_entry(struct hists *hists,
239262 p = & (* p )-> rb_right ;
240263 }
241264
242- he = hist_entry__new (& entry );
265+ he = hist_entry__new (entry );
243266 if (!he )
244267 goto out_unlock ;
245268
@@ -252,6 +275,51 @@ struct hist_entry *__hists__add_entry(struct hists *hists,
252275 return he ;
253276}
254277
278+ struct hist_entry * __hists__add_branch_entry (struct hists * self ,
279+ struct addr_location * al ,
280+ struct symbol * sym_parent ,
281+ struct branch_info * bi ,
282+ u64 period )
283+ {
284+ struct hist_entry entry = {
285+ .thread = al -> thread ,
286+ .ms = {
287+ .map = bi -> to .map ,
288+ .sym = bi -> to .sym ,
289+ },
290+ .cpu = al -> cpu ,
291+ .ip = bi -> to .addr ,
292+ .level = al -> level ,
293+ .period = period ,
294+ .parent = sym_parent ,
295+ .filtered = symbol__parent_filter (sym_parent ),
296+ .branch_info = bi ,
297+ };
298+
299+ return add_hist_entry (self , & entry , al , period );
300+ }
301+
302+ struct hist_entry * __hists__add_entry (struct hists * self ,
303+ struct addr_location * al ,
304+ struct symbol * sym_parent , u64 period )
305+ {
306+ struct hist_entry entry = {
307+ .thread = al -> thread ,
308+ .ms = {
309+ .map = al -> map ,
310+ .sym = al -> sym ,
311+ },
312+ .cpu = al -> cpu ,
313+ .ip = al -> addr ,
314+ .level = al -> level ,
315+ .period = period ,
316+ .parent = sym_parent ,
317+ .filtered = symbol__parent_filter (sym_parent ),
318+ };
319+
320+ return add_hist_entry (self , & entry , al , period );
321+ }
322+
255323int64_t
256324hist_entry__cmp (struct hist_entry * left , struct hist_entry * right )
257325{
0 commit comments