HPCToolkit
main.cpp
Go to the documentation of this file.
1 // -*-Mode: C++;-*-
2 
3 // * BeginRiceCopyright *****************************************************
4 //
5 // $HeadURL$
6 // $Id$
7 //
8 // --------------------------------------------------------------------------
9 // Part of HPCToolkit (hpctoolkit.org)
10 //
11 // Information about sources of support for research and development of
12 // HPCToolkit is at 'hpctoolkit.org' and in 'README.Acknowledgments'.
13 // --------------------------------------------------------------------------
14 //
15 // Copyright ((c)) 2002-2019, Rice University
16 // All rights reserved.
17 //
18 // Redistribution and use in source and binary forms, with or without
19 // modification, are permitted provided that the following conditions are
20 // met:
21 //
22 // * Redistributions of source code must retain the above copyright
23 // notice, this list of conditions and the following disclaimer.
24 //
25 // * Redistributions in binary form must reproduce the above copyright
26 // notice, this list of conditions and the following disclaimer in the
27 // documentation and/or other materials provided with the distribution.
28 //
29 // * Neither the name of Rice University (RICE) nor the names of its
30 // contributors may be used to endorse or promote products derived from
31 // this software without specific prior written permission.
32 //
33 // This software is provided by RICE and contributors "as is" and any
34 // express or implied warranties, including, but not limited to, the
35 // implied warranties of merchantability and fitness for a particular
36 // purpose are disclaimed. In no event shall RICE or contributors be
37 // liable for any direct, indirect, incidental, special, exemplary, or
38 // consequential damages (including, but not limited to, procurement of
39 // substitute goods or services; loss of use, data, or profits; or
40 // business interruption) however caused and on any theory of liability,
41 // whether in contract, strict liability, or tort (including negligence
42 // or otherwise) arising in any way out of the use of this software, even
43 // if advised of the possibility of such damage.
44 //
45 // ******************************************************* EndRiceCopyright *
46 
47 //************************ System Include Files ******************************
48 
49 #include <iostream>
50 #include <fstream>
51 #include <iomanip>
52 
53 #include <string>
54 using std::string;
55 
56 #include <exception>
57 
58 //*********************** Xerces Include Files *******************************
59 
60 //************************* User Include Files *******************************
61 
62 #include "Args.hpp"
63 
66 #include <lib/analysis/Raw.hpp>
67 
69 #include <lib/support/NaN.h>
70 
71 //************************ Forward Declarations ******************************
72 
73 static int
74 realmain(int argc, char* const* argv);
75 
76 static int
77 main_rawData(const std::vector<string>& profileFiles);
78 
79 
80 //****************************************************************************
81 
82 void
84 (
85  int error_code
86 )
87 {
88  exit(error_code);
89 }
90 
91 
92 int
93 main(int argc, char* const* argv)
94 {
95  int ret;
96 
97  try {
98  ret = realmain(argc, argv);
99  }
100  catch (const Diagnostics::Exception& x) {
101  DIAG_EMsg(x.message());
102  exit(1);
103  }
104  catch (const std::bad_alloc& x) {
105  DIAG_EMsg("[std::bad_alloc] " << x.what());
106  exit(1);
107  }
108  catch (const std::exception& x) {
109  DIAG_EMsg("[std::exception] " << x.what());
110  exit(1);
111  }
112  catch (...) {
113  DIAG_EMsg("Unknown exception encountered!");
114  exit(2);
115  }
116 
117  return ret;
118 }
119 
120 
121 static int
122 realmain(int argc, char* const* argv)
123 {
124  Args args(argc, argv); // exits if error on command line
125  return main_rawData(args.profileFiles);
126 }
127 
128 
129 //****************************************************************************
130 //
131 //****************************************************************************
132 
133 static int
134 main_rawData(const std::vector<string>& profileFiles)
135 {
136  std::ostream& os = std::cout;
137 
138  for (uint i = 0; i < profileFiles.size(); ++i) {
139  const char* fnm = profileFiles[i].c_str();
140 
141  // generate nice header
142  os << std::setfill('=') << std::setw(77) << "=" << std::endl;
143  os << fnm << std::endl;
144  os << std::setfill('=') << std::setw(77) << "=" << std::endl;
145 
146  Analysis::Raw::writeAsText(fnm); // pass os FIXME
147  }
148  return 0;
149 }
150 
151 //****************************************************************************
Definition: Args.hpp:79
void prof_abort(int error_code)
Definition: main.cpp:98
#define DIAG_EMsg(...)
Definition: diagnostics.h:251
static int realmain(int argc, char *const *argv)
Definition: main.cpp:122
virtual std::string message() const
Definition: Exception.hpp:134
static int main_rawData(const std::vector< string > &profileFiles)
Definition: main.cpp:134
exit
Definition: names.cpp:1
unsigned int uint
Definition: uint.h:124
int main(int argc, char *argv[])
Definition: main.cpp:125
std::vector< std::string > profileFiles
Definition: Args.hpp:138
void writeAsText(const char *filenm)
Definition: Raw.cpp:88