Mon 12 Sep 2011 08:09:06 PM UTC, comment #3:
All right, give it a try:
diff --git a/src/hwstack.cpp b/src/hwstack.cpp
index eddd686..6c87734 100644
--- a/src/hwstack.cpp
+++ b/src/hwstack.cpp
@@ -28,11 +28,12 @@
#include "avrmalloc.h"
#include "flash.h"
#include <assert.h>
+#include <stdio.h>
using namespace std;
HWStack::HWStack(AvrDevice *c):
- m_ThreadList(*c),
+ m_ThreadList(c),
core(c) {
Reset();
}
@@ -233,7 +234,7 @@ unsigned long ThreeLevelStack::PopAddr() {
return val;
}
-ThreadList::ThreadList(AvrDevice & core)
+ThreadList::ThreadList(AvrDevice* core)
: m_core(core)
{
m_phase_of_switch = eNormal;
@@ -262,12 +263,12 @@ void ThreadList::OnReset()
void ThreadList::OnCall()
{
- m_on_call_sp = m_core.stack->GetStackPointer();
+ m_on_call_sp = m_core->stack->GetStackPointer();
assert(m_on_call_sp != 0x0000);
- m_on_call_ip = m_core.PC * 2;
+ m_on_call_ip = m_core->PC * 2;
Thread * old = m_threads[m_cur_thread];
for(unsigned int i = 0; i < 32; i++) {
- old->registers[i] = (*m_core.R)[i];
+ old->registers[i] = (*(m_core->R))[i];
}
if(0xc9c <= m_on_call_ip && m_on_call_ip <= 0xca4)
@@ -286,7 +287,7 @@ void ThreadList::OnSPRead(int SP_value)
void ThreadList::OnSPWrite( int new_SP )
{
- if( ! m_core.Flash->LooksLikeContextSwitch(m_core.PC*2))
+ if( ! m_core->Flash->LooksLikeContextSwitch(m_core->PC*2))
return;
m_phase_of_switch = (m_phase_of_switch==eWritten) ? eWritten2 : eWritten;
m_last_SP_writen = new_SP;
@@ -309,7 +310,7 @@ void ThreadList::OnPop()
return;
}
m_phase_of_switch = eNormal;
- int addr = m_core.PC * 2;
+ int addr = m_core->PC * 2;
assert(0 <= m_cur_thread && m_cur_thread < (int) m_threads.size());
Thread * old = m_threads[m_cur_thread];
assert(m_on_call_sp != 0x0000);
diff --git a/src/hwstack.h b/src/hwstack.h
index 5f748b3..6bae0f1 100644
--- a/src/hwstack.h
+++ b/src/hwstack.h
@@ -64,10 +64,10 @@ class ThreadList
int m_on_call_ip; ///< Address in a routine calling the context-switch
/// Currently running thread. (Thread index used for querying by GDB is in GdbServer.)
int m_cur_thread;
- AvrDevice & m_core;
+ AvrDevice* m_core;
public:
- ThreadList(AvrDevice & core);
+ ThreadList(AvrDevice* core);
~ThreadList();
void OnReset();
void OnCall();
|