From: Namhyung Kim Date: Fri, 24 Apr 2015 01:15:32 +0000 (+0900) Subject: perf tools: Introduce pstack_peek() X-Git-Tag: submit/tizen/20160607.132125~2319^2~50^2~2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=c8539e3fc630067020814657636b45095edfb5bb;p=sdk%2Femulator%2Femulator-kernel.git perf tools: Introduce pstack_peek() The pstack_peek() is to get the topmost entry without removing it. Signed-off-by: Namhyung Kim Acked-by: Jiri Olsa Cc: David Ahern Cc: Peter Zijlstra Link: http://lkml.kernel.org/r/1429838133-14001-1-git-send-email-namhyung@kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- diff --git a/tools/perf/util/pstack.c b/tools/perf/util/pstack.c index a126e6c..b234a6e 100644 --- a/tools/perf/util/pstack.c +++ b/tools/perf/util/pstack.c @@ -74,3 +74,10 @@ void *pstack__pop(struct pstack *pstack) pstack->entries[pstack->top] = NULL; return ret; } + +void *pstack__peek(struct pstack *pstack) +{ + if (pstack->top == 0) + return NULL; + return pstack->entries[pstack->top - 1]; +} diff --git a/tools/perf/util/pstack.h b/tools/perf/util/pstack.h index c3cb658..ded7f2e 100644 --- a/tools/perf/util/pstack.h +++ b/tools/perf/util/pstack.h @@ -10,5 +10,6 @@ bool pstack__empty(const struct pstack *pstack); void pstack__remove(struct pstack *pstack, void *key); void pstack__push(struct pstack *pstack, void *key); void *pstack__pop(struct pstack *pstack); +void *pstack__peek(struct pstack *pstack); #endif /* _PERF_PSTACK_ */