mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Petr Vandrovec <vandrove@vc.cvut.cz>
To: turveysp@ntlworld.com
Cc: dalecki@evision.ag, linux-kernel@vger.kernel.org
Subject: Re: Generating a function call trace
Date: Fri, 30 Nov 2001 17:19:23 +0100	[thread overview]
Message-ID: <20011130171923.A6569@vana.vc.cvut.cz> (raw)
In-Reply-To: <001501c179b1$870db7c0$140ba8c0@mistral> <3C07A6E6.45A4AC61@evision-ventures.com>
In-Reply-To: <3C07A6E6.45A4AC61@evision-ventures.com>

On Fri, Nov 30, 2001 at 04:33:58PM +0100, Martin Dalecki wrote:
> Simon Turvey wrote:
> > 
> > Is it possible to arbitrarily generate (in a module say) a function call
> > trace?
> > 
> 
> Just insert the dereference of a NULL pointer where you wan't to have
> it.
> The oops gives you what you wan't....
> Or better attach the gdb to /proc/kmem (you will have to compile the
> kernel with
> debugging on in front of this action) and have fun.

I'm using this ia32-only solution, as killing userspace program is not
acceptable under some conditions. Patch below was generated from
my 2.5.0-pre1 tree.
					Petr Vandrovec
					vandrove@vc.cvut.cz


diff -urdN linux/arch/i386/kernel/traps.c linux/arch/i386/kernel/traps.c
--- linux/arch/i386/kernel/traps.c	Sun Sep 30 19:26:08 2001
+++ linux/arch/i386/kernel/traps.c	Mon Nov 26 15:40:47 2001
@@ -237,6 +237,42 @@
 	printk("\n");
 }	
 
+void printstate(void) {
+	asm volatile (
+		"pushl %%ss\n\t"
+		"pushl %%esp\n\t"
+		"pushfl\n\t"
+		"pushl %%cs\n\t"
+		"call 1f\n"
+		"1:\n\t"
+		"pushl %%eax\n\t"
+		"pushl %%ds\n\t"
+		"pushl %%es\n\t"
+		"pushl %%eax\n\t"
+		"pushl %%ebp\n\t"
+		"pushl %%edi\n\t"
+		"pushl %%esi\n\t"
+		"pushl %%edx\n\t"
+		"pushl %%ecx\n\t"
+		"pushl %%ebx\n\t"
+		"movl %%esp,%%eax\n\t"
+		"pushl %%eax\n\t"
+		"call show_registers\n\t"
+		"addl $4,%%esp\n\t"
+		"popl %%ebx\n\t"
+		"popl %%ecx\n\t"
+		"popl %%edx\n\t"
+		"popl %%esi\n\t"
+		"popl %%edi\n\t"
+		"popl %%ebp\n\t"
+		"popl %%eax\n\t"
+		"popl %%es\n\t"
+		"popl %%ds\n\t"
+		"popl %%eax\n\t"
+		"addl $20,%%esp\n\t"
+		: : : "memory" );
+}
+
 spinlock_t die_lock = SPIN_LOCK_UNLOCKED;
 
 void die(const char * str, struct pt_regs * regs, long err)
diff -urdN linux/kernel/ksyms.c linux/kernel/ksyms.c
--- linux/kernel/ksyms.c	Wed Nov 21 22:07:25 2001
+++ linux/kernel/ksyms.c	Mon Nov 26 15:40:47 2001
@@ -71,6 +71,9 @@
 };
 #endif
 
+extern void printstate(void);
+
+EXPORT_SYMBOL(printstate);
 
 EXPORT_SYMBOL(inter_module_register);
 EXPORT_SYMBOL(inter_module_unregister);

  reply	other threads:[~2001-11-30 16:19 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-11-30 15:13 Simon Turvey
2001-11-30 15:33 ` Martin Dalecki
2001-11-30 16:19   ` Petr Vandrovec [this message]
2001-11-30 17:02 ` Davide Libenzi
2001-11-30 18:20   ` Brian Gerst
2001-11-30 18:39     ` Davide Libenzi
2001-11-30 18:37       ` Martin Dalecki
2001-12-01 19:00     ` Matt D. Robinson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20011130171923.A6569@vana.vc.cvut.cz \
    --to=vandrove@vc.cvut.cz \
    --cc=dalecki@evision.ag \
    --cc=linux-kernel@vger.kernel.org \
    --cc=turveysp@ntlworld.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®