1 /* Copyright (c) 2010-2020. The SimGrid Team.
2 * All rights reserved. */
4 /* This program is free software; you can redistribute it and/or modify it
5 * under the terms of the license (GNU LGPL) which comes with this package. */
7 #include "simgrid/Exception.hpp"
8 #include "src/instr/instr_private.hpp"
9 #include "xbt/virtu.h" /* xbt::cmdline */
11 extern std::ofstream tracing_file;
16 void dump_generator_version()
18 tracing_file << "#This file was generated using SimGrid-" << SIMGRID_VERSION_MAJOR << "." << SIMGRID_VERSION_MINOR
19 << "." << SIMGRID_VERSION_PATCH << std::endl;
21 for (auto str : simgrid::xbt::cmdline) {
22 tracing_file << str << " ";
24 tracing_file << "]" << std::endl;
27 void dump_comment_file(const std::string& filename)
31 std::ifstream fs(filename.c_str(), std::ifstream::in);
34 throw TracingError(XBT_THROW_POINT,
35 xbt::string_printf("Comment file %s could not be opened for reading.", filename.c_str()));
37 while (not fs.eof()) {
39 std::getline(fs, line);
40 tracing_file << "# " << line;
45 void dump_header(bool basic, bool display_sizes)
48 tracing_file << "%EventDef PajeDefineContainerType " << PAJE_DefineContainerType << std::endl;
49 tracing_file << "% Alias string" << std::endl;
51 tracing_file << "% ContainerType string" << std::endl;
53 tracing_file << "% Type string" << std::endl;
55 tracing_file << "% Name string" << std::endl;
56 tracing_file << "%EndEventDef" << std::endl;
58 tracing_file << "%EventDef PajeDefineVariableType " << PAJE_DefineVariableType << std::endl;
59 tracing_file << "% Alias string" << std::endl;
60 tracing_file << "% " << (basic ? "Container" : "") << "Type string" << std::endl;
61 tracing_file << "% Name string" << std::endl;
62 tracing_file << "% Color color" << std::endl;
63 tracing_file << "%EndEventDef" << std::endl;
65 tracing_file << "%EventDef PajeDefineStateType " << PAJE_DefineStateType << std::endl;
66 tracing_file << "% Alias string" << std::endl;
67 tracing_file << "% " << (basic ? "Container" : "") << "Type string" << std::endl;
68 tracing_file << "% Name string" << std::endl;
69 tracing_file << "%EndEventDef" << std::endl;
71 tracing_file << "%EventDef PajeDefineEventType " << PAJE_DefineEventType << std::endl;
72 tracing_file << "% Alias string" << std::endl;
73 tracing_file << "% " << (basic ? "Container" : "") << "Type string" << std::endl;
74 tracing_file << "% Name string" << std::endl;
75 tracing_file << "%EndEventDef" << std::endl;
77 tracing_file << "%EventDef PajeDefineLinkType " << PAJE_DefineLinkType << std::endl;
78 tracing_file << "% Alias string" << std::endl;
79 tracing_file << "% " << (basic ? "Container" : "") << "Type string" << std::endl;
80 tracing_file << "% " << (basic ? "Source" : "Start") << "ContainerType string" << std::endl;
81 tracing_file << "% " << (basic ? "Dest" : "End") << "ContainerType string" << std::endl;
82 tracing_file << "% Name string" << std::endl;
83 tracing_file << "%EndEventDef" << std::endl;
86 tracing_file << "%EventDef PajeDefineEntityValue " << PAJE_DefineEntityValue << std::endl;
87 tracing_file << "% Alias string" << std::endl;
88 tracing_file << "% " << (basic ? "Entity" : "") << "Type string" << std::endl;
89 tracing_file << "% Name string" << std::endl;
90 tracing_file << "% Color color" << std::endl;
91 tracing_file << "%EndEventDef" << std::endl;
94 tracing_file << "%EventDef PajeCreateContainer " << PAJE_CreateContainer << std::endl;
95 tracing_file << "% Time date" << std::endl;
96 tracing_file << "% Alias string" << std::endl;
97 tracing_file << "% Type string" << std::endl;
98 tracing_file << "% Container string" << std::endl;
99 tracing_file << "% Name string" << std::endl;
100 tracing_file << "%EndEventDef" << std::endl;
102 tracing_file << "%EventDef PajeDestroyContainer " << PAJE_DestroyContainer << std::endl;
103 tracing_file << "% Time date" << std::endl;
104 tracing_file << "% Type string" << std::endl;
105 tracing_file << "% Name string" << std::endl;
106 tracing_file << "%EndEventDef" << std::endl;
109 tracing_file << "%EventDef PajeSetVariable " << PAJE_SetVariable << std::endl;
110 tracing_file << "% Time date" << std::endl;
111 tracing_file << "% Type string" << std::endl;
112 tracing_file << "% Container string" << std::endl;
113 tracing_file << "% Value double" << std::endl;
114 tracing_file << "%EndEventDef" << std::endl;
116 tracing_file << "%EventDef PajeAddVariable " << PAJE_AddVariable << std::endl;
117 tracing_file << "% Time date" << std::endl;
118 tracing_file << "% Type string" << std::endl;
119 tracing_file << "% Container string" << std::endl;
120 tracing_file << "% Value double" << std::endl;
121 tracing_file << "%EndEventDef" << std::endl;
123 tracing_file << "%EventDef PajeSubVariable " << PAJE_SubVariable << std::endl;
124 tracing_file << "% Time date" << std::endl;
125 tracing_file << "% Type string" << std::endl;
126 tracing_file << "% Container string" << std::endl;
127 tracing_file << "% Value double" << std::endl;
128 tracing_file << "%EndEventDef" << std::endl;
131 tracing_file << "%EventDef PajeSetState " << PAJE_SetState << std::endl;
132 tracing_file << "% Time date" << std::endl;
133 tracing_file << "% Type string" << std::endl;
134 tracing_file << "% Container string" << std::endl;
135 tracing_file << "% Value string" << std::endl;
136 tracing_file << "%EndEventDef" << std::endl;
138 tracing_file << "%EventDef PajePushState " << PAJE_PushState << std::endl;
139 tracing_file << "% Time date" << std::endl;
140 tracing_file << "% Type string" << std::endl;
141 tracing_file << "% Container string" << std::endl;
142 tracing_file << "% Value string" << std::endl;
144 tracing_file << "% Size int" << std::endl;
146 if (simgrid::config::get_value<bool>("smpi/trace-call-location")) {
147 /* paje currently (May 2016) uses "Filename" and "Linenumber" as reserved words. We cannot use them... */
148 tracing_file << "% Fname string" << std::endl;
149 tracing_file << "% Lnumber int" << std::endl;
152 tracing_file << "%EndEventDef" << std::endl;
154 tracing_file << "%EventDef PajePopState " << PAJE_PopState << std::endl;
155 tracing_file << "% Time date" << std::endl;
156 tracing_file << "% Type string" << std::endl;
157 tracing_file << "% Container string" << std::endl;
158 tracing_file << "%EndEventDef" << std::endl;
161 tracing_file << "%EventDef PajeResetState " << PAJE_ResetState << std::endl;
162 tracing_file << "% Time date" << std::endl;
163 tracing_file << "% Type string" << std::endl;
164 tracing_file << "% Container string" << std::endl;
165 tracing_file << "%EndEventDef" << std::endl;
169 tracing_file << "%EventDef PajeStartLink " << PAJE_StartLink << std::endl;
170 tracing_file << "% Time date" << std::endl;
171 tracing_file << "% Type string" << std::endl;
172 tracing_file << "% Container string" << std::endl;
173 tracing_file << "% Value string" << std::endl;
174 tracing_file << "% " << (basic ? "Source" : "Start") << "Container string" << std::endl;
175 tracing_file << "% Key string" << std::endl;
177 tracing_file << "% Size int" << std::endl;
178 tracing_file << "%EndEventDef" << std::endl;
180 tracing_file << "%EventDef PajeEndLink " << PAJE_EndLink << std::endl;
181 tracing_file << "% Time date" << std::endl;
182 tracing_file << "% Type string" << std::endl;
183 tracing_file << "% Container string" << std::endl;
184 tracing_file << "% Value string" << std::endl;
185 tracing_file << "% " << (basic ? "Dest" : "End") << "Container string" << std::endl;
186 tracing_file << "% Key string" << std::endl;
187 tracing_file << "%EndEventDef" << std::endl;
190 tracing_file << "%EventDef PajeNewEvent " << PAJE_NewEvent << std::endl;
191 tracing_file << "% Time date" << std::endl;
192 tracing_file << "% Type string" << std::endl;
193 tracing_file << "% Container string" << std::endl;
194 tracing_file << "% Value string" << std::endl;
195 tracing_file << "%EndEventDef" << std::endl;
199 } // namespace simgrid