1
0
Fork 0

formatter ran

This commit is contained in:
3rdit 2026-04-16 02:08:06 +01:00
parent ce1cf27630
commit 0ed945af36
No known key found for this signature in database
GPG Key ID: 7DD8A35AE190E434
8 changed files with 33 additions and 21 deletions

View File

@ -183,7 +183,8 @@ namespace ElfBug
do
{
waited = waitpid(pid, &stepStatus, __WALL);
} while(waited == -1 && errno == EINTR);
}
while(waited == -1 && errno == EINTR);
if(waited == -1)
{
cbInternalError("waitpid(step) failed: " + std::string(strerror(errno)));

View File

@ -119,7 +119,8 @@ namespace ElfBug
do
{
n = read(pipeFds[0], errBuf, sizeof(errBuf) - 1);
} while(n == -1 && errno == EINTR);
}
while(n == -1 && errno == EINTR);
close(pipeFds[0]);
if(n == -1)

View File

@ -87,7 +87,8 @@ namespace ElfBug::test
}
// /proc/<pid>/stat state char: R/S = scheduled, t/T = ptrace-stopped.
bool WaitForRunning(const std::chrono::milliseconds timeout = std::chrono::seconds(5)) const {
bool WaitForRunning(const std::chrono::milliseconds timeout = std::chrono::seconds(5)) const
{
const pid_t pid = mProcess ? mProcess->pid : 0;
if(pid <= 0) return false;
const auto start = std::chrono::steady_clock::now();

View File

@ -1,10 +1,12 @@
#include <cstdio>
extern "C" __attribute__((noinline, used)) void hit_me() {
extern "C" __attribute__((noinline, used)) void hit_me()
{
asm volatile("nop");
}
int main() {
int main()
{
std::puts("Hello, ElfBug!");
hit_me();
hit_me();

View File

@ -4,12 +4,14 @@
static std::atomic<int> gRanCount{0};
static void* worker(void*) {
static void* worker(void*)
{
gRanCount.fetch_add(1, std::memory_order_relaxed);
return nullptr;
}
int main() {
int main()
{
std::vector<pthread_t> threads(5);
for(auto& t : threads) pthread_create(&t, nullptr, worker, nullptr);
for(const auto& t : threads) pthread_join(t, nullptr);

View File

@ -1,4 +1,5 @@
int main() {
int main()
{
volatile int i = 0;
while(true) { i = 42; }
}

View File

@ -1,6 +1,7 @@
#include <cstdint>
int main() {
int main()
{
volatile int* p = reinterpret_cast<int*>(static_cast<std::uintptr_t>(0));
*p = 42;
return 0;

View File

@ -156,7 +156,8 @@ TEST_CASE("Software breakpoint: persistent hits twice", "[breakpoint]")
std::promise<ResolvedBreakpoint> bpPromise;
auto bpFuture = bpPromise.get_future();
dbg.OnSystemBreakpoint([&] {
dbg.OnSystemBreakpoint([&]
{
ResolvedBreakpoint bp;
const auto resolved = ResolveRuntimeAddress(path, dbg.process()->pid, "hit_me");
if(resolved)
@ -207,7 +208,8 @@ TEST_CASE("Software breakpoint patches and restores instruction byte", "[breakpo
std::promise<BreakpointPatchRoundTrip> bpPromise;
auto bpFuture = bpPromise.get_future();
dbg.OnSystemBreakpoint([&] {
dbg.OnSystemBreakpoint([&]
{
BreakpointPatchRoundTrip bp;
const auto resolved = ResolveRuntimeAddress(path, dbg.process()->pid, "hit_me");
if(resolved)
@ -252,7 +254,8 @@ TEST_CASE("Software breakpoint: singleshot hits once", "[breakpoint]")
std::promise<ResolvedBreakpoint> bpPromise;
auto bpFuture = bpPromise.get_future();
dbg.OnSystemBreakpoint([&] {
dbg.OnSystemBreakpoint([&]
{
ResolvedBreakpoint bp;
const auto resolved = ResolveRuntimeAddress(path, dbg.process()->pid, "hit_me");
if(resolved)