summaryrefslogtreecommitdiff
path: root/nuttx/libc/spawn
diff options
context:
space:
mode:
authorpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2013-01-11 16:53:44 +0000
committerpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2013-01-11 16:53:44 +0000
commit7272d1e7473fc1ce1d0a29c7287260402ca2420e (patch)
tree46e6b528a6ace37a9ec35f2e4c1d7d3fe8b510f5 /nuttx/libc/spawn
parent8b26f2afdf93273f95e24840b68df485f971f89a (diff)
downloadpx4-nuttx-7272d1e7473fc1ce1d0a29c7287260402ca2420e.tar.gz
px4-nuttx-7272d1e7473fc1ce1d0a29c7287260402ca2420e.tar.bz2
px4-nuttx-7272d1e7473fc1ce1d0a29c7287260402ca2420e.zip
Various changes while debugging posix_spawn
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@5510 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'nuttx/libc/spawn')
-rw-r--r--nuttx/libc/spawn/Make.defs8
-rw-r--r--nuttx/libc/spawn/lib_ps.c13
-rw-r--r--nuttx/libc/spawn/lib_psa_dump.c127
-rw-r--r--nuttx/libc/spawn/lib_psa_init.c3
-rw-r--r--nuttx/libc/spawn/lib_psfa_dump.c129
5 files changed, 272 insertions, 8 deletions
diff --git a/nuttx/libc/spawn/Make.defs b/nuttx/libc/spawn/Make.defs
index 2cf75c410..99ee781ce 100644
--- a/nuttx/libc/spawn/Make.defs
+++ b/nuttx/libc/spawn/Make.defs
@@ -42,6 +42,10 @@ CSRCS += lib_ps.c
CSRCS += lib_psfa_addaction.c lib_psfa_addclose.c lib_psfa_adddup2.c
CSRCS += lib_psfa_addopen.c lib_psfa_destroy.c lib_psfa_init.c
+ifeq ($(CONFIG_DEBUG),y)
+CSRCS += lib_psfa_dump.c
+endif
+
CSRCS += lib_psa_getflags.c lib_psa_getschedparam.c lib_psa_getschedpolicy.c
CSRCS += lib_psa_init.c lib_psa_setflags.c lib_psa_setschedparam.c
CSRCS += lib_psa_setschedpolicy.c
@@ -50,6 +54,10 @@ ifneq ($(CONFIG_DISABLE_SIGNALS),y)
CSRCS += lib_psa_getsigmask.c lib_psa_setsigmask.c
endif
+ifeq ($(CONFIG_DEBUG),y)
+CSRCS += lib_psa_dump.c
+endif
+
# Add the spawn directory to the build
DEPPATH += --dep-path spawn
diff --git a/nuttx/libc/spawn/lib_ps.c b/nuttx/libc/spawn/lib_ps.c
index 7509d6737..a6a0590d4 100644
--- a/nuttx/libc/spawn/lib_ps.c
+++ b/nuttx/libc/spawn/lib_ps.c
@@ -357,7 +357,7 @@ static int spawn_proxy(int argc, char *argv[])
{
FAR struct spawn_general_file_action_s *entry;
FAR const posix_spawnattr_t *attr = g_ps_parms.attr;
- int ret;
+ int ret = OK;
/* Perform file actions and/or set a custom signal mask. We get here only
* if the file_actions parameter to posix_spawn[p] was non-NULL and/or the
@@ -365,10 +365,10 @@ static int spawn_proxy(int argc, char *argv[])
*/
#ifndef CONFIG_DISABLE_SIGNALS
- DEBUGASSERT(g_ps_parms.file_actions ||
+ DEBUGASSERT((g_ps_parms.file_actions && *g_ps_parms.file_actions) ||
(attr && (attr->flags & POSIX_SPAWN_SETSIGMASK) != 0));
#else
- DEBUGASSERT(g_ps_parms.file_actions);
+ DEBUGASSERT(g_ps_parms.file_actions && *g_ps_parms.file_actions);
#endif
/* Check if we need to change the signal mask */
@@ -553,9 +553,10 @@ int posix_spawn(FAR pid_t *pid, FAR const char *path,
*/
#ifndef CONFIG_DISABLE_SIGNALS
- if (!file_actions && (attr->flags & POSIX_SPAWN_SETSIGMASK) == 0)
+ if ((file_actions == NULL || *file_actions == NULL) &&
+ (attr == NULL || (attr->flags & POSIX_SPAWN_SETSIGMASK) == 0))
#else
- if (!file_actions)
+ if (file_actions == NULL || *file_actions == NULL)
#endif
{
return ps_exec(pid, path, attr, argv);
@@ -601,7 +602,7 @@ int posix_spawn(FAR pid_t *pid, FAR const char *path,
proxy = TASK_CREATE("spawn_proxy", param.sched_priority,
CONFIG_POSIX_SPAWN_STACKSIZE, (main_t)spawn_proxy,
- (const char **)NULL);
+ (FAR const char **)NULL);
if (proxy < 0)
{
int errcode = errno;
diff --git a/nuttx/libc/spawn/lib_psa_dump.c b/nuttx/libc/spawn/lib_psa_dump.c
new file mode 100644
index 000000000..03770c6ff
--- /dev/null
+++ b/nuttx/libc/spawn/lib_psa_dump.c
@@ -0,0 +1,127 @@
+/****************************************************************************
+ * libc/string/lib_psa_dump.c
+ *
+ * Copyright (C) 2013 Gregory Nutt. All rights reserved.
+ * Author: Gregory Nutt <gnutt@nuttx.org>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the name NuttX nor the names of its contributors may be
+ * used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <spawn.h>
+#include <debug.h>
+
+#ifdef CONFIG_DEBUG
+
+/****************************************************************************
+ * Global Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: posix_spawnattr_dump
+ *
+ * Description:
+ * Show the current attributes.
+ *
+ * Input Parameters:
+ * attr - The address of the spawn attributes to be dumped.
+ *
+ * Returned Value:
+ * None
+ *
+ ****************************************************************************/
+
+void posix_spawnattr_dump(posix_spawnattr_t *attr)
+{
+ dbg("attr[%p]:\n", attr);
+ dbg(" flags: %04x\n", attr->flags);
+ if (attr->flags == 0)
+ {
+ dbg(" None\n");
+ }
+ else
+ {
+ if ((attr->flags & POSIX_SPAWN_RESETIDS) != 0)
+ {
+ dbg(" POSIX_SPAWN_RESETIDS\n");
+ }
+
+ if ((attr->flags & POSIX_SPAWN_SETPGROUP) != 0)
+ {
+ dbg(" POSIX_SPAWN_SETPGROUP\n");
+ }
+
+ if ((attr->flags & POSIX_SPAWN_SETSCHEDPARAM) != 0)
+ {
+ dbg(" POSIX_SPAWN_SETSCHEDPARAM\n");
+ }
+
+ if ((attr->flags & POSIX_SPAWN_SETSCHEDULER) != 0)
+ {
+ dbg(" POSIX_SPAWN_SETSCHEDULER\n");
+ }
+
+ if ((attr->flags & POSIX_SPAWN_SETSIGDEF) != 0)
+ {
+ dbg(" POSIX_SPAWN_SETSIGDEF\n");
+ }
+
+ if ((attr->flags & POSIX_SPAWN_SETSIGMASK) != 0)
+ {
+ dbg(" POSIX_SPAWN_SETSIGMASK\n");
+ }
+ }
+
+ dbg(" priority: %d\n", attr->priority);
+
+ dbg(" policy: %d\n", attr->policy);
+ if (attr->policy == SCHED_FIFO)
+ {
+ dbg(" SCHED_FIFO\n");
+ }
+ else if (attr->policy == SCHED_RR)
+ {
+ dbg(" SCHED_RR\n");
+ }
+ else
+ {
+ dbg(" Unrecognized\n");
+ }
+
+#ifndef CONFIG_DISABLE_SIGNALS
+ dbg(" sigmask: %08x\n", attr->sigmask);
+#endif
+};
+
+#endif /* CONFIG_DEBUG */ \ No newline at end of file
diff --git a/nuttx/libc/spawn/lib_psa_init.c b/nuttx/libc/spawn/lib_psa_init.c
index 8aabfd090..f76188c52 100644
--- a/nuttx/libc/spawn/lib_psa_init.c
+++ b/nuttx/libc/spawn/lib_psa_init.c
@@ -43,7 +43,6 @@
#include <spawn.h>
#include <assert.h>
#include <errno.h>
-#include <errno.h>
/****************************************************************************
* Global Functions
@@ -58,7 +57,7 @@
* call to posix_spawn() or posix_spawnp().
*
* Input Parameters:
- * attr - The address spawn attributes to be initialized.
+ * attr - The address of the spawn attributes to be initialized.
*
* Returned Value:
* On success, these functions return 0; on failure they return an error
diff --git a/nuttx/libc/spawn/lib_psfa_dump.c b/nuttx/libc/spawn/lib_psfa_dump.c
new file mode 100644
index 000000000..d7bf1576d
--- /dev/null
+++ b/nuttx/libc/spawn/lib_psfa_dump.c
@@ -0,0 +1,129 @@
+/****************************************************************************
+ * libc/string/lib_psfa_dump.c
+ *
+ * Copyright (C) 2013 Gregory Nutt. All rights reserved.
+ * Author: Gregory Nutt <gnutt@nuttx.org>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the name NuttX nor the names of its contributors may be
+ * used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <spawn.h>
+#include <assert.h>
+#include <debug.h>
+
+#include "spawn/spawn.h"
+
+#ifdef CONFIG_DEBUG
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: lib_psfa_dump
+ *
+ * Description:
+ * Show the entryent file actions.
+ *
+ * Input Parameters:
+ * file_actions - The address of the file_actions to be dumped.
+ *
+ * Returned Value:
+ * None
+ *
+ ****************************************************************************/
+
+void posix_spawn_file_actions_dump(FAR posix_spawn_file_actions_t *file_actions)
+{
+ FAR struct spawn_general_file_action_s *entry;
+
+ DEBUGASSERT(file_actions);
+
+ dbg("File Actions[%p->%p]:\n", file_actions, *file_actions);
+ if (!*file_actions)
+ {
+ dbg(" NONE\n");
+ return;
+ }
+
+ /* Destroy each file action, one at a time */
+
+ for (entry = (FAR struct spawn_general_file_action_s *)*file_actions;
+ entry;
+ entry = entry->flink)
+ {
+ switch (entry->action)
+ {
+ case SPAWN_FILE_ACTION_CLOSE:
+ {
+ FAR struct spawn_close_file_action_s *action =
+ (FAR struct spawn_close_file_action_s *)entry;
+
+ dbg(" CLOSE: fd=%d\n", action->fd);
+ }
+ break;
+
+ case SPAWN_FILE_ACTION_DUP2:
+ {
+ FAR struct spawn_dup2_file_action_s *action =
+ (FAR struct spawn_dup2_file_action_s *)entry;
+
+ dbg(" DUP2: %d->%d\n", action->fd1, action->fd2);
+ }
+ break;
+
+ case SPAWN_FILE_ACTION_OPEN:
+ {
+ FAR struct spawn_open_file_action_s *action =
+ (FAR struct spawn_open_file_action_s *)entry;
+
+ svdbg(" OPEN: path=%s oflags=%04x mode=%04x fd=%d\n",
+ action->path, action->oflags, action->mode, action->fd);
+ }
+ break;
+
+ case SPAWN_FILE_ACTION_NONE:
+ default:
+ dbg(" ERROR: Unknown action: %d\n", entry->action);
+ break;
+ }
+ }
+}
+
+#endif /* CONFIG_DEBUG */ \ No newline at end of file