1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
|
/***************************************************************************
* Copyright (C) 2006 Nicolas Hadacek <hadacek@kde.org> *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
***************************************************************************/
#include "generic_debug.h"
#include "common/global/global.h"
#include "generic_prog.h"
#include "devices/base/register.h"
#include "devices/base/device_group.h"
#include "devices/pic/base/pic.h"
//----------------------------------------------------------------------------
Debugger::Base::Base(Programmer::Base &programmer)
: Log::Base(&programmer), _programmer(programmer), _deviceSpecific(0),
_specific(0), _inputType(PURL::Nb_FileTypes), _coff(0)
{}
void Debugger::Base::init(DeviceSpecific *deviceSpecific, Specific *specific)
{
_deviceSpecific = deviceSpecific;
_specific = specific;
}
Debugger::Base::~Base()
{
delete _deviceSpecific;
delete _specific;
}
const Device::Data *Debugger::Base::device() const
{
return _programmer.device();
}
bool Debugger::Base::init()
{
_programmer.setState(Programmer::Stopped);
log(Log::LineType::Information, i18n("Setting up debugging session."));
if ( !internalInit() ) {
log(Log::LineType::Error, i18n("Failed to initialize device for debugging."));
return false;
}
log(Log::LineType::Information, i18n("Ready to start debugging."));
_programmer.setState(Programmer::Halted);
return update();
}
bool Debugger::Base::update()
{
if ( !updateState() ) return false;
if ( _programmer.state()==::Programmer::Halted ) return _deviceSpecific->updateStatus();
return true;
}
bool Debugger::Base::run()
{
if ( !internalRun() ) return false;
_programmer.setState(::Programmer::Running);
return update();
}
bool Debugger::Base::step()
{
if ( !internalStep() ) return false;
return update();
}
bool Debugger::Base::halt()
{
bool success;
if ( !softHalt(success) ) return false;
if ( !success ) return hardHalt();
if ( !update() ) return false;
log(Log::LineType::Information, QString("Halted at %1").arg(toHexLabel(pc(), _programmer.device()->nbCharsAddress())));
_programmer.setState(::Programmer::Halted);
return true;
}
bool Debugger::Base::reset()
{
if ( !internalReset() ) return false;
return update();
}
QString Debugger::Base::statusString() const
{
if ( _programmer.state()!=::Programmer::Halted ) return QString::null;
return _deviceSpecific->statusString();
}
void Debugger::Base::setupInput(PURL::FileType type, const QString &directory, const QString &filename)
{
_inputType = type;
_directory = directory;
_filename = filename;
}
BitValue Debugger::Base::pc() const
{
return Register::list().value(pcTypeData());
}
Register::TypeData Debugger::Base::pcTypeData() const
{
return Register::TypeData("PC", 2*device()->nbBytesAddress());
}
|