OpenASIP  2.0
Classes | Functions
DumpTPEF.cc File Reference
#include <ostream>
#include "Exception.hh"
#include "CmdLineOptions.hh"
#include "BinaryReader.hh"
#include "BinaryStream.hh"
#include "Binary.hh"
#include "TPEFDumper.hh"
#include "tce_config.h"
Include dependency graph for DumpTPEF.cc:

Go to the source code of this file.

Classes

class  DumperCmdLineOptions
 

Functions

int main (int argc, char *argv[])
 

Detailed Description

Program for outputting TPEF hierarchy in textual format.

Author
Mikael Lepist� 2005 (tmlepist-no.spam-tut.fi)
Note
rating: red

Definition in file DumpTPEF.cc.

Function Documentation

◆ main()

int main ( int  argc,
char *  argv[] 
)

Calls TPEFDumper with parameters given in commandline.

Definition at line 179 of file DumpTPEF.cc.

179  {
180 
182 
183  try {
184  options.parse(argv, argc);
185  } catch (ParserStopRequest) {
186  return 0;
187  } catch (IllegalCommandLine& e) {
188  std::cerr << "Illegal command line parameters: "
189  << e.errorMessage() << std::endl;
190 
191  options.printHelp();
192  return 0;
193  }
194 
195  if (options.numberOfArguments() != 1) {
196  std::cerr << "Error: Must give input binary file.\n\n";
197  options.printHelp();
198  return 0;
199  }
200 
201  BinaryStream stream(options.argument(1));
202 
203  Binary* tpef = NULL;
204  try {
205  tpef = BinaryReader::readBinary(stream);
206  } catch (UnresolvedReference& e) {
207  std::cerr
208  << "Misread the input file: " << options.argument(1) << std::endl
209  << "error: " << e.errorMessage() << std::endl;
210  return 0;
211  } catch (const Exception& e) {
212  std::cerr
213  << "Can't read input file: " << options.argument(1) << std::endl
214  << "error: " << e.errorMessage() << std::endl;
215  return 0;
216  }
217 
218  TPEFDumper dumper(*tpef, std::cout);
219 
220  dumper.setOnlyLogical(options.onlyLogicalInfo());
221 
222  if (options.printFileHeaders()) {
223  dumper.fileHeaders();
224  }
225 
226  if (options.printSectionHeaders()) {
227  dumper.sectionHeaders();
228  }
229 
230  if (options.printMemoryInfo()) {
231  dumper.memoryInfo();
232  }
233 
234  if (options.printSymbols()) {
235  dumper.symbolTables();
236  }
237 
238  if (options.printRelocations()) {
239  dumper.relocationTables();
240  }
241 
242  for (int i = 1; i < options.sectionIdCount() + 1; i++) {
243  dumper.section(options.sectionId(i));
244  }
245 
246  delete tpef;
247 
248  return 0;
249 }

References CmdLineParser::argument(), Exception::errorMessage(), TPEFDumper::fileHeaders(), TPEFDumper::memoryInfo(), CmdLineParser::numberOfArguments(), options, CmdLineOptions::parse(), MachInfoCmdLineOptions::printHelp(), TPEFDumper::relocationTables(), TPEFDumper::section(), TPEFDumper::sectionHeaders(), TPEFDumper::setOnlyLogical(), and TPEFDumper::symbolTables().

Here is the call graph for this function:
MachInfoCmdLineOptions::printHelp
virtual void printHelp() const
Definition: MachInfoCmdLineOptions.cc:89
UnresolvedReference
Definition: Exception.hh:370
ParserStopRequest
Definition: Exception.hh:491
CmdLineParser::numberOfArguments
virtual int numberOfArguments() const
TPEF::Binary
Definition: Binary.hh:49
TPEF::BinaryStream
Definition: BinaryStream.hh:59
IllegalCommandLine
Definition: Exception.hh:438
DumperCmdLineOptions
Definition: DumpTPEF.cc:90
TPEFDumper
Definition: TPEFDumper.hh:51
Exception
Definition: Exception.hh:54
Exception::errorMessage
std::string errorMessage() const
Definition: Exception.cc:123
CmdLineOptions::parse
void parse(char *argv[], int argc)
Definition: CmdLineOptions.cc:107
options
static MachInfoCmdLineOptions options
Definition: MachInfo.cc:46
CmdLineParser::argument
virtual std::string argument(int index) const