]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
stack() / jstack(): Send PID to userspace.
authorNick Alcock <nick.alcock@oracle.com>
Thu, 28 Mar 2013 20:46:09 +0000 (20:46 +0000)
committerNick Alcock <nick.alcock@oracle.com>
Thu, 28 Mar 2013 20:47:01 +0000 (20:47 +0000)
The stack() and jstack() actions expect the buffer to begin with the PID under
investigation, rather than just being a stream of addresses, as now.

Adjust the buffer size and contents accordingly.

Signed-off-by: Nick Alcock <nick.alcock@oracle.com>
dtrace/dtrace_ecb.c
dtrace/dtrace_probe.c

index 596477c7e0af4fa42dc3c2c9c4a2262b9739be5e..c2c929324a648f99eae02b5f8ca2970861bb2b69 100644 (file)
@@ -278,7 +278,8 @@ static int dtrace_ecb_action_add(dtrace_ecb_t *ecb, dtrace_actdesc_t *desc)
                                arg = DTRACE_USTACK_ARG(nframes, strsize);
                        }
 
-                       size = (nframes + 1) * sizeof(uint64_t);
+                       size = (nframes + 2) * sizeof(uint64_t); /* +1 for limit,
+                                                                   +1 for PID */
                        size += DTRACE_USTACK_STRSIZE(arg);
                        size = P2ROUNDUP(size, (uint32_t)(sizeof(uintptr_t)));
 
index 0a6cb394a61bebbc97a815e4bfde7faade75438b..a161c9301d9337d757d670106ececf056ca09e8a 100644 (file)
@@ -855,7 +855,9 @@ void dtrace_probe(dtrace_id_t id, uintptr_t arg0, uintptr_t arg1,
                                continue;
 
                        case DTRACEACT_JSTACK:
-                       case DTRACEACT_USTACK:
+                       case DTRACEACT_USTACK: {
+                               pid_t   pid = current->pid;
+
                                if (!dtrace_priv_proc(state))
                                        continue;
 
@@ -875,29 +877,35 @@ void dtrace_probe(dtrace_id_t id, uintptr_t arg0, uintptr_t arg1,
                                        continue;
                                }
 
+                               DTRACE_STORE(uint64_t, tomax, valoffs,
+                                            (uint64_t)pid);
+
                                if (DTRACE_USTACK_STRSIZE(rec->dtrd_arg) != 0 &&
                                    current->dtrace_helpers != NULL) {
                                        /*
                                         * This is the slow path -- we have
                                         * allocated string space, and we're
                                         * getting the stack of a process that
-                                        * has helpers.  Call into a separate
+                                        * has helpers.  Call into a separate
                                         * routine to perform this processing.
                                         */
                                        dtrace_action_ustack(
                                                &mstate, state,
-                                               (uint64_t *)(tomax + valoffs),
+                                               (uint64_t *)(tomax + valoffs +
+                                                            sizeof(uint64_t)),
                                                rec->dtrd_arg);
                                        continue;
                                }
 
                                DTRACE_CPUFLAG_SET(CPU_DTRACE_NOFAULT);
                                dtrace_getupcstack(
-                                       (uint64_t *)(tomax + valoffs),
+                                       (uint64_t *)(tomax + valoffs +
+                                                    sizeof(uint64_t)),
                                        DTRACE_USTACK_NFRAMES(rec->dtrd_arg) +
                                        1);
                                DTRACE_CPUFLAG_CLEAR(CPU_DTRACE_NOFAULT);
                                continue;
+                       }
 
                        default:
                                break;