Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 9011
b: refs/heads/master
c: 3eddddc
h: refs/heads/master
i:
  9009: bfa8c2b
  9007: 03ae327
v: v3
  • Loading branch information
Jeff Dike authored and Linus Torvalds committed Sep 17, 2005
1 parent da195a0 commit e91f61d
Show file tree
Hide file tree
Showing 6 changed files with 64 additions and 2 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: f6e34c6af6f18bd6c66bfb1c6a7c57068412aa73
refs/heads/master: 3eddddcf239c89bbd3c50d1440001a3d384ed40a
52 changes: 52 additions & 0 deletions trunk/arch/um/drivers/mconsole_kern.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
#include "os.h"
#include "umid.h"
#include "irq_kern.h"
#include "choose-mode.h"

static int do_unlink_socket(struct notifier_block *notifier,
unsigned long what, void *data)
Expand Down Expand Up @@ -276,6 +277,7 @@ void mconsole_proc(struct mc_request *req)
go - continue the UML after a 'stop' \n\
log <string> - make UML enter <string> into the kernel log\n\
proc <file> - returns the contents of the UML's /proc/<file>\n\
stack <pid> - returns the stack of the specified pid\n\
"

void mconsole_help(struct mc_request *req)
Expand Down Expand Up @@ -479,6 +481,56 @@ void mconsole_sysrq(struct mc_request *req)
}
#endif

/* Mconsole stack trace
* Added by Allan Graves, Jeff Dike
* Dumps a stacks registers to the linux console.
* Usage stack <pid>.
*/
void do_stack(struct mc_request *req)
{
char *ptr = req->request.data;
int pid_requested= -1;
struct task_struct *from = NULL;
struct task_struct *to = NULL;

/* Would be nice:
* 1) Send showregs output to mconsole.
* 2) Add a way to stack dump all pids.
*/

ptr += strlen("stack");
while(isspace(*ptr)) ptr++;

/* Should really check for multiple pids or reject bad args here */
/* What do the arguments in mconsole_reply mean? */
if(sscanf(ptr, "%d", &pid_requested) == 0){
mconsole_reply(req, "Please specify a pid", 1, 0);
return;
}

from = current;
to = find_task_by_pid(pid_requested);

if((to == NULL) || (pid_requested == 0)) {
mconsole_reply(req, "Couldn't find that pid", 1, 0);
return;
}
to->thread.saved_task = current;

switch_to(from, to, from);
mconsole_reply(req, "Stack Dumped to console and message log", 0, 0);
}

void mconsole_stack(struct mc_request *req)
{
/* This command doesn't work in TT mode, so let's check and then
* get out of here
*/
CHOOSE_MODE(mconsole_reply(req, "Sorry, this doesn't work in TT mode",
1, 0),
do_stack(req));
}

/* Changed by mconsole_setup, which is __setup, and called before SMP is
* active.
*/
Expand Down
1 change: 1 addition & 0 deletions trunk/arch/um/drivers/mconsole_user.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ static struct mconsole_command commands[] = {
{ "go", mconsole_go, MCONSOLE_INTR },
{ "log", mconsole_log, MCONSOLE_INTR },
{ "proc", mconsole_proc, MCONSOLE_PROC },
{ "stack", mconsole_stack, MCONSOLE_INTR },
};

/* Initialized in mconsole_init, which is an initcall */
Expand Down
1 change: 1 addition & 0 deletions trunk/arch/um/include/mconsole.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ extern void mconsole_stop(struct mc_request *req);
extern void mconsole_go(struct mc_request *req);
extern void mconsole_log(struct mc_request *req);
extern void mconsole_proc(struct mc_request *req);
extern void mconsole_stack(struct mc_request *req);

extern int mconsole_get_request(int fd, struct mc_request *req);
extern int mconsole_notify(char *sock_name, int type, const void *data,
Expand Down
9 changes: 8 additions & 1 deletion trunk/arch/um/kernel/process_kern.c
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,14 @@ void *_switch_to(void *prev, void *next, void *last)
to->thread.prev_sched = from;
set_current(to);

CHOOSE_MODE_PROC(switch_to_tt, switch_to_skas, prev, next);
do {
current->thread.saved_task = NULL ;
CHOOSE_MODE_PROC(switch_to_tt, switch_to_skas, prev, next);
if(current->thread.saved_task)
show_regs(&(current->thread.regs));
next= current->thread.saved_task;
prev= current;
} while(current->thread.saved_task);

return(current->thread.prev_sched);

Expand Down
1 change: 1 addition & 0 deletions trunk/include/asm-um/processor-generic.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ struct thread_struct {
* copy_thread) to mark that we are begin called from userspace (fork /
* vfork / clone), and reset to 0 after. It is left to 0 when called
* from kernelspace (i.e. kernel_thread() or fork_idle(), as of 2.6.11). */
struct task_struct *saved_task;
int forking;
int nsyscalls;
struct pt_regs regs;
Expand Down

0 comments on commit e91f61d

Please sign in to comment.