OpenASIP 2.2
Loading...
Searching...
No Matches
ConditionCommand.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 ConditionCommand.cc
26 *
27 * Implementation of ConditionCommand class
28 *
29 * @author Pekka Jääskeläinen 2005 (pjaaskel-no.spam-cs.tut.fi)
30 * @note rating: red
31 */
32
33#include "ConditionCommand.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 "TclConditionScript.hh"
44
45#include <iostream>
46
47/**
48 * Constructor.
49 *
50 * Sets the name of the command to the base class.
51 */
55
56/**
57 * Destructor.
58 *
59 * Does nothing.
60 */
63
64/**
65 * Executes the "condition" command.
66 *
67 * Modifies conditions of breakpoints.
68 *
69 * @param arguments The handle of the breakpoint of which condition to modify.
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 */
74bool
75ConditionCommand::execute(const std::vector<DataObject>& arguments) {
76 if (!checkArgumentCount(arguments.size() - 1, 1, 1)) {
77 return false;
78 }
79
82 return false;
83 }
84 }
85
86 if (arguments.size() == 2) {
87 if (!checkIntegerArgument(arguments[1])) {
88 return false;
89 }
90 const int breakpointHandle = arguments[1].integerValue();
91 try {
92 StopPointManager& stopPointManager =
94 stopPointManager.stopPointWithHandleConst(breakpointHandle);
95
96 TclConditionScript condition(NULL, "");
97 if (!askConditionFromUser(condition)) {
98 return false;
99 }
100 assert(condition.script().size() > 0);
101 if (condition.script().at(0) == "1") {
102 stopPointManager.removeCondition(breakpointHandle);
103 } else {
104 stopPointManager.setCondition(breakpointHandle, condition);
105 }
106 printBreakpointInfo(breakpointHandle);
107 } catch (const InstanceNotFound&) {
111 return false;
112 }
113
114
115 }
116 return true;
117}
118
119/**
120 * Returns the help text for this command.
121 *
122 * Help text is searched from SimulatorTextGenerator.
123 *
124 * @return The help text.
125 * @todo Use SimulatorTextGenerator to get the help text.
126 */
127std::string
#define assert(condition)
virtual ~ConditionCommand()
virtual bool execute(const std::vector< DataObject > &arguments)
virtual std::string helpText() const
bool checkArgumentCount(int argumentCount, int minimum, int maximum)
bool checkIntegerArgument(const DataObject &argument)
ScriptInterpreter * interpreter() const
virtual void setError(bool state)
virtual bool printBreakpointInfo(unsigned int breakpointHandle)
bool askConditionFromUser(TclConditionScript &target)
StopPointManager & stopPointManager()
static SimulatorTextGenerator & textGenerator()
void removeCondition(unsigned int handle)
void setCondition(unsigned int handle, const ConditionScript &condition)
const StopPoint & stopPointWithHandleConst(unsigned int handle) const
virtual std::vector< std::string > script() const
virtual boost::format text(int textId)
@ TXT_INTERP_HELP_CONDITION
Help text for command "condition" of the CLI.