Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Quick tests show that currentContainer is always empty at this point.
[simgrid.git] / src / instr / instr_paje_header.cpp
1 /* Copyright (c) 2010-2023. The SimGrid Team. All rights reserved.          */
2
3 /* This program is free software; you can redistribute it and/or modify it
4  * under the terms of the license (GNU LGPL) which comes with this package. */
5
6 #include "simgrid/version.h"
7 #include "src/instr/instr_private.hpp"
8 #include "src/smpi/include/private.hpp"
9 #include <simgrid/Exception.hpp>
10 #include <simgrid/s4u/Engine.hpp>
11
12 extern std::ofstream tracing_file;
13 namespace simgrid::instr::paje {
14
15 void dump_generator_version()
16 {
17   tracing_file << "#This file was generated using SimGrid-" << SIMGRID_VERSION_MAJOR << "." << SIMGRID_VERSION_MINOR
18                << "." << SIMGRID_VERSION_PATCH << '\n';
19   tracing_file << "#[";
20   for (auto const& str : simgrid::s4u::Engine::get_instance()->get_cmdline()) {
21     tracing_file << str << " ";
22   }
23   tracing_file << "]\n";
24 }
25
26 void dump_comment_file(const std::string& filename)
27 {
28   if (filename.empty())
29     return;
30   std::ifstream fs(filename.c_str(), std::ifstream::in);
31
32   if (fs.fail())
33     throw TracingError(XBT_THROW_POINT,
34                        xbt::string_printf("Comment file %s could not be opened for reading.", filename.c_str()));
35
36   std::string line;
37   while (std::getline(fs, line))
38     tracing_file << "# " << line;
39   fs.close();
40 }
41
42 void dump_header(bool basic, bool display_sizes)
43 {
44   // Types
45   tracing_file << "%EventDef PajeDefineContainerType " << PajeEventType::DefineContainerType << '\n';
46   tracing_file << "%       Alias string\n";
47   if (basic)
48     tracing_file << "%       ContainerType string\n";
49   else
50     tracing_file << "%       Type string\n";
51
52   tracing_file << "%       Name string\n";
53   tracing_file << "%EndEventDef\n";
54
55   tracing_file << "%EventDef PajeDefineVariableType " << PajeEventType::DefineVariableType << '\n';
56   tracing_file << "%       Alias string\n";
57   tracing_file << "%       " << (basic ? "Container" : "") << "Type string\n";
58   tracing_file << "%       Name string\n";
59   tracing_file << "%       Color color\n";
60   tracing_file << "%EndEventDef\n";
61
62   tracing_file << "%EventDef PajeDefineStateType " << PajeEventType::DefineStateType << '\n';
63   tracing_file << "%       Alias string\n";
64   tracing_file << "%       " << (basic ? "Container" : "") << "Type string\n";
65   tracing_file << "%       Name string\n";
66   tracing_file << "%EndEventDef\n";
67
68   tracing_file << "%EventDef PajeDefineEventType " << PajeEventType::DefineEventType << '\n';
69   tracing_file << "%       Alias string\n";
70   tracing_file << "%       " << (basic ? "Container" : "") << "Type string\n";
71   tracing_file << "%       Name string\n";
72   tracing_file << "%EndEventDef\n";
73
74   tracing_file << "%EventDef PajeDefineLinkType " << PajeEventType::DefineLinkType << '\n';
75   tracing_file << "%       Alias string\n";
76   tracing_file << "%       " << (basic ? "Container" : "") << "Type string\n";
77   tracing_file << "%       " << (basic ? "Source" : "Start") << "ContainerType string\n";
78   tracing_file << "%       " << (basic ? "Dest" : "End") << "ContainerType string\n";
79   tracing_file << "%       Name string\n";
80   tracing_file << "%EndEventDef\n";
81
82   // EntityValue
83   tracing_file << "%EventDef PajeDefineEntityValue " << PajeEventType::DefineEntityValue << '\n';
84   tracing_file << "%       Alias string\n";
85   tracing_file << "%       " << (basic ? "Entity" : "") << "Type string\n";
86   tracing_file << "%       Name string\n";
87   tracing_file << "%       Color color\n";
88   tracing_file << "%EndEventDef\n";
89
90   // Container
91   tracing_file << "%EventDef PajeCreateContainer " << PajeEventType::CreateContainer << '\n';
92   tracing_file << "%       Time date\n";
93   tracing_file << "%       Alias string\n";
94   tracing_file << "%       Type string\n";
95   tracing_file << "%       Container string\n";
96   tracing_file << "%       Name string\n";
97   tracing_file << "%EndEventDef\n";
98
99   tracing_file << "%EventDef PajeDestroyContainer " << PajeEventType::DestroyContainer << '\n';
100   tracing_file << "%       Time date\n";
101   tracing_file << "%       Type string\n";
102   tracing_file << "%       Name string\n";
103   tracing_file << "%EndEventDef\n";
104
105   // Variable
106   tracing_file << "%EventDef PajeSetVariable " << PajeEventType::SetVariable << '\n';
107   tracing_file << "%       Time date\n";
108   tracing_file << "%       Type string\n";
109   tracing_file << "%       Container string\n";
110   tracing_file << "%       Value double\n";
111   tracing_file << "%EndEventDef\n";
112
113   tracing_file << "%EventDef PajeAddVariable " << PajeEventType::AddVariable << '\n';
114   tracing_file << "%       Time date\n";
115   tracing_file << "%       Type string\n";
116   tracing_file << "%       Container string\n";
117   tracing_file << "%       Value double\n";
118   tracing_file << "%EndEventDef\n";
119
120   tracing_file << "%EventDef PajeSubVariable " << PajeEventType::SubVariable << '\n';
121   tracing_file << "%       Time date\n";
122   tracing_file << "%       Type string\n";
123   tracing_file << "%       Container string\n";
124   tracing_file << "%       Value double\n";
125   tracing_file << "%EndEventDef\n";
126
127   // State
128   tracing_file << "%EventDef PajeSetState " << PajeEventType::SetState << '\n';
129   tracing_file << "%       Time date\n";
130   tracing_file << "%       Type string\n";
131   tracing_file << "%       Container string\n";
132   tracing_file << "%       Value string\n";
133   tracing_file << "%EndEventDef\n";
134
135   tracing_file << "%EventDef PajePushState " << PajeEventType::PushState << '\n';
136   tracing_file << "%       Time date\n";
137   tracing_file << "%       Type string\n";
138   tracing_file << "%       Container string\n";
139   tracing_file << "%       Value string\n";
140   if (display_sizes)
141     tracing_file << "%       Size int\n";
142 #if HAVE_SMPI
143   if (smpi_cfg_trace_call_location()) {
144     /* paje currently (May 2016) uses "Filename" and "Linenumber" as reserved words. We cannot use them... */
145     tracing_file << "%       Fname string\n";
146     tracing_file << "%       Lnumber int\n";
147   }
148 #endif
149   tracing_file << "%EndEventDef\n";
150
151   tracing_file << "%EventDef PajePopState " << PajeEventType::PopState << '\n';
152   tracing_file << "%       Time date\n";
153   tracing_file << "%       Type string\n";
154   tracing_file << "%       Container string\n";
155   tracing_file << "%EndEventDef\n";
156
157   if (not basic) {
158     tracing_file << "%EventDef PajeResetState " << PajeEventType::ResetState << '\n';
159     tracing_file << "%       Time date\n";
160     tracing_file << "%       Type string\n";
161     tracing_file << "%       Container string\n";
162     tracing_file << "%EndEventDef\n";
163   }
164
165   // Link
166   tracing_file << "%EventDef PajeStartLink " << PajeEventType::StartLink << '\n';
167   tracing_file << "%       Time date\n";
168   tracing_file << "%       Type string\n";
169   tracing_file << "%       Container string\n";
170   tracing_file << "%       Value string\n";
171   tracing_file << "%       " << (basic ? "Source" : "Start") << "Container string\n";
172   tracing_file << "%       Key string\n";
173   if (display_sizes)
174     tracing_file << "%       Size int\n";
175   tracing_file << "%EndEventDef\n";
176
177   tracing_file << "%EventDef PajeEndLink " << PajeEventType::EndLink << '\n';
178   tracing_file << "%       Time date\n";
179   tracing_file << "%       Type string\n";
180   tracing_file << "%       Container string\n";
181   tracing_file << "%       Value string\n";
182   tracing_file << "%       " << (basic ? "Dest" : "End") << "Container string\n";
183   tracing_file << "%       Key string\n";
184   tracing_file << "%EndEventDef\n";
185
186   // Event
187   tracing_file << "%EventDef PajeNewEvent " << PajeEventType::NewEvent << '\n';
188   tracing_file << "%       Time date\n";
189   tracing_file << "%       Type string\n";
190   tracing_file << "%       Container string\n";
191   tracing_file << "%       Value string\n";
192   tracing_file << "%EndEventDef\n";
193 }
194 } // namespace simgrid::instr::paje