Skip to content

Commit

Permalink
feat(usability): Print message on ^C (#201)
Browse files Browse the repository at this point in the history
Co-authored-by: Mario Bielert <[email protected]>
  • Loading branch information
cvonelm and bmario authored Mar 9, 2022
1 parent fc255d9 commit 05e2278
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 16 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/cmake.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ jobs:
uses: actions/cache@v2
with:
path: /opt/otf2/
key: ${{ matrix.os }}-otf2
key: ${{ matrix.os }}-otf2-${OTF2_VERSION}
- name: Install OTF2
if: steps.cache-otf2.outputs.cache-hit != 'true'
run: |
Expand All @@ -49,7 +49,7 @@ jobs:
CXX: ${{ matrix.compiler }}
run: cmake . -DCMAKE_BUILD_TYPE=${{ matrix.build-type }}
- name: Build
run: make -j
run: make -j 2
- name: Create source tarball
if: ${{ matrix.compiler == 'g++-10' && matrix.os == 'ubuntu-20.04' && matrix.build-type == 'RelWithDebInfo' }}
run: make dist
Expand Down
6 changes: 3 additions & 3 deletions include/lo2s/bfd_resolve.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -149,9 +149,9 @@ class Lib
private:
void filter_symbols()
{
symbols_.erase(std::remove_if(symbols_.begin(), symbols_.end(), [](const asymbol* sym) {
return (sym != nullptr) && !(sym->flags & BSF_FUNCTION);
}));
symbols_.erase(std::remove_if(
symbols_.begin(), symbols_.end(),
[](const asymbol* sym) { return (sym != nullptr) && !(sym->flags & BSF_FUNCTION); }));
}

void read_symbols();
Expand Down
2 changes: 2 additions & 0 deletions src/monitor/cpu_set_monitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ void CpuSetMonitor::run()
{
int sig;
auto ret = sigwait(&ss, &sig);
std::cout << "[ lo2s: Encountered SIGINT. Stopping measurements and closing trace ]"
<< std::endl;
if (ret)
{
throw make_system_error();
Expand Down
3 changes: 2 additions & 1 deletion src/monitor/process_monitor_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@ namespace monitor

std::vector<char*> tmp;
std::transform(command_and_args.begin(), command_and_args.end(), std::back_inserter(tmp),
[](const std::string& s) {
[](const std::string& s)
{
char* pc = new char[s.size() + 1];
std::strcpy(pc, s.c_str());
return pc;
Expand Down
7 changes: 6 additions & 1 deletion src/process_controller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,8 @@ void ProcessController::handle_signal(Thread child, int status)
// exit if detached from first child (the original sampled process)
if (child == first_child_)
{
Log::info() << "Exiting monitor with status " << 0;
std::cout << "[ lo2s: Child exited. Stopping measurements and closing trace. ]"
<< std::endl;
throw std::system_error(0, std::system_category());
}
}
Expand Down Expand Up @@ -307,6 +308,8 @@ void ProcessController::handle_signal(Thread child, int status)
// exit if first child (the original sampled process) is dead
if (child == first_child_)
{
std::cout << "[ lo2s: Child exited. Stopping measurements and closing trace. ]"
<< std::endl;
summary().set_exit_code(WEXITSTATUS(status));
throw std::system_error(0, std::system_category());
}
Expand All @@ -318,6 +321,8 @@ void ProcessController::handle_signal(Thread child, int status)
// exit if first child (the original sampled process) is dead
if (child == first_child_)
{
std::cout << "[ lo2s: Child exited. Stopping measurements and closing trace. ]"
<< std::endl;
throw std::system_error(0, std::system_category());
}
return;
Expand Down
18 changes: 9 additions & 9 deletions src/summary.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,15 +97,15 @@ void Summary::show()

std::filesystem::recursive_directory_iterator it(trace_dir_), end;

trace_size =
std::accumulate(it, end, static_cast<size_t>(0),
[](std::size_t sum, const std::filesystem::directory_entry& entry) {
if (!std::filesystem::is_directory(entry))
{
return sum + std::filesystem::file_size(entry);
}
return sum;
});
trace_size = std::accumulate(it, end, static_cast<size_t>(0),
[](std::size_t sum, const std::filesystem::directory_entry& entry)
{
if (!std::filesystem::is_directory(entry))
{
return sum + std::filesystem::file_size(entry);
}
return sum;
});

if (config().monitor_type == lo2s::MonitorType::PROCESS)
{
Expand Down

0 comments on commit 05e2278

Please sign in to comment.