Skip to content
Snippets Groups Projects
Commit 0c2b6bf9 authored by Lorenz Meier's avatar Lorenz Meier
Browse files

POSIX: Set the thread name for better debugging

parent 9ee4760f
No related branches found
No related tags found
No related merge requests found
......@@ -75,6 +75,7 @@ static task_entry taskmap[PX4_MAX_TASKS] = {};
typedef struct {
px4_main_t entry;
const char* name;
int argc;
char *argv[];
// strings are allocated after the
......@@ -83,6 +84,19 @@ typedef struct {
static void *entry_adapter(void *ptr)
{
pthdata_t *data = (pthdata_t *) ptr;
int rv;
// set the threads name
#ifdef __PX4_DARWIN
rv = pthread_setname_np(data->name);
#else
rv = pthread_setname_np(pthread_self(), data->name);
#endif
if (rv) {
PX4_ERR("px4_task_spawn_cmd: failed to set name of thread %d %d\n", rv, errno);
}
data->entry(data->argc, data->argv);
free(ptr);
PX4_DEBUG("Before px4_task_exit");
......@@ -132,6 +146,7 @@ px4_task_t px4_task_spawn_cmd(const char *name, int scheduler, int priority, int
memset(taskdata, 0, structsize + len);
offset = ((unsigned long)taskdata) + structsize;
taskdata->name = name;
taskdata->entry = entry;
taskdata->argc = argc;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment