[compiler-rt] r191157 - tsan: allow symbolization of non-native PCs, e.g. coming from JIT/JAVA/etc
Alexey Samsonov
samsonov at google.com
Mon Sep 23 00:39:42 PDT 2013
On Sun, Sep 22, 2013 at 4:14 AM, Dmitry Vyukov <dvyukov at google.com> wrote:
> Author: dvyukov
> Date: Sat Sep 21 19:14:57 2013
> New Revision: 191157
>
> URL: http://llvm.org/viewvc/llvm-project?rev=191157&view=rev
> Log:
> tsan: allow symbolization of non-native PCs, e.g. coming from JIT/JAVA/etc
>
>
> Modified:
> compiler-rt/trunk/lib/tsan/rtl/tsan_symbolize.cc
>
> Modified: compiler-rt/trunk/lib/tsan/rtl/tsan_symbolize.cc
> URL:
> http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/tsan/rtl/tsan_symbolize.cc?rev=191157&r1=191156&r2=191157&view=diff
>
> ==============================================================================
> --- compiler-rt/trunk/lib/tsan/rtl/tsan_symbolize.cc (original)
> +++ compiler-rt/trunk/lib/tsan/rtl/tsan_symbolize.cc Sat Sep 21 19:14:57
> 2013
> @@ -69,7 +69,56 @@ static ReportStack *NewReportStackEntry(
> return ent;
> }
>
> +
> + ReportStack *next;
> + char *module;
> + uptr offset;
> + uptr pc;
> + char *func;
> + char *file;
> + int line;
> + int col;
> +
> +
> +// Denotes fake PC values that come from JIT/JAVA/etc.
> +// For such PC values __tsan_symbolize_external() will be called.
> +const uptr kExternalPCBit = 1ULL << 60;
> +
> +// May be overriden by JIT/JAVA/etc,
> +// whatever produces PCs marked with kExternalPCBit.
> +extern "C" bool __tsan_symbolize_external(uptr pc,
> + char *func_buf, uptr func_siz,
> + char *file_buf, uptr file_siz,
> + int *line, int *col)
> + SANITIZER_WEAK_ATTRIBUTE;
> +
> +bool __tsan_symbolize_external(uptr pc,
> + char *func_buf, uptr func_siz,
> + char *file_buf, uptr file_siz,
> + int *line, int *col) {
> + return false;
> +}
>
Is there a chance we may need this for another sanitizer tools? Why not
move this logic to symbolizer in
sanitizer_common?
> +
> ReportStack *SymbolizeCode(uptr addr) {
> + // Check if PC comes from non-native land.
> + if (addr & kExternalPCBit) {
> + // Declare static to not consume too much stack space.
> + // We symbolize reports in a single thread, so this is fine.
> + static char func_buf[1024];
> + static char file_buf[1024];
>
If speed is not very important here, you may use InternalScopedBuffer. In
any case,
it would be nice to be defensive and ensure we're executing this code in a
single thread using
Mutex or assert.
> + int line, col;
> + if (!__tsan_symbolize_external(addr, func_buf, sizeof(func_buf),
> + file_buf, sizeof(file_buf), &line,
> &col))
> + return NewReportStackEntry(addr);
> + ReportStack *ent = NewReportStackEntry(addr);
> + ent->module = 0;
> + ent->offset = 0;
> + ent->func = internal_strdup(func_buf);
> + ent->file = internal_strdup(file_buf);
> + ent->line = line;
> + ent->col = col;
> + return ent;
> + }
> if (!getSymbolizer()->IsAvailable())
> return SymbolizeCodeAddr2Line(addr);
> ScopedInSymbolizer in_symbolizer;
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>
--
Alexey Samsonov, MSK
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20130923/0133ac23/attachment.html>
More information about the llvm-commits
mailing list