forked from fmoessbauer/drace
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add printer detector to trace calls to the detector API
- Loading branch information
1 parent
c8dacef
commit 85be7a5
Showing
5 changed files
with
140 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# DRace, a dynamic data race detector | ||
# | ||
# Copyright (c) Siemens AG, 2019 | ||
# | ||
# Authors: | ||
# Felix Moessbauer <felix.moessbauer@siemens.com> | ||
# | ||
# This work is licensed under the terms of the MIT license. See | ||
# the LICENSE file in the top-level directory. | ||
|
||
message(STATUS "Build detector printer") | ||
|
||
add_library("drace.detector.printer" SHARED "printer") | ||
target_link_libraries("drace.detector.printer" "drace-common") | ||
install(TARGETS "drace.detector.printer" | ||
RUNTIME DESTINATION ${DRACE_RUNTIME_DEST} COMPONENT Runtime | ||
LIBRARY DESTINATION ${DRACE_ARCHIVE_DEST} COMPONENT ARCHIVE) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
/* | ||
* DRace, a dynamic data race detector | ||
* | ||
* Copyright 2018 Siemens AG | ||
* | ||
* Authors: | ||
* Felix Moessbauer <felix.moessbauer@siemens.com> | ||
* | ||
* SPDX-License-Identifier: MIT | ||
*/ | ||
|
||
#include <string> | ||
|
||
#include <detector/Detector.h> | ||
|
||
#ifdef WINDOWS | ||
#define DUMMY_EXPORT __declspec(dllexport) | ||
#else | ||
#define DUMMY_EXPORT | ||
#endif | ||
|
||
namespace drace { | ||
namespace detector { | ||
/// Fake detector that stubs the \ref Detector interface | ||
class Dummy : public Detector { | ||
public: | ||
virtual bool init(int argc, const char** argv, Callback rc_clb) { | ||
return true; | ||
printf("init\n"); | ||
} | ||
|
||
virtual void finalize() { printf("%p | finalize |\n", nullptr); } | ||
|
||
virtual void map_shadow(void* startaddr, size_t size_in_bytes) { | ||
printf("%p | map_shadow | addr=%p size=%zu\n", nullptr, startaddr, | ||
size_in_bytes); | ||
}; | ||
|
||
virtual void func_enter(tls_t tls, void* pc) { | ||
printf("%p | func_enter | pc=%p\n", tls, pc); | ||
} | ||
|
||
virtual void func_exit(tls_t tls) { printf("%p | func_exit |\n", tls); } | ||
|
||
virtual void acquire(tls_t tls, void* mutex, int recursive, bool write) { | ||
printf("%p | acquire | m=%p rec=%i w=%i\n", tls, mutex, recursive, | ||
write); | ||
} | ||
|
||
virtual void release(tls_t tls, void* mutex, bool write) { | ||
printf("%p | release | m=%p, w=%i\n", tls, mutex, write); | ||
} | ||
|
||
virtual void happens_before(tls_t tls, void* identifier) { | ||
printf("%p | happens_before | %p\n", tls, identifier); | ||
} | ||
|
||
virtual void happens_after(tls_t tls, void* identifier) { | ||
printf("%p | happens_after | %p\n", tls, identifier); | ||
} | ||
|
||
virtual void read(tls_t tls, void* pc, void* addr, size_t size) { | ||
printf("%p | read | pc=%p, addr=%p, s=%zu\n", tls, pc, addr, | ||
size); | ||
} | ||
|
||
virtual void write(tls_t tls, void* pc, void* addr, size_t size) { | ||
printf("%p | write | pc=%p, addr=%p, s=%zu\n", tls, pc, addr, | ||
size); | ||
} | ||
|
||
virtual void allocate(tls_t tls, void* pc, void* addr, size_t size) { | ||
printf("%p | allocate | pc=%p, addr=%p, s=%zu\n", tls, pc, addr, | ||
size); | ||
} | ||
|
||
virtual void deallocate(tls_t tls, void* addr) { | ||
printf("%p | deallocate | addr=%p\n", tls, addr); | ||
} | ||
|
||
virtual void fork(tid_t parent, tid_t child, tls_t* tls) { | ||
*tls = (void*)(0xFF0000ull + child); | ||
printf("%p | fork | par=%i, child=%i\n", *tls, parent, child); | ||
} | ||
|
||
virtual void join(tid_t parent, tid_t child) { | ||
printf("%p | join | par=%i, child=%i\n", nullptr, parent, child); | ||
} | ||
|
||
virtual void detach(tls_t tls, tid_t thread_id) { | ||
printf("%p | detach | tid=%i\n", tls, thread_id); | ||
}; | ||
|
||
virtual void finish(tls_t tls, tid_t thread_id) { | ||
printf("%p | finish | tid=%i\n", tls, thread_id); | ||
}; | ||
|
||
virtual const char* name() { | ||
printf("%p | name |\n", nullptr); | ||
return "Dummy"; | ||
} | ||
|
||
virtual const char* version() { | ||
printf("%p | version |\n", nullptr); | ||
return "1.0.0"; | ||
} | ||
}; | ||
} // namespace detector | ||
} // namespace drace | ||
|
||
extern "C" DUMMY_EXPORT Detector* CreateDetector() { | ||
return new drace::detector::Dummy(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters