mirror of
https://github.com/Fennix-Project/Kernel.git
synced 2025-05-28 15:34:33 +00:00
Added DebuggerIsAttached
This commit is contained in:
parent
59d547d9c4
commit
c046b079f2
@ -52,9 +52,9 @@ int LockClass::Lock(const char *FunctionName)
|
|||||||
LockData.StackPointerAttempt = (uintptr_t)__builtin_frame_address(0);
|
LockData.StackPointerAttempt = (uintptr_t)__builtin_frame_address(0);
|
||||||
Retry:
|
Retry:
|
||||||
unsigned int i = 0;
|
unsigned int i = 0;
|
||||||
while (IsLocked.Exchange(true, MemoryOrder::Acquire) && ++i < 0x10000000)
|
while (IsLocked.Exchange(true, MemoryOrder::Acquire) && ++i < (DebuggerIsAttached ? 0x100000 : 0x10000000))
|
||||||
CPU::Pause();
|
CPU::Pause();
|
||||||
if (i >= 0x10000000)
|
if (i >= (DebuggerIsAttached ? 0x100000 : 0x10000000))
|
||||||
{
|
{
|
||||||
DeadLock(LockData);
|
DeadLock(LockData);
|
||||||
goto Retry;
|
goto Retry;
|
||||||
@ -89,15 +89,14 @@ void LockClass::TimeoutDeadLock(SpinLockData Lock, uint64_t Timeout)
|
|||||||
if (CoreData != nullptr)
|
if (CoreData != nullptr)
|
||||||
CCore = CoreData->ID;
|
CCore = CoreData->ID;
|
||||||
|
|
||||||
warn("Potential deadlock in lock '%s' held by '%s'! %ld %s in queue. Interrupts are %s. Core %ld is being held by %ld. Timeout in %ld",
|
uint64_t Counter = TimeManager->GetCounter();
|
||||||
|
|
||||||
|
warn("Potential deadlock in lock '%s' held by '%s'! %ld %s in queue. Interrupts are %s. Core %ld is being held by %ld. Timeout in %ld (%ld ticks remaining).",
|
||||||
Lock.AttemptingToGet, Lock.CurrentHolder,
|
Lock.AttemptingToGet, Lock.CurrentHolder,
|
||||||
Lock.Count, Lock.Count > 1 ? "locks" : "lock",
|
Lock.Count, Lock.Count > 1 ? "locks" : "lock",
|
||||||
CPU::Interrupts(CPU::Check) ? "enabled" : "disabled",
|
CPU::Interrupts(CPU::Check) ? "enabled" : "disabled",
|
||||||
CCore, Lock.Core, this->DeadLocks, Timeout);
|
CCore, Lock.Core, Timeout, Timeout - Counter);
|
||||||
|
|
||||||
// TODO: Print on screen too.
|
|
||||||
|
|
||||||
uint64_t Counter = TimeManager->GetCounter();
|
|
||||||
if (Timeout < Counter)
|
if (Timeout < Counter)
|
||||||
{
|
{
|
||||||
warn("Unlocking lock '%s' because of timeout. (%ld < %ld)", Lock.AttemptingToGet, Timeout, Counter);
|
warn("Unlocking lock '%s' because of timeout. (%ld < %ld)", Lock.AttemptingToGet, Timeout, Counter);
|
||||||
@ -117,13 +116,13 @@ int LockClass::TimeoutLock(const char *FunctionName, uint64_t Timeout)
|
|||||||
Atomic<uint64_t> Target = 0;
|
Atomic<uint64_t> Target = 0;
|
||||||
Retry:
|
Retry:
|
||||||
unsigned int i = 0;
|
unsigned int i = 0;
|
||||||
while (IsLocked.Exchange(true, MemoryOrder::Acquire) && ++i < 0x10000000)
|
while (IsLocked.Exchange(true, MemoryOrder::Acquire) && ++i < (DebuggerIsAttached ? 0x100000 : 0x10000000))
|
||||||
CPU::Pause();
|
CPU::Pause();
|
||||||
if (i >= 0x10000000)
|
if (i >= (DebuggerIsAttached ? 0x100000 : 0x10000000))
|
||||||
{
|
{
|
||||||
if (Target == 0)
|
if (Target.Load() == 0)
|
||||||
Target = TimeManager->CalculateTarget(Timeout);
|
Target.Store(TimeManager->CalculateTarget(Timeout));
|
||||||
TimeoutDeadLock(LockData, Target);
|
TimeoutDeadLock(LockData, Target.Load());
|
||||||
goto Retry;
|
goto Retry;
|
||||||
}
|
}
|
||||||
LockData.Count++;
|
LockData.Count++;
|
||||||
|
@ -15,6 +15,8 @@
|
|||||||
#include "Core/smbios.hpp"
|
#include "Core/smbios.hpp"
|
||||||
#include "Tests/t.h"
|
#include "Tests/t.h"
|
||||||
|
|
||||||
|
bool DebuggerIsAttached = false;
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
bool EnableExternalMemoryTracer = false; /* This can be modified while we are debugging with GDB. */
|
bool EnableExternalMemoryTracer = false; /* This can be modified while we are debugging with GDB. */
|
||||||
char mExtTrkLog[MEM_TRK_MAX_SIZE];
|
char mExtTrkLog[MEM_TRK_MAX_SIZE];
|
||||||
@ -182,6 +184,13 @@ EXTERNC NIF void Main(BootInfo *Info)
|
|||||||
Interrupts::Initialize(0);
|
Interrupts::Initialize(0);
|
||||||
KPrint("Initializing CPU Features");
|
KPrint("Initializing CPU Features");
|
||||||
CPU::InitializeFeatures(0);
|
CPU::InitializeFeatures(0);
|
||||||
|
|
||||||
|
if (strcmp(CPU::Hypervisor(), x86_CPUID_VENDOR_TCG) == 0)
|
||||||
|
{
|
||||||
|
KPrint("\eFFA500Debugger detected! (TCG Virtual Machine)");
|
||||||
|
DebuggerIsAttached = true;
|
||||||
|
}
|
||||||
|
|
||||||
KPrint("Loading Kernel Symbols");
|
KPrint("Loading Kernel Symbols");
|
||||||
KernelSymbolTable = new SymbolResolver::Symbols((uintptr_t)Info->Kernel.FileBase);
|
KernelSymbolTable = new SymbolResolver::Symbols((uintptr_t)Info->Kernel.FileBase);
|
||||||
KPrint("Reading Kernel Parameters");
|
KPrint("Reading Kernel Parameters");
|
||||||
|
@ -28,12 +28,13 @@ test_mem_new_delete::~test_mem_new_delete()
|
|||||||
}
|
}
|
||||||
|
|
||||||
extern bool EnableExternalMemoryTracer;
|
extern bool EnableExternalMemoryTracer;
|
||||||
|
extern bool DebuggerIsAttached;
|
||||||
|
|
||||||
void TestMemoryAllocation()
|
void TestMemoryAllocation()
|
||||||
{
|
{
|
||||||
if (EnableExternalMemoryTracer)
|
if (EnableExternalMemoryTracer || DebuggerIsAttached)
|
||||||
{
|
{
|
||||||
debug("The test is disabled when the external memory tracer is enabled.");
|
debug("The test is disabled when the external memory tracer or a debugger is enabled.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user