Skip to content

Commit accd257

Browse files
jbachorikclaude
andcommitted
Add TEST_LOG diagnostics for silent dump/copy failure paths
Profiler::dump() discarded _jfr.dump()'s Error entirely, and OS::copyFile()'s sendfile() loop broke silently on short/failed copies - both are debug-only visibility gaps that would otherwise leave a lost reference-chain write or truncated chunk copy unexplained in CI logs. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
1 parent 787f29e commit accd257

3 files changed

Lines changed: 8 additions & 0 deletions

File tree

ddprof-lib/src/main/cpp/flightRecorder.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -851,6 +851,8 @@ void Recording::switchChunk(int fd) {
851851
_chunk_start = finishChunk(/*end_recording=*/true, /*do_cleanup=*/true);
852852

853853
TEST_LOG("MethodMap: %zu methods after cleanup", _method_map.size());
854+
TEST_LOG("Recording::switchChunk copying [0, %lld) from _fd=%d to fd=%d",
855+
(long long)_chunk_start, _fd, fd);
854856

855857
_start_time = _stop_time;
856858
_start_ticks = _stop_ticks;

ddprof-lib/src/main/cpp/os_linux.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -730,9 +730,12 @@ int OS::createMemoryFile(const char* name) {
730730

731731
void OS::copyFile(int src_fd, int dst_fd, off_t offset, size_t size) {
732732
// copy_file_range() is probably better, but not supported on all kernels
733+
size_t requested = size;
733734
while (size > 0) {
734735
ssize_t bytes = sendfile(dst_fd, src_fd, &offset, size);
735736
if (bytes <= 0) {
737+
TEST_LOG("OS::copyFile sendfile returned %zd, errno=%d, remaining=%zu of requested=%zu",
738+
bytes, errno, size, requested);
736739
break;
737740
}
738741
size -= (size_t)bytes;

ddprof-lib/src/main/cpp/profiler.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1850,6 +1850,9 @@ Error Profiler::dump(const char *path, const int length) {
18501850
err = _jfr.dump(path, length);
18511851
__atomic_add_fetch(&_epoch, 1, __ATOMIC_SEQ_CST);
18521852
});
1853+
if (err) {
1854+
TEST_LOG("Profiler::dump _jfr.dump failed: %s", err.message());
1855+
}
18531856

18541857
_thread_info.clearAll(thread_ids);
18551858
_thread_info.reportCounters();

0 commit comments

Comments
 (0)