Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 191310
b: refs/heads/master
c: 139633c
h: refs/heads/master
v: v3
  • Loading branch information
Arnaldo Carvalho de Melo committed May 9, 2010
1 parent 0484410 commit d4f983e
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 15 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: e157eb8341e7885ff2d9f1620155e3da6e0c8f56
refs/heads/master: 139633c6a43781cd44798165b0472a34bf53a1e8
15 changes: 1 addition & 14 deletions trunk/tools/perf/builtin-report.c
Original file line number Diff line number Diff line change
Expand Up @@ -123,19 +123,6 @@ static int perf_session__add_hist_entry(struct perf_session *self,
return 0;
}

static int validate_chain(struct ip_callchain *chain, event_t *event)
{
unsigned int chain_size;

chain_size = event->header.size;
chain_size -= (unsigned long)&event->ip.__more_data - (unsigned long)event;

if (chain->nr*sizeof(u64) > chain_size)
return -1;

return 0;
}

static int add_event_total(struct perf_session *session,
struct sample_data *data,
struct perf_event_attr *attr)
Expand Down Expand Up @@ -171,7 +158,7 @@ static int process_sample_event(event_t *event, struct perf_session *session)

dump_printf("... chain: nr:%Lu\n", data.callchain->nr);

if (validate_chain(data.callchain, event) < 0) {
if (!ip_callchain__valid(data.callchain, event)) {
pr_debug("call-chain problem with event, "
"skipping it.\n");
return 0;
Expand Down
7 changes: 7 additions & 0 deletions trunk/tools/perf/util/callchain.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,13 @@

#include "callchain.h"

bool ip_callchain__valid(struct ip_callchain *chain, event_t *event)
{
unsigned int chain_size = event->header.size;
chain_size -= (unsigned long)&event->ip.__more_data - (unsigned long)event;
return chain->nr * sizeof(u64) <= chain_size;
}

#define chain_for_each_child(child, parent) \
list_for_each_entry(child, &parent->children, brothers)

Expand Down
3 changes: 3 additions & 0 deletions trunk/tools/perf/util/callchain.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include "../perf.h"
#include <linux/list.h>
#include <linux/rbtree.h>
#include "event.h"
#include "util.h"
#include "symbol.h"

Expand Down Expand Up @@ -58,4 +59,6 @@ static inline u64 cumul_hits(struct callchain_node *node)
int register_callchain_param(struct callchain_param *param);
int append_chain(struct callchain_node *root, struct ip_callchain *chain,
struct map_symbol *syms);

bool ip_callchain__valid(struct ip_callchain *chain, event_t *event);
#endif /* __PERF_CALLCHAIN_H */

0 comments on commit d4f983e

Please sign in to comment.