It's currently not very clear if the Python exception handling functions
append a Babeltrace error cause or clear the Python error indicator.
It's therefore easy to mis-use them.
Rename them to better indicate what they do.
Change-Id: I7dc31264196c6410e715c620cf9e4cd48a2711f6
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/2222
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Francis Deslauriers <francis.deslauriers@efficios.com>
-int py_exc_to_status(bt_self_component_class *self_component_class,
+int py_exc_to_status_clear(
+ bt_self_component_class *self_component_class,
bt_self_component *self_component,
bt_self_message_iterator *self_message_iterator,
const char *module_name, int active_log_level)
bt_self_component *self_component,
bt_self_message_iterator *self_message_iterator,
const char *module_name, int active_log_level)
}
BT_ASSERT(active_log_level != -1);
}
BT_ASSERT(active_log_level != -1);
- log_exception_and_maybe_append_error(BT_LOG_WARNING,
+ log_exception_and_maybe_append_cause(BT_LOG_WARNING,
active_log_level, true,
self_component_class, self_component,
self_message_iterator, module_name);
active_log_level, true,
self_component_class, self_component,
self_message_iterator, module_name);
-int py_exc_to_status_component_class(
+int py_exc_to_status_component_class_clear(
bt_self_component_class *self_component_class,
int active_log_level)
{
bt_self_component_class *self_component_class,
int active_log_level)
{
- return py_exc_to_status(self_component_class, NULL, NULL, NULL,
+ return py_exc_to_status_clear(self_component_class, NULL, NULL, NULL,
active_log_level);
}
static
active_log_level);
}
static
-int py_exc_to_status_component(bt_self_component *self_component)
+int py_exc_to_status_component_clear(bt_self_component *self_component)
- return py_exc_to_status(NULL, self_component, NULL, NULL, -1);
+ return py_exc_to_status_clear(NULL, self_component, NULL, NULL, -1);
-int py_exc_to_status_message_iterator(
+int py_exc_to_status_message_iterator_clear(
bt_self_message_iterator *self_message_iterator)
{
bt_self_message_iterator *self_message_iterator)
{
- return py_exc_to_status(NULL, NULL, self_message_iterator, NULL, -1);
+ return py_exc_to_status_clear(NULL, NULL, self_message_iterator, NULL, -1);
BT_COMP_LOG_CUR_LVL(BT_LOG_WARNING, log_level, self_component,
"Failed to call Python class's _bt_init_from_native() method: "
"py-cls-addr=%p", py_cls);
BT_COMP_LOG_CUR_LVL(BT_LOG_WARNING, log_level, self_component,
"Failed to call Python class's _bt_init_from_native() method: "
"py-cls-addr=%p", py_cls);
- status = py_exc_to_status_component(self_component);
+ status = py_exc_to_status_component_clear(self_component);
BT_LOG_WRITE_CUR_LVL(BT_LOG_WARNING, log_level, BT_LOG_TAG,
"Failed to call Python class's _bt_get_supported_mip_versions_from_native() method: "
"py-cls-addr=%p", py_cls);
BT_LOG_WRITE_CUR_LVL(BT_LOG_WARNING, log_level, BT_LOG_TAG,
"Failed to call Python class's _bt_get_supported_mip_versions_from_native() method: "
"py-cls-addr=%p", py_cls);
- status = py_exc_to_status_component_class(self_component_class,
+ status = py_exc_to_status_component_class_clear(self_component_class,
*can_seek = PyObject_IsTrue(py_result);
status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_CAN_SEEK_BEGINNING_METHOD_STATUS_OK;
} else {
*can_seek = PyObject_IsTrue(py_result);
status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_CAN_SEEK_BEGINNING_METHOD_STATUS_OK;
} else {
- status = py_exc_to_status_message_iterator(self_message_iterator);
+ status = py_exc_to_status_message_iterator_clear(self_message_iterator);
BT_ASSERT(status != __BT_FUNC_STATUS_OK);
}
BT_ASSERT(status != __BT_FUNC_STATUS_OK);
}
py_result = PyObject_CallMethod(py_iter, "_bt_seek_beginning_from_native",
NULL);
BT_ASSERT(!py_result || py_result == Py_None);
py_result = PyObject_CallMethod(py_iter, "_bt_seek_beginning_from_native",
NULL);
BT_ASSERT(!py_result || py_result == Py_None);
- status = py_exc_to_status_message_iterator(self_message_iterator);
+ status = py_exc_to_status_message_iterator_clear(self_message_iterator);
Py_XDECREF(py_result);
return status;
}
Py_XDECREF(py_result);
return status;
}
*can_seek = PyObject_IsTrue(py_result);
status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_CAN_SEEK_NS_FROM_ORIGIN_METHOD_STATUS_OK;
} else {
*can_seek = PyObject_IsTrue(py_result);
status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_CAN_SEEK_NS_FROM_ORIGIN_METHOD_STATUS_OK;
} else {
- status = py_exc_to_status_message_iterator(self_message_iterator);
+ status = py_exc_to_status_message_iterator_clear(self_message_iterator);
BT_ASSERT(status != BT_COMPONENT_CLASS_MESSAGE_ITERATOR_CAN_SEEK_NS_FROM_ORIGIN_METHOD_STATUS_OK);
}
BT_ASSERT(status != BT_COMPONENT_CLASS_MESSAGE_ITERATOR_CAN_SEEK_NS_FROM_ORIGIN_METHOD_STATUS_OK);
}
py_result = PyObject_CallMethod(py_iter,
"_bt_seek_ns_from_origin_from_native", "L", ns_from_origin);
BT_ASSERT(!py_result || py_result == Py_None);
py_result = PyObject_CallMethod(py_iter,
"_bt_seek_ns_from_origin_from_native", "L", ns_from_origin);
BT_ASSERT(!py_result || py_result == Py_None);
- status = py_exc_to_status_message_iterator(self_message_iterator);
+ status = py_exc_to_status_message_iterator_clear(self_message_iterator);
Py_XDECREF(py_result);
return status;
}
Py_XDECREF(py_result);
return status;
}
"_bt_port_connected_from_native", "(OiO)", py_self_port_ptr,
self_component_port_type, py_other_port_ptr);
BT_ASSERT(!py_method_result || py_method_result == Py_None);
"_bt_port_connected_from_native", "(OiO)", py_self_port_ptr,
self_component_port_type, py_other_port_ptr);
BT_ASSERT(!py_method_result || py_method_result == Py_None);
- status = py_exc_to_status_component(self_component);
+ status = py_exc_to_status_component_clear(self_component);
end:
Py_XDECREF(py_self_port_ptr);
end:
Py_XDECREF(py_self_port_ptr);
py_method_result = PyObject_CallMethod(py_comp,
"_bt_graph_is_configured_from_native", NULL);
BT_ASSERT(!py_method_result || py_method_result == Py_None);
py_method_result = PyObject_CallMethod(py_comp,
"_bt_graph_is_configured_from_native", NULL);
BT_ASSERT(!py_method_result || py_method_result == Py_None);
- status = py_exc_to_status_component(self_component);
+ status = py_exc_to_status_component_clear(self_component);
Py_XDECREF(py_method_result);
return status;
}
Py_XDECREF(py_method_result);
return status;
}
py_object, py_params_ptr,
method_data ? method_data : Py_None);
if (!py_results_addr) {
py_object, py_params_ptr,
method_data ? method_data : Py_None);
if (!py_results_addr) {
- status = py_exc_to_status_component_class(self_component_class,
+ status = py_exc_to_status_component_class_clear(self_component_class,
log_level);
if (status < 0) {
static const char *fmt =
log_level);
if (status < 0) {
static const char *fmt =
python_error:
/* Handling of errors that cause a Python exception to be set. */
python_error:
/* Handling of errors that cause a Python exception to be set. */
- status = py_exc_to_status_message_iterator(self_message_iterator);
+ status = py_exc_to_status_message_iterator_clear(self_message_iterator);
BT_ASSERT(status != __BT_FUNC_STATUS_OK);
goto end;
BT_ASSERT(status != __BT_FUNC_STATUS_OK);
goto end;
py_method_result = PyObject_CallMethod(py_message_iter,
"_bt_next_from_native", NULL);
if (!py_method_result) {
py_method_result = PyObject_CallMethod(py_message_iter,
"_bt_next_from_native", NULL);
if (!py_method_result) {
- status = py_exc_to_status_message_iterator(message_iterator);
+ status = py_exc_to_status_message_iterator_clear(message_iterator);
BT_ASSERT(status != __BT_FUNC_STATUS_OK);
goto end;
}
BT_ASSERT(status != __BT_FUNC_STATUS_OK);
goto end;
}
BT_ASSERT(py_comp);
py_method_result = PyObject_CallMethod(py_comp,
"_user_consume", NULL);
BT_ASSERT(py_comp);
py_method_result = PyObject_CallMethod(py_comp,
"_user_consume", NULL);
- status = py_exc_to_status_component(self_component);
+ status = py_exc_to_status_component_clear(self_component);
BT_ASSERT(py_method_result || status != __BT_FUNC_STATUS_OK);
Py_XDECREF(py_method_result);
return status;
BT_ASSERT(py_method_result || status != __BT_FUNC_STATUS_OK);
Py_XDECREF(py_method_result);
return status;
py_res = PyObject_CallFunction(py_callable, "(OiOi)",
py_component_ptr, component_class_type, py_port_ptr, port_type);
if (!py_res) {
py_res = PyObject_CallFunction(py_callable, "(OiOi)",
py_component_ptr, component_class_type, py_port_ptr, port_type);
if (!py_res) {
- loge_exception("Graph's port added listener (Python)",
+ loge_exception_append_cause(
+ "Graph's port added listener (Python)",
BT_LOG_OUTPUT_LEVEL);
PyErr_Clear();
status = __BT_FUNC_STATUS_ERROR;
BT_LOG_OUTPUT_LEVEL);
PyErr_Clear();
status = __BT_FUNC_STATUS_ERROR;
py_downstream_component_ptr, downstream_component_class_type,
py_downstream_port_ptr);
if (!py_res) {
py_downstream_component_ptr, downstream_component_class_type,
py_downstream_port_ptr);
if (!py_res) {
- loge_exception("Graph's port connected listener (Python)",
+ loge_exception_append_cause(
+ "Graph's port connected listener (Python)",
BT_LOG_OUTPUT_LEVEL);
PyErr_Clear();
status = __BT_FUNC_STATUS_ERROR;
BT_LOG_OUTPUT_LEVEL);
PyErr_Clear();
status = __BT_FUNC_STATUS_ERROR;
-void log_exception_and_maybe_append_error(int func_log_level,
- int active_log_level, bool append_error,
+void log_exception_and_maybe_append_cause(
+ int func_log_level,
+ int active_log_level,
+ bool append_error,
bt_self_component_class *self_component_class,
bt_self_component *self_component,
bt_self_message_iterator *self_message_iterator,
bt_self_component_class *self_component_class,
bt_self_component *self_component,
bt_self_message_iterator *self_message_iterator,
-void loge_exception(const char *module_name, int active_log_level)
+void loge_exception_append_cause(const char *module_name, int active_log_level)
- log_exception_and_maybe_append_error(BT_LOG_ERROR, active_log_level,
+ log_exception_and_maybe_append_cause(BT_LOG_ERROR, active_log_level,
true, NULL, NULL, NULL, module_name);
}
static inline
void logw_exception(int active_log_level)
{
true, NULL, NULL, NULL, module_name);
}
static inline
void logw_exception(int active_log_level)
{
- log_exception_and_maybe_append_error(BT_LOG_WARNING, active_log_level,
+ log_exception_and_maybe_append_cause(BT_LOG_WARNING, active_log_level,
false, NULL, NULL, NULL, NULL);
}
false, NULL, NULL, NULL, NULL);
}
if (py_res) {
BT_ASSERT(py_res == Py_None);
} else {
if (py_res) {
BT_ASSERT(py_res == Py_None);
} else {
- loge_exception("Trace's destruction listener (Python)",
+ loge_exception_append_cause(
+ "Trace's destruction listener (Python)",
if (py_res) {
BT_ASSERT(py_res == Py_None);
} else {
if (py_res) {
BT_ASSERT(py_res == Py_None);
} else {
- loge_exception("Trace class's destruction listener (Python)",
+ loge_exception_append_cause(
+ "Trace class's destruction listener (Python)",