• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

llnl / dftracer / 28731245268

05 Jul 2026 05:54AM UTC coverage: 18.611%. First build
28731245268

Pull #367

github

web-flow
Merge 117a42ffe into 193c94037
Pull Request #367: Feature for ByPass

7339 of 53706 branches covered (13.67%)

Branch coverage included in aggregate %.

108 of 129 new or added lines in 9 files covered. (83.72%)

4861 of 11845 relevant lines covered (41.04%)

1103.74 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

82.35
/src/dftracer/core/utils/stdio_bypass.cpp
1
//
2
// Created by haridev on 7/2/26.
3
//
4

5
#include <dftracer/core/common/logging.h>
6
#include <dftracer/core/utils/stdio_bypass.h>
7
#include <dlfcn.h>
8

9
#include <cassert>
10
#include <dftracer/core/dftracer_config.hpp>
11

12
#ifndef DFTRACER_LIBC_SO_PATH
13
#define DFTRACER_LIBC_SO_PATH "libc.so.6"
14
#endif
15

16
namespace dftracer {
17

18
STDIOBypass& STDIOBypass::get_instance() {
686✔
19
  // No initialize() call here: initialization happens exactly once, eagerly,
20
  // from DFTracerCore::initialize() (see dftracer_main.cpp). This keeps
21
  // every call site (every bypass_* invocation on the write hot path) to
22
  // just this static-local access and a direct function-pointer call below,
23
  // with no redundant re-check.
24
  static STDIOBypass instance;
25
  return instance;
686✔
26
}
27

28
void STDIOBypass::initialize() {
129✔
29
  if (initialized_) return;
129✔
30
  DFTRACER_LOG_DEBUG("STDIOBypass::initialize");
57✔
31
  // libc is already loaded in every process; RTLD_NOLOAD means this just
32
  // returns a handle to the existing mapping, not a fresh load.
33
  void* libc = dlopen(DFTRACER_LIBC_SO_PATH, RTLD_LAZY | RTLD_NOLOAD);
66✔
34
  assert(libc != nullptr);
66!
35
  real_fopen_ = reinterpret_cast<fopen_fn>(dlsym(libc, "fopen"));
66✔
36
  real_setvbuf_ = reinterpret_cast<setvbuf_fn>(dlsym(libc, "setvbuf"));
66✔
37
  real_flockfile_ = reinterpret_cast<flockfile_fn>(dlsym(libc, "flockfile"));
66✔
38
  real_funlockfile_ =
66✔
39
      reinterpret_cast<funlockfile_fn>(dlsym(libc, "funlockfile"));
66✔
40
  real_ftrylockfile_ =
66✔
41
      reinterpret_cast<ftrylockfile_fn>(dlsym(libc, "ftrylockfile"));
66✔
42
  real_fflush_ = reinterpret_cast<fflush_fn>(dlsym(libc, "fflush"));
66✔
43
  real_fwrite_ = reinterpret_cast<fwrite_fn>(dlsym(libc, "fwrite"));
66✔
44
  real_fseek_ = reinterpret_cast<fseek_fn>(dlsym(libc, "fseek"));
66✔
45
  real_ftell_ = reinterpret_cast<ftell_fn>(dlsym(libc, "ftell"));
66✔
46
  real_fclose_ = reinterpret_cast<fclose_fn>(dlsym(libc, "fclose"));
66✔
47
  assert(real_fopen_ != nullptr);
66!
48
  assert(real_setvbuf_ != nullptr);
66!
49
  assert(real_flockfile_ != nullptr);
66!
50
  assert(real_funlockfile_ != nullptr);
66!
51
  assert(real_ftrylockfile_ != nullptr);
66!
52
  assert(real_fflush_ != nullptr);
66!
53
  assert(real_fwrite_ != nullptr);
66!
54
  assert(real_fseek_ != nullptr);
66!
55
  assert(real_ftell_ != nullptr);
66!
56
  assert(real_fclose_ != nullptr);
66!
57
  initialized_ = true;
66✔
58
}
59

60
FILE* STDIOBypass::fopen(const char* path, const char* mode) {
64✔
61
  return real_fopen_(path, mode);
64✔
62
}
63

64
int STDIOBypass::setvbuf(FILE* fp, char* buf, int mode, size_t size) {
64✔
65
  return real_setvbuf_(fp, buf, mode, size);
64✔
66
}
67

68
void STDIOBypass::flockfile(FILE* fp) { real_flockfile_(fp); }
64✔
69

70
void STDIOBypass::funlockfile(FILE* fp) { real_funlockfile_(fp); }
64✔
71

NEW
72
int STDIOBypass::ftrylockfile(FILE* fp) { return real_ftrylockfile_(fp); }
×
73

74
int STDIOBypass::fflush(FILE* fp) { return real_fflush_(fp); }
493✔
75

76
size_t STDIOBypass::fwrite(const void* ptr, size_t size, size_t count,
64✔
77
                           FILE* fp) {
78
  return real_fwrite_(ptr, size, count, fp);
64✔
79
}
80

81
int STDIOBypass::fseek(FILE* fp, long offset, int whence) {
128✔
82
  return real_fseek_(fp, offset, whence);
128✔
83
}
84

85
long STDIOBypass::ftell(FILE* fp) { return real_ftell_(fp); }
64✔
86

87
int STDIOBypass::fclose(FILE* fp) { return real_fclose_(fp); }
64✔
88

89
}  // namespace dftracer
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc