summaryrefslogtreecommitdiffstats
path: root/src/progs/manager/debug_manager.h
blob: 1598287de72959e94b049b9747d532a63ad10957 (plain)
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
/***************************************************************************
 *   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.                                   *
 ***************************************************************************/
#ifndef DEBUG_MANAGER_H
#define DEBUG_MANAGER_H

#include <tqtimer.h>

#include "common/global/log.h"
#include "common/global/purl.h"
#include "common/common/storage.h"
#include "devices/base/generic_device.h"
#include "devices/base/register.h"
#include "breakpoint.h"
#include "prog_manager.h"
#include "progs/base/generic_debug.h"
namespace Coff { class TextObject; }
namespace CDB { class Object; }

namespace Debugger
{
class Manager : public TQObject, public Log::Base, public GenericView
{
Q_OBJECT
  TQ_OBJECT
public:
  Manager();
  virtual ~Manager();
  virtual PURL::Url coffUrl() const = 0;
  virtual const Programmer::Group *programmerGroup() const = 0;
  Programmer::Base *programmer() const { return Programmer::manager->programmer(); }
  virtual const Device::Data *deviceData() const = 0;
  Debugger::Base *debugger() const;
  virtual void updateDevice();
  bool prepareDebugging();
  bool init();
  const Coff::TextObject *coff() const { return _coff; }
  virtual void clear();
  Breakpoint::MarkType breakpointType(const Breakpoint::Data &data) const;
  bool run();
  bool halt();
  bool reset();
  bool step();
  bool readRegister(const Register::TypeData &data);
  bool writeRegister(const Register::TypeData &data, BitValue value);
  BitValue pc() const;
  bool isStepping() const;

public slots:
  void clearBreakpoints();
  virtual bool update(bool gotoPC);
  void setRegisterWatched(const Register::TypeData &data, bool watched);
  bool readAllRegisters();
  void stopWatchAll();

signals:
  void statusChanged(const TQString &text);
  void targetStateChanged();
  void actionMessage(const TQString &text);

protected:
  Coff::TextObject      *_coff;
  TQMap<PURL::Url, uint>  _currentSourceLines;

  void freeActiveBreakpoint();
  bool checkBreakpoint(const Breakpoint::Data &bdata, bool onlyWarn, Address &address);
  bool updateRegisters();
  virtual bool internalInit();
  virtual bool checkState(bool &first);
  virtual Log::View *compileView() = 0;
  virtual bool isProjectSource(const PURL::Url &url) const = 0;
  virtual bool checkIfContinueStepping(bool &continueStepping);

private slots:
  void slotRunTimeout();
  bool doStep(bool first = false, bool continued = true);

private:
  const Device::Data *_data;
  TQTimer _runTimer, _stepTimer;
  TQValueList<Register::TypeData> _readRegisters;

  void computeBreakpointAddresses();
  TQValueList<Address> activeBreakpointAddresses() const;
  void updateBreakpointsDisplay();
  virtual void updateView() { updateView(false); }
  virtual void updateView(bool gotoPC) = 0;
  bool updateRegister(const Register::TypeData &data);
};

extern Manager *manager;

} // namespace

#endif