mark_color = white;
XBT_DEBUG("MARK,declare_value %s %s %s", mark_type, mark_value, mark_color);
- new simgrid::instr::Value(mark_value, mark_color, type);
+ simgrid::instr::Value::byNameOrCreate(mark_value, mark_color, type);
}
/** \ingroup TRACE_mark
XBT_DEBUG("MARK %s %s", mark_type, mark_value);
new simgrid::instr::NewEvent(MSG_get_clock(), PJ_container_get_root(), type,
- simgrid::instr::Value::get(mark_value, type));
+ simgrid::instr::Value::byName(mark_value, type));
}
/** \ingroup TRACE_mark
{
container_t container = PJ_container_get(host);
simgrid::instr::Type* type = container->type_->getChild(state);
- simgrid::instr::Value* val = simgrid::instr::Value::get_or_new(
- value_str, nullptr, type); /* if user didn't declare a value with a color, use nullptr color */
+ simgrid::instr::Value* val = simgrid::instr::Value::byNameOrCreate(
+ value_str, "", type); /* if user didn't declare a value with a color, use no color */
new simgrid::instr::SetStateEvent(MSG_get_clock(), container, type, val);
}
{
container_t container = PJ_container_get(host);
simgrid::instr::Type* type = container->type_->getChild(state);
- simgrid::instr::Value* val = simgrid::instr::Value::get_or_new(
- value_str, nullptr, type); /* if user didn't declare a value with a color, use nullptr color */
+ simgrid::instr::Value* val = simgrid::instr::Value::byNameOrCreate(
+ value_str, "", type); /* if user didn't declare a value with a color, use no color */
new simgrid::instr::PushStateEvent(MSG_get_clock(), container, type, val);
}
}
}
-void LogEntityValue(simgrid::instr::Value* val)
+void simgrid::instr::Value::print()
{
XBT_DEBUG("%s: event_type=%d", __FUNCTION__, simgrid::instr::PAJE_DefineEntityValue);
//print it
if (instr_fmt_type == instr_fmt_paje) {
stream << std::fixed << std::setprecision(TRACE_precision());
stream << simgrid::instr::PAJE_DefineEntityValue;
- stream << " " << val->id_ << " " << val->father_->id_ << " " << val->name_;
- if (val->color_)
- stream << " \"" << val->color_ << "\"";
+ stream << " " << id_ << " " << father_->id_ << " " << name_;
+ if (isColored())
+ stream << " \"" << color_ << "\"";
print_row();
} else if (instr_fmt_type == instr_fmt_TI) {
/* Nothing to do */
stream << (int)this->eventType_;
print_timestamp(this);
stream << " " << type->id_ << " " << container->id_;
- stream << " " << value->id_;
+ stream << " " << value->getId();
#if HAVE_SMPI
if (xbt_cfg_get_boolean("smpi/trace-call-location")) {
stream << " \"" << filename << "\" " << linenumber;
stream << (int)this->eventType_;
print_timestamp(this);
stream << " " << type->id_ << " " << container->id_;
- stream << " " << value->id_;
+ stream << " " << value->getId();
if (TRACE_display_sizes()) {
stream << " ";
case TRACING_SSEND:
case TRACING_ISSEND:
default:
- XBT_WARN("Call from %s impossible to translate into replay command : Not implemented (yet)", value->name_);
+ XBT_WARN("Call from %s impossible to translate into replay command : Not implemented (yet)", value->getCname());
break;
}
stream << std::fixed << std::setprecision(TRACE_precision());
stream << (int)this->eventType_;
print_timestamp(this);
- stream << " " << type->id_ << " " << container->id_ << " " << val->id_;
+ stream << " " << type->id_ << " " << container->id_ << " " << val->getId();
print_row();
} else if (instr_fmt_type == instr_fmt_TI) {
/* Nothing to do */
char *value_name;
xbt_dict_cursor_t cursor = nullptr;
xbt_dict_foreach (values_, cursor, value_name, val) {
- XBT_DEBUG("free value %s, child of %s", val->name_, val->father_->name_);
+ XBT_DEBUG("free value %s, child of %s", val->getCname(), val->father_->name_);
delete val;
}
xbt_dict_free(&values_);
XBT_LOG_NEW_DEFAULT_SUBCATEGORY (instr_paje_values, instr, "Paje tracing event system (values)");
-simgrid::instr::Value::Value(const char* name, const char* color, simgrid::instr::Type* father) : father_(father)
+simgrid::instr::Value::Value(std::string name, std::string color, simgrid::instr::Type* father) : father_(father)
{
- if (name == nullptr || father == nullptr){
- THROWF (tracing_error, 0, "can't create a value with a nullptr name (or a nullptr father)");
+ if (name.empty() || father == nullptr) {
+ THROWF(tracing_error, 0, "can't create a value with no name (or a nullptr father)");
}
- this->name_ = xbt_strdup(name);
- this->color_ = xbt_strdup(color);
+ this->name_ = name;
+ this->color_ = color;
+ this->id_ = std::to_string(instr_new_paje_id());
- this->id_ = bprintf("%lld", instr_new_paje_id());
-
- xbt_dict_set(father->values_, name, this, nullptr);
- XBT_DEBUG("new value %s, child of %s", name_, father_->name_);
- LogEntityValue(this);
+ xbt_dict_set(father->values_, name.c_str(), this, nullptr);
+ XBT_DEBUG("new value %s, child of %s", name_.c_str(), father_->name_);
+ print();
};
-simgrid::instr::Value::~Value()
-{
- xbt_free(name_);
- xbt_free(color_);
- xbt_free(id_);
-}
-
-simgrid::instr::Value* simgrid::instr::Value::get_or_new(const char* name, const char* color,
- simgrid::instr::Type* father)
+simgrid::instr::Value* simgrid::instr::Value::byNameOrCreate(std::string name, std::string color,
+ simgrid::instr::Type* father)
{
Value* ret = 0;
try {
- ret = Value::get(name, father);
+ ret = Value::byName(name, father);
}
catch(xbt_ex& e) {
ret = new Value(name, color, father);
return ret;
}
-simgrid::instr::Value* simgrid::instr::Value::get(const char* name, Type* father)
+simgrid::instr::Value* simgrid::instr::Value::byName(std::string name, Type* father)
{
- if (name == nullptr || father == nullptr){
- THROWF (tracing_error, 0, "can't get a value with a nullptr name (or a nullptr father)");
+ if (name.empty() || father == nullptr) {
+ THROWF(tracing_error, 0, "can't get a value with no name (or a nullptr father)");
}
if (father->kind_ == TYPE_VARIABLE)
THROWF(tracing_error, 0, "variables can't have different values (%s)", father->name_);
- Value* ret = (Value*)xbt_dict_get_or_null(father->values_, name);
+ Value* ret = (Value*)xbt_dict_get_or_null(father->values_, name.c_str());
if (ret == nullptr) {
- THROWF(tracing_error, 2, "value with name (%s) not found in father type (%s)", name, father->name_);
+ THROWF(tracing_error, 2, "value with name (%s) not found in father type (%s)", name.c_str(), father->name_);
}
return ret;
}
//--------------------------------------------------
class Value {
-public:
- char* id_;
- char* name_;
- char* color_;
+private:
+ std::string name_;
+ std::string id_;
+ std::string color_;
+
+ explicit Value(std::string name, std::string color, Type* father);
+public:
+ ~Value() = default;
Type* father_;
- Value(const char* name, const char* color, Type* father);
- ~Value();
- static Value* get_or_new(const char* name, const char* color, Type* father);
- static Value* get(const char* name, Type* father);
+ static Value* byNameOrCreate(std::string name, std::string color, Type* father);
+ static Value* byName(std::string name, Type* father);
+ const char* getCname() { return name_.c_str(); }
+ const char* getId() { return id_.c_str(); }
+ bool isColored() { return not color_.empty(); }
+ void print();
};
//--------------------------------------------------
void LogVariableTypeDefinition(simgrid::instr::Type* type);
void LogStateTypeDefinition(simgrid::instr::Type* type);
void LogLinkTypeDefinition(simgrid::instr::Type* type, simgrid::instr::Type* source, simgrid::instr::Type* dest);
-void LogEntityValue(simgrid::instr::Value* val);
void LogContainerCreation(container_t container);
void LogContainerDestruction(container_t container);
void LogDefineEventType(simgrid::instr::Type* type);
container_t process_container = PJ_container_get (instr_process_id(process, str, len));
simgrid::instr::Type* type = process_container->type_->getChild("MSG_PROCESS_STATE");
- simgrid::instr::Value* val = simgrid::instr::Value::get("suspend", type);
+ simgrid::instr::Value* val = simgrid::instr::Value::byName("suspend", type);
new simgrid::instr::PushStateEvent(MSG_get_clock(), process_container, type, val);
}
}
container_t process_container = PJ_container_get (instr_process_id(process, str, len));
simgrid::instr::Type* type = process_container->type_->getChild("MSG_PROCESS_STATE");
- simgrid::instr::Value* val = simgrid::instr::Value::get("sleep", type);
+ simgrid::instr::Value* val = simgrid::instr::Value::byName("sleep", type);
new simgrid::instr::PushStateEvent(MSG_get_clock(), process_container, type, val);
}
}
container_t process_container = PJ_container_get (instr_process_id(MSG_process_self(), str, len));
simgrid::instr::Type* type = process_container->type_->getChild("MSG_PROCESS_STATE");
- simgrid::instr::Value* val = simgrid::instr::Value::get("task_execute", type);
+ simgrid::instr::Value* val = simgrid::instr::Value::byName("task_execute", type);
new simgrid::instr::PushStateEvent(MSG_get_clock(), process_container, type, val);
}
}
container_t process_container = PJ_container_get (instr_process_id(MSG_process_self(), str, len));
simgrid::instr::Type* type = process_container->type_->getChild("MSG_PROCESS_STATE");
- simgrid::instr::Value* val = simgrid::instr::Value::get("receive", type);
+ simgrid::instr::Value* val = simgrid::instr::Value::byName("receive", type);
new simgrid::instr::PushStateEvent(MSG_get_clock(), process_container, type, val);
}
}
container_t process_container = PJ_container_get (instr_process_id(MSG_process_self(), str, len));
simgrid::instr::Type* type = process_container->type_->getChild("MSG_PROCESS_STATE");
- simgrid::instr::Value* val = simgrid::instr::Value::get("send", type);
+ simgrid::instr::Value* val = simgrid::instr::Value::byName("send", type);
new simgrid::instr::PushStateEvent(MSG_get_clock(), process_container, type, val);
char key[INSTR_DEFAULT_STR_SIZE];
if (TRACE_msg_vm_is_enabled()) {
container_t vm_container = PJ_container_get(vm->getCname());
simgrid::instr::Type* type = vm_container->type_->getChild("MSG_VM_STATE");
- simgrid::instr::Value* val = simgrid::instr::Value::get_or_new("start", "0 0 1", type); // start is blue
+ simgrid::instr::Value* val = simgrid::instr::Value::byNameOrCreate("start", "0 0 1", type); // start is blue
new simgrid::instr::PushStateEvent(MSG_get_clock(), vm_container, type, val);
}
}
if (TRACE_msg_vm_is_enabled()) {
container_t vm_container = PJ_container_get(vm->getCname());
simgrid::instr::Type* type = vm_container->type_->getChild("MSG_VM_STATE");
- simgrid::instr::Value* val = simgrid::instr::Value::get_or_new("suspend", "1 0 0", type); // suspend is red
+ simgrid::instr::Value* val = simgrid::instr::Value::byNameOrCreate("suspend", "1 0 0", type); // suspend is red
new simgrid::instr::PushStateEvent(MSG_get_clock(), vm_container, type, val);
}
}
char cont_name[25]; \
snprintf(cont_name, 25, "rank-%d", smpi_process()->index()); \
simgrid::instr::Value* val = \
- simgrid::instr::Value::get_or_new(Colls::mpi_coll_##cat##_description[i].name, "1.0 1.0 1.0", type); \
+ simgrid::instr::Value::byNameOrCreate(Colls::mpi_coll_##cat##_description[i].name, "1.0 1.0 1.0", type); \
new simgrid::instr::NewEvent(SIMIX_get_clock(), PJ_container_get(cont_name), type, val); \
}
container_t container = PJ_container_get (str);
simgrid::instr::Type* type = container->type_->getChild("MPI_STATE");
const char *color = instr_find_color (operation);
- simgrid::instr::Value* val = simgrid::instr::Value::get_or_new(operation, color, type);
+ simgrid::instr::Value* val = simgrid::instr::Value::byNameOrCreate(operation, color, type);
new simgrid::instr::PushStateEvent(SIMIX_get_clock(), container, type, val, static_cast<void*>(extra));
}
simgrid::instr::Type* type = container->type_->getChild("MPI_STATE");
const char* color = instr_find_color("computing");
new simgrid::instr::PushStateEvent(SIMIX_get_clock(), container, type,
- simgrid::instr::Value::get_or_new("computing", color, type));
+ simgrid::instr::Value::byNameOrCreate("computing", color, type));
}
void TRACE_smpi_computing_in(int rank, instr_extra_data extra)
smpi_container(rank, str, INSTR_DEFAULT_STR_SIZE);
container_t container = PJ_container_get (str);
simgrid::instr::Type* type = container->type_->getChild("MPI_STATE");
- simgrid::instr::Value* val = simgrid::instr::Value::get_or_new("computing", nullptr, type);
+ simgrid::instr::Value* val = simgrid::instr::Value::byNameOrCreate("computing", "", type);
new simgrid::instr::PushStateEvent(SIMIX_get_clock(), container, type, val, static_cast<void*>(extra));
}
container_t container = PJ_container_get (str);
simgrid::instr::Type* type = container->type_->getChild("MPI_STATE");
const char *color = instr_find_color ("sleeping");
- simgrid::instr::Value* val = simgrid::instr::Value::get_or_new("sleeping", color, type);
+ simgrid::instr::Value* val = simgrid::instr::Value::byNameOrCreate("sleeping", color, type);
new simgrid::instr::PushStateEvent(SIMIX_get_clock(), container, type, val);
}
smpi_container(rank, str, INSTR_DEFAULT_STR_SIZE);
container_t container = PJ_container_get (str);
simgrid::instr::Type* type = container->type_->getChild("MPI_STATE");
- simgrid::instr::Value* val = simgrid::instr::Value::get_or_new("sleeping", nullptr, type);
+ simgrid::instr::Value* val = simgrid::instr::Value::byNameOrCreate("sleeping", "", type);
new simgrid::instr::PushStateEvent(SIMIX_get_clock(), container, type, val, static_cast<void*>(extra));
}
smpi_container(rank, str, INSTR_DEFAULT_STR_SIZE);
container_t container = PJ_container_get (str);
simgrid::instr::Type* type = container->type_->getChild("MPI_STATE");
- simgrid::instr::Value* val = simgrid::instr::Value::get_or_new("test", nullptr, type);
+ simgrid::instr::Value* val = simgrid::instr::Value::byNameOrCreate("test", "", type);
new simgrid::instr::PushStateEvent(SIMIX_get_clock(), container, type, val, static_cast<void*>(extra));
}
container_t container = PJ_container_get (str);
simgrid::instr::Type* type = container->type_->getChild("MPI_STATE");
const char *color = instr_find_color (operation);
- simgrid::instr::Value* val = simgrid::instr::Value::get_or_new(operation, color, type);
+ simgrid::instr::Value* val = simgrid::instr::Value::byNameOrCreate(operation, color, type);
new simgrid::instr::PushStateEvent(SIMIX_get_clock(), container, type, val, static_cast<void*>(extra));
}
if (msg_process == nullptr){
msg_process = simgrid::instr::Type::containerNew("MSG_PROCESS", container->type_);
simgrid::instr::Type* state = simgrid::instr::Type::stateNew("MSG_PROCESS_STATE", msg_process);
- new simgrid::instr::Value("suspend", "1 0 1", state);
- simgrid::instr::Value::get_or_new("sleep", "1 1 0", state);
- simgrid::instr::Value::get_or_new("receive", "1 0 0", state);
- simgrid::instr::Value::get_or_new("send", "0 0 1", state);
- simgrid::instr::Value::get_or_new("task_execute", "0 1 1", state);
+ simgrid::instr::Value::byNameOrCreate("suspend", "1 0 1", state);
+ simgrid::instr::Value::byNameOrCreate("sleep", "1 1 0", state);
+ simgrid::instr::Value::byNameOrCreate("receive", "1 0 0", state);
+ simgrid::instr::Value::byNameOrCreate("send", "0 0 1", state);
+ simgrid::instr::Value::byNameOrCreate("task_execute", "0 1 1", state);
simgrid::instr::Type::linkNew("MSG_PROCESS_LINK", PJ_type_get_root(), msg_process, msg_process);
simgrid::instr::Type::linkNew("MSG_PROCESS_TASK_LINK", PJ_type_get_root(), msg_process, msg_process);
}
if (msg_vm == nullptr){
msg_vm = simgrid::instr::Type::containerNew("MSG_VM", container->type_);
simgrid::instr::Type* state = simgrid::instr::Type::stateNew("MSG_VM_STATE", msg_vm);
- new simgrid::instr::Value("suspend", "1 0 1", state);
- simgrid::instr::Value::get_or_new("sleep", "1 1 0", state);
- simgrid::instr::Value::get_or_new("receive", "1 0 0", state);
- simgrid::instr::Value::get_or_new("send", "0 0 1", state);
- simgrid::instr::Value::get_or_new("task_execute", "0 1 1", state);
+ simgrid::instr::Value::byNameOrCreate("suspend", "1 0 1", state);
+ simgrid::instr::Value::byNameOrCreate("sleep", "1 1 0", state);
+ simgrid::instr::Value::byNameOrCreate("receive", "1 0 0", state);
+ simgrid::instr::Value::byNameOrCreate("send", "0 0 1", state);
+ simgrid::instr::Value::byNameOrCreate("task_execute", "0 1 1", state);
simgrid::instr::Type::linkNew("MSG_VM_LINK", PJ_type_get_root(), msg_vm, msg_vm);
simgrid::instr::Type::linkNew("MSG_VM_PROCESS_LINK", PJ_type_get_root(), msg_vm, msg_vm);
}
simgrid::instr::Type* root)
{
if (not strcmp(root->name_, type_name)) {
- new simgrid::instr::Value(val, color, root);
+ simgrid::instr::Value::byNameOrCreate(val, color, root);
}
xbt_dict_cursor_t cursor = nullptr;
simgrid::instr::Type* child_type;