OpenASIP  2.0
EnableBPCommand.cc
Go to the documentation of this file.
1 /*
2  Copyright (c) 2002-2009 Tampere University.
3 
4  This file is part of TTA-Based Codesign Environment (TCE).
5 
6  Permission is hereby granted, free of charge, to any person obtaining a
7  copy of this software and associated documentation files (the "Software"),
8  to deal in the Software without restriction, including without limitation
9  the rights to use, copy, modify, merge, publish, distribute, sublicense,
10  and/or sell copies of the Software, and to permit persons to whom the
11  Software is furnished to do so, subject to the following conditions:
12 
13  The above copyright notice and this permission notice shall be included in
14  all copies or substantial portions of the Software.
15 
16  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19  THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21  FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22  DEALINGS IN THE SOFTWARE.
23  */
24 /**
25  * @file EnableBPCommand.cc
26  *
27  * Implementation of EnableBPCommand class
28  *
29  * @author Pekka Jääskeläinen 2005 (pjaaskel-no.spam-cs.tut.fi)
30  * @note rating: red
31  */
32 
33 #include "EnableBPCommand.hh"
34 #include "Application.hh"
35 #include "FileSystem.hh"
36 #include "SimulatorFrontend.hh"
38 #include "Exception.hh"
39 #include "SimulatorToolbox.hh"
41 #include "SimValue.hh"
42 #include "StopPointManager.hh"
43 #include "StringTools.hh"
44 
45 #include <iostream>
46 
47 /**
48  * Constructor.
49  *
50  * Sets the name of the command to the base class.
51  */
53  SimControlLanguageCommand("enablebp") {
54 }
55 
56 /**
57  * Destructor.
58  *
59  * Does nothing.
60  */
62 }
63 
64 /**
65  * Executes the "enablebp" command.
66  *
67  * Enables the given breakpoints.
68  *
69  * @param arguments The handle(s) of the breakpoint(s) to enable.
70  * @return True in case simulation is initialized and arguments are ok.
71  * @exception NumberFormatException Is never thrown by this command.
72  * @todo Use the count for the step.
73  */
74 bool
75 EnableBPCommand::execute(const std::vector<DataObject>& arguments) {
76  if (!checkArgumentCount(arguments.size() - 1, 1, INT_MAX)) {
77  return false;
78  }
79 
80  if (!checkSimulationStopped()) {
82  return false;
83  }
84  }
85 
86  const std::string firstArgument =
88  arguments[1].stringValue()));
89 
90  bool enableOnce = false;
91  bool temporary = false;
92  int firstHandleIndex = 1;
93  if (firstArgument == "once") {
94  enableOnce = true;
95  firstHandleIndex = 2;
96  } else if (firstArgument == "delete") {
97  temporary = true;
98  firstHandleIndex = 2;
99  }
100 
101  StopPointManager& breakpointManager =
103 
104  if (!verifyBreakpointHandles(arguments, firstHandleIndex)) {
105  return false;
106  }
107 
108  // enable (and modify the properties of) the given breakpoints
109  for (size_t i = firstHandleIndex; i < arguments.size(); ++i) {
110  const unsigned int breakpointHandle = arguments[i].integerValue();
111  breakpointManager.enable(breakpointHandle);
112  if (enableOnce) {
113  breakpointManager.enableOnceAndDisable(breakpointHandle);
114  }
115  if (temporary) {
116  breakpointManager.enableOnceAndDelete(breakpointHandle);
117  }
118  printBreakpointInfo(breakpointHandle);
119  }
120  return true;
121 }
122 
123 /**
124  * Returns the help text for this command.
125  *
126  * Help text is searched from SimulatorTextGenerator.
127  *
128  * @return The help text.
129  * @todo Use SimulatorTextGenerator to get the help text.
130  */
131 std::string
135 }
StopPointManager::enableOnceAndDelete
void enableOnceAndDelete(unsigned int handle)
Definition: StopPointManager.cc:172
StopPointManager.hh
CustomCommand::checkArgumentCount
bool checkArgumentCount(int argumentCount, int minimum, int maximum)
Definition: CustomCommand.cc:82
FileSystem.hh
SimControlLanguageCommand::checkSimulationStopped
bool checkSimulationStopped()
Definition: SimControlLanguageCommand.cc:135
SimulatorInterpreterContext.hh
Exception.hh
EnableBPCommand::EnableBPCommand
EnableBPCommand()
Definition: EnableBPCommand.cc:52
EnableBPCommand::execute
virtual bool execute(const std::vector< DataObject > &arguments)
Definition: EnableBPCommand.cc:75
StopPointManager::enableOnceAndDisable
void enableOnceAndDisable(unsigned int handle)
Definition: StopPointManager.cc:187
Texts::TXT_INTERP_HELP_ENABLEBP
@ TXT_INTERP_HELP_ENABLEBP
Help text for command "enablebp" of the CLI.
Definition: SimulatorTextGenerator.hh:97
EnableBPCommand::helpText
virtual std::string helpText() const
Definition: EnableBPCommand.cc:132
Texts::TextGenerator::text
virtual boost::format text(int textId)
Definition: TextGenerator.cc:94
EnableBPCommand.hh
SimControlLanguageCommand::verifyBreakpointHandles
bool verifyBreakpointHandles(const std::vector< DataObject > &arguments, std::size_t startIndex=1)
Definition: SimControlLanguageCommand.cc:712
StringTools.hh
SimulatorToolbox.hh
StopPointManager::enable
void enable(unsigned int handle)
Definition: StopPointManager.cc:149
StopPointManager
Definition: StopPointManager.hh:50
Application.hh
SimulatorToolbox::textGenerator
static SimulatorTextGenerator & textGenerator()
Definition: SimulatorToolbox.cc:75
SimulatorTextGenerator.hh
SimControlLanguageCommand::checkSimulationInitialized
bool checkSimulationInitialized()
Definition: SimControlLanguageCommand.cc:88
SimulatorFrontend.hh
StringTools::trim
static std::string trim(const std::string &source)
Definition: StringTools.cc:55
SimValue.hh
SimControlLanguageCommand
Definition: SimControlLanguageCommand.hh:63
SimControlLanguageCommand::simulatorFrontend
SimulatorFrontend & simulatorFrontend()
Definition: SimControlLanguageCommand.cc:214
EnableBPCommand::~EnableBPCommand
virtual ~EnableBPCommand()
Definition: EnableBPCommand.cc:61
temporary
SimValue * temporary
Definition: POMGenMacros.hh:76
StringTools::stringToLower
static std::string stringToLower(const std::string &source)
Definition: StringTools.cc:160
SimulatorFrontend::stopPointManager
StopPointManager & stopPointManager()
Definition: SimulatorFrontend.cc:2108
SimControlLanguageCommand::printBreakpointInfo
virtual bool printBreakpointInfo(unsigned int breakpointHandle)
Definition: SimControlLanguageCommand.cc:678