Skip to content
This repository has been archived by the owner on Jan 23, 2023. It is now read-only.

Commit

Permalink
enabling LTtng logging system for coreclr
Browse files Browse the repository at this point in the history
To add more events modify <root>/src/vm/ClrEtwAll.man
and execute perl <root>/src/inc/genXplatEtw.pl
  • Loading branch information
ramarag committed Sep 22, 2015
1 parent b270517 commit 4fe6749
Show file tree
Hide file tree
Showing 34 changed files with 22,461 additions and 188 deletions.
7 changes: 4 additions & 3 deletions CMakeLists.txt
Expand Up @@ -225,6 +225,7 @@ if(CLR_CMAKE_PLATFORM_UNIX)
add_subdirectory(src/coreclr/hosts/unixcoreconsole)
endif(CLR_CMAKE_PLATFORM_UNIX)


if(CLR_CMAKE_PLATFORM_DARWIN)
add_subdirectory(src/coreclr/hosts/osxbundlerun)
endif(CLR_CMAKE_PLATFORM_DARWIN)
Expand Down Expand Up @@ -394,10 +395,10 @@ if (WIN32)
endif(WIN32)
# Definition directives

# The following defines were extracted from the official amd64 debug / release builds.
if (WIN32)
if (WIN32 OR CLR_CMAKE_PLATFORM_LINUX)
add_definitions(-DFEATURE_EVENT_TRACE=1)
endif (WIN32)
endif (WIN32 OR CLR_CMAKE_PLATFORM_LINUX)


if (CLR_CMAKE_PLATFORM_UNIX)
add_definitions(-DPLATFORM_UNIX=1)
Expand Down
22 changes: 21 additions & 1 deletion Documentation/building/linux-instructions.md
Expand Up @@ -36,7 +36,27 @@ ellismg@linux:~$ sudo apt-get update

Then install the packages you need:

`ellismg@linux:~$ sudo apt-get install cmake llvm-3.5 clang-3.5 lldb-3.6 lldb-3.6-dev libunwind8 libunwind8-dev gettext`
`ellismg@linux:~$ sudo apt-get install cmake llvm-3.5 clang-3.5 lldb-3.6 lldb-3.6-dev libunwind8 libunwind8-dev gettext liblttng-ust-dev`

Note: If liblttng-ust-dev can not be obtained out of box use the following steps:

```
wget http://lttng.org/files/urcu/userspace-rcu-0.8.7.tar.bz2
tar -xjvf userspace-rcu-0.8.7.tar.bz2
./configure
make
sudo make install
sudo bash -c " echo '/usr/local/lib' >> /etc/ld.so.conf"
sudo ldconfig
cd userspace-rcu-0.8.7
wget http://lttng.org/files/lttng-ust/lttng-ust-2.6.2.tar.bz2
tar -xjvf lttng-ust-2.6.2.tar.bz2
cd lttng-ust-2.6.2
./configure
make
sudo make install
sudo ldconfig
```

You now have all the required components.

Expand Down
13 changes: 12 additions & 1 deletion src/dlls/mscoree/coreclr/CMakeLists.txt
Expand Up @@ -42,6 +42,7 @@ else()

endif (WIN32)

set(CLR_CMAKE_ADDITIONAL_LINKEROPTIONS "" )
add_definitions(-DFX_VER_INTERNALNAME_STR=CoreCLR.dll)

add_library(coreclr
Expand Down Expand Up @@ -114,7 +115,17 @@ else()
)
endif(WIN32)

target_link_libraries(coreclr ${CORECLR_LIBRARIES})
if(CLR_CMAKE_PLATFORM_LINUX)
list(APPEND CORECLR_LIBRARIES
eventprovider
)

list(APPEND CLR_CMAKE_ADDITIONAL_LINKEROPTIONS
-llttng-ust
)
endif(CLR_CMAKE_PLATFORM_LINUX)

target_link_libraries(coreclr ${CORECLR_LIBRARIES} ${CLR_CMAKE_ADDITIONAL_LINKEROPTIONS})

if(WIN32)
add_dependencies(coreclr dactablegen)
Expand Down
2 changes: 1 addition & 1 deletion src/gc/gc.cpp
Expand Up @@ -31551,7 +31551,7 @@ void gc_heap::descr_generations_to_profiler (gen_walk_fn fn, void *context)
assert (seg == hp->ephemeral_heap_segment);
assert (curr_gen_number0 <= max_generation);
//
if ((curr_gen_number0 == max_generation))
if (curr_gen_number0 == max_generation)
{
if (heap_segment_mem (seg) < generation_allocation_start (hp->generation_of (max_generation-1)))
{
Expand Down
15 changes: 9 additions & 6 deletions src/gc/gcee.cpp
Expand Up @@ -392,7 +392,7 @@ size_t GCHeap::GetNow()

void ProfScanRootsHelper(Object** ppObject, ScanContext *pSC, DWORD dwFlags)
{
#if defined(GC_PROFILING) || defined(FEATURE_EVENT_TRACE)
#if defined(GC_PROFILING)
Object *pObj = *ppObject;
#ifdef INTERIOR_POINTERS
if (dwFlags & GC_CALL_INTERIOR)
Expand All @@ -408,7 +408,7 @@ void ProfScanRootsHelper(Object** ppObject, ScanContext *pSC, DWORD dwFlags)
}
#endif //INTERIOR_POINTERS
ScanRootsHelper(&pObj, pSC, dwFlags);
#endif // defined(GC_PROFILING) || defined(FEATURE_EVENT_TRACE)
#endif // defined(GC_PROFILING)
}

#if defined(GC_PROFILING) || defined(FEATURE_EVENT_TRACE)
Expand All @@ -428,6 +428,7 @@ void GCProfileWalkHeapWorker(BOOL fProfilerPinned, BOOL fShouldWalkHeapRootsForE
// **** Scan roots: Only scan roots if profiling API wants them or ETW wants them.
if (fProfilerPinned || fShouldWalkHeapRootsForEtw)
{
#if defined(GC_PROFILING) //ScanRootsHelper is only defined in this context
#ifdef MULTIPLE_HEAPS
int hn;

Expand All @@ -454,7 +455,7 @@ void GCProfileWalkHeapWorker(BOOL fProfilerPinned, BOOL fShouldWalkHeapRootsForE
pGenGCHeap->finalize_queue->GcScanRoots(&ScanRootsHelper, 0, &SC);

#endif // MULTIPLE_HEAPS

#endif// defined(GC_PROFILING)
// Handles are kept independent of wks/svr/concurrent builds
SC.dwEtwRootKind = kEtwGCRootKindHandle;
CNameSpace::GcScanHandlesForProfilerAndETW(max_generation, &SC);
Expand All @@ -470,6 +471,7 @@ void GCProfileWalkHeapWorker(BOOL fProfilerPinned, BOOL fShouldWalkHeapRootsForE
#endif // defined (GC_PROFILING)
}

#if defined (GC_PROFILING)
// **** Scan dependent handles: only if the profiler supports it or ETW wants roots
if ((fProfilerPinned && CORProfilerTrackConditionalWeakTableElements()) ||
fShouldWalkHeapRootsForEtw)
Expand All @@ -482,19 +484,19 @@ void GCProfileWalkHeapWorker(BOOL fProfilerPinned, BOOL fShouldWalkHeapRootsForE
// indicate that dependent handle scanning is over, so we can flush the buffered roots
// to the profiler. (This is for profapi only. ETW will flush after the
// entire heap was is complete, via ETW::GCLog::EndHeapDump.)
#if defined (GC_PROFILING)
if (fProfilerPinned && CORProfilerTrackConditionalWeakTableElements())
{
g_profControlBlock.pProfInterface->EndConditionalWeakTableElementReferences(&SC.pHeapId);
}
#endif // defined (GC_PROFILING)
}
#endif // defined (GC_PROFILING)

ProfilerWalkHeapContext profilerWalkHeapContext(fProfilerPinned, SC.pvEtwContext);

// **** Walk objects on heap: only if profiling API wants them or ETW wants them.
if (fProfilerPinned || fShouldWalkHeapObjectsForEtw)
{
#ifdef GC_PROFILING // HeapWalkHelper is only defined in this context
#ifdef MULTIPLE_HEAPS
int hn;

Expand All @@ -507,6 +509,7 @@ void GCProfileWalkHeapWorker(BOOL fProfilerPinned, BOOL fShouldWalkHeapRootsForE
#else
gc_heap::walk_heap(&HeapWalkHelper, &profilerWalkHeapContext, max_generation, TRUE);
#endif //MULTIPLE_HEAPS
#endif //GC_PROFILING
}

// **** Done! Indicate to ETW helpers that the heap walk is done, so any buffers
Expand Down Expand Up @@ -543,7 +546,7 @@ void GCProfileWalkHeap()
}
#endif // defined (GC_PROFILING)

#ifdef FEATURE_EVENT_TRACE
#if defined (FEATURE_EVENT_TRACE)
// If the profiling API didn't want us to walk the heap but ETW does, then do the
// walk here
if (!fWalkedHeapForProfiler &&
Expand Down
1 change: 0 additions & 1 deletion src/gc/objecthandle.cpp
Expand Up @@ -505,7 +505,6 @@ void CALLBACK ScanPointerForProfilerAndETW(_UNCHECKED_OBJECTREF *pObjRef, LPARAM
pSec = (_UNCHECKED_OBJECTREF)HndGetHandleExtraInfo(handle);

}

ETW::GCLog::RootReference(
handle,
*pRef, // object being rooted
Expand Down

0 comments on commit 4fe6749

Please sign in to comment.