- while ((evt = action_get_action(argv[0]))) {
- msg_action_fun function =
- xbt_dict_get(action_funs, xbt_dynar_get_as(evt, 1, char *));
- (*function) (evt);
- xbt_dynar_free(&evt);
- }
+ while ((evt = action_get_action(argv[0]))) {
+ msg_action_fun function =
+ xbt_dict_get(action_funs, xbt_dynar_get_as(evt, 1, char *));
+ (*function) (evt);
+ xbt_dynar_free(&evt);
+ }
+ } else { // Should have got my trace file in argument
+ xbt_assert1(argc >= 2,
+ "No '%s' agent function provided, no simulation-wide trace file provided to MSG_action_trace_run(), "
+ "and no process-wide trace file provided in deployment file. Aborting.",
+ argv[0]
+ );
+
+ fp = fopen(argv[1], "r");
+ xbt_assert2(fp != NULL, "Cannot open %s: %s", argv[1],
+ strerror(errno));
+
+ // Read lines and execute them until I reach the end of file
+ while ((read = getline(&line, &line_len, fp)) != -1) {
+ // cleanup and split the string I just read
+ if (paranoid_action_replayer) {
+ comment = strchr(line, '#');
+ if (comment != NULL)
+ *comment = '\0';
+ xbt_str_trim(line, NULL);
+ }
+ evt = xbt_str_split_quoted_in_place(line);
+ if (xbt_dynar_length(evt)==0) {
+ xbt_dynar_free(&evt);
+ continue;
+ }