/********************************* MSG **************************************/
+static void _sg_cfg_cb_msg_multiple_backtraces(const char *name, int pos)
+{
+ msg_global->multiple_backtraces = xbt_cfg_get_boolean(_sg_cfg_set, name);
+}
+
/**
* \ingroup msg_simulation
* \brief Initialize MSG with less verifications
xbt_getpid = MSG_process_self_PID;
if (!msg_global) {
- SIMIX_global_init(argc, argv);
-
msg_global = xbt_new0(s_MSG_Global_t, 1);
+ xbt_cfg_register(&_sg_cfg_set, "msg/multiple_backtraces",
+ "Keep the severals backtraces",
+ xbt_cfgelm_boolean, 1, 1, _sg_cfg_cb_msg_multiple_backtraces, NULL);
+ xbt_cfg_setdefault_boolean(_sg_cfg_set, "msg/multiple_backtraces", "no");
+
+ SIMIX_global_init(argc, argv);
+
#ifdef MSG_USE_DEPRECATED
msg_global->max_channel = 0;
#endif
sg_platf_postparse_add_cb(MSG_post_create_environment);
}
-
+
if(MC_is_active()){
/* Ignore total amount of messages sent during the simulation for heap comparison */
MC_ignore_heap(&(msg_global->sent_msg), sizeof(msg_global->sent_msg));
xbt_assert((!simdata->compute) && (task->simdata->isused == 0),
"This task is executed somewhere else. Go fix your code! %d",
- task->simdata->isused);
+ task->simdata->isused!=NULL);
XBT_DEBUG("Computing on %s", MSG_process_get_name(MSG_process_self()));
TRY {
-
- simdata->isused=1;
+ if (msg_global->multiple_backtraces)
+ MSG_BT(simdata->isused, "Using Backtrace");
+ else
+ simdata->isused = (void*)1;
if (simdata->host_nb > 0) {
simdata->compute = simcall_host_parallel_execute(task->name,
t_simdata->sender = process;
t_simdata->source = ((simdata_process_t) SIMIX_process_self_get_data(process))->m_host;
- xbt_assert(t_simdata->isused == 0,
- "This task is still being used somewhere else. You cannot send it now. Go fix your code!");
+ if (t_simdata->isused != 0) {
+ if (msg_global->multiple_backtraces){
+ XBT_ERROR("This task is already used in there:");
+ xbt_backtrace_display(t_simdata->isused);
+ THROWF(unknown_error, 0, "And you try to reuse it from here. You cannot send it now. Go fix your code!");
+ } else {
+ THROWF(unknown_error, 0, "This task is still being used somewhere else. You cannot send it now. Go fix your code! (use --cfg=msg/multiple_backtraces:on to get the backtrace of the other process)");
+ }
+ }
- t_simdata->isused = 1;
+ if (msg_global->multiple_backtraces)
+ MSG_BT(t_simdata->isused, "Using Backtrace");
+ else
+ t_simdata->isused = (void*)1;
t_simdata->comm = NULL;
msg_global->sent_msg++;
/** \ingroup msg_mailbox_management
* \brief Set the mailbox to receive in asynchronous mode
*
- * All messages sent to this mailbox will be transferred to
- * the receiver without waiting for the receive call.
+ * All messages sent to this mailbox will be transferred to
+ * the receiver without waiting for the receive call.
* The receive call will still be necessary to use the received data.
- * If there is a need to receive some messages asynchronously, and some not,
+ * If there is a need to receive some messages asynchronously, and some not,
* two different mailboxes should be used.
*
- * \param alias The name of the mailbox
+ * \param alias The name of the mailbox
*/
void MSG_mailbox_set_async(const char *alias){
msg_mailbox_t mailbox = MSG_mailbox_get_by_alias(alias);
t_simdata->sender = process;
t_simdata->source = ((simdata_process_t) SIMIX_process_self_get_data(process))->m_host;
- xbt_assert(t_simdata->isused == 0,
- "This task is still being used somewhere else. You cannot send it now. Go fix your code!");
+ if (t_simdata->isused != 0) {
+ if (msg_global->multiple_backtraces){
+ XBT_ERROR("This task is already used in there:");
+ xbt_backtrace_display(t_simdata->isused);
+ THROWF(unknown_error, 0, "And you try to reuse it from here. You cannot send it now. Go fix your code!");
+ } else {
+ THROWF(unknown_error, 0, "This task is still being used somewhere else. You cannot send it now. Go fix your code! (use --cfg=msg/multiple_backtraces:on to get the backtrace of the other process)");
+ }
+ }
- t_simdata->isused=1;
+ if (msg_global->multiple_backtraces)
+ MSG_BT(t_simdata->isused, "Using Backtrace");
+ else
+ t_simdata->isused = (void*)1;
t_simdata->comm = NULL;
msg_global->sent_msg++;
/********************************* Task **************************************/
+
+#define MSG_BT(ptr, m) \
+ do {xbt_ex_t *_xbt_ex_t = xbt_new0(xbt_ex_t, 1); \
+ /* build the exception */ \
+ _xbt_ex_t->msg = (bprintf(m)); \
+ _xbt_ex_t->category = (xbt_errcat_t)(0); \
+ _xbt_ex_t->value = (0); \
+ _xbt_ex_t->procname = (char*)xbt_procname(); \
+ _xbt_ex_t->pid = xbt_getpid(); \
+ _xbt_ex_t->file = (char*)__FILE__; \
+ _xbt_ex_t->line = __LINE__; \
+ _xbt_ex_t->func = (char*)_XBT_FUNCTION; \
+ _xbt_ex_t->bt_strings = NULL; \
+ xbt_backtrace_current(_xbt_ex_t); \
+ ptr = _xbt_ex_t; } while(0)
+
typedef struct simdata_task {
smx_action_t compute; /* SIMIX modeling of computation */
smx_action_t comm; /* SIMIX modeling of communication */
/* CPU affinity database of this task */
xbt_dict_t affinity_mask_db; /* smx_host_t host => unsigned long mask */
- int isused; /* Indicates whether the task is used in SIMIX currently */
+ void *isused; /* Indicates whether the task is used in SIMIX currently */
int host_nb; /* ==0 if sequential task; parallel task if not */
/******* Parallel Tasks Only !!!! *******/
smx_host_t *host_list;
int max_channel;
#endif
int session;
+ int multiple_backtraces;
unsigned long int sent_msg; /* Total amount of messages sent during the simulation */
void (*task_copy_callback) (msg_task_t task, msg_process_t src, msg_process_t dst);
void_f_pvoid_t process_data_cleanup;