* Fixed abuse of the DoublyLinkedListLink. TemporaryVariables have an

explicit queued field now. Fixes #5352.
* set_debug_variable(): Disallow symbol variable names.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35534 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Ingo Weinhold
2010-02-20 13:19:41 +00:00
parent 477fd1be55
commit cd694fdbfa
+11 -4
View File
@@ -1,5 +1,5 @@
/* /*
* Copyright 2008, Ingo Weinhold, [email protected] * Copyright 2008-2010, Ingo Weinhold, [email protected]
* Distributed under the terms of the MIT License. * Distributed under the terms of the MIT License.
*/ */
@@ -51,6 +51,7 @@ struct Variable {
struct TemporaryVariable : Variable, struct TemporaryVariable : Variable,
DoublyLinkedListLinkImpl<TemporaryVariable> { DoublyLinkedListLinkImpl<TemporaryVariable> {
bool queued;
}; };
static Variable sVariables[kVariableCount]; static Variable sVariables[kVariableCount];
@@ -84,9 +85,9 @@ static void
dequeue_temporary_variable(TemporaryVariable* variable) dequeue_temporary_variable(TemporaryVariable* variable)
{ {
// dequeue if queued // dequeue if queued
if (variable->GetDoublyLinkedListLink()->previous != NULL if (variable->queued) {
|| sTemporaryVariablesLRUQueue.Head() == variable) {
sTemporaryVariablesLRUQueue.Remove(variable); sTemporaryVariablesLRUQueue.Remove(variable);
variable->queued = false;
} }
} }
@@ -112,6 +113,7 @@ touch_variable(Variable* _variable)
// move to the end of the queue // move to the end of the queue
dequeue_temporary_variable(variable); dequeue_temporary_variable(variable);
sTemporaryVariablesLRUQueue.Add(variable); sTemporaryVariablesLRUQueue.Add(variable);
variable->queued = true;
} }
@@ -119,8 +121,10 @@ static Variable*
free_temporary_variable_slot() free_temporary_variable_slot()
{ {
TemporaryVariable* variable = sTemporaryVariablesLRUQueue.RemoveHead(); TemporaryVariable* variable = sTemporaryVariablesLRUQueue.RemoveHead();
if (variable) if (variable) {
variable->queued = false;
variable->Uninit(); variable->Uninit();
}
return variable; return variable;
} }
@@ -260,6 +264,9 @@ is_debug_variable_defined(const char* variableName)
bool bool
set_debug_variable(const char* variableName, uint64 value) set_debug_variable(const char* variableName, uint64 value)
{ {
if (is_symbol_variable(variableName))
return false;
if (is_arch_specific_variable(variableName)) if (is_arch_specific_variable(variableName))
return arch_set_debug_variable(variableName + 1, value) == B_OK; return arch_set_debug_variable(variableName + 1, value) == B_OK;