mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* Cute kernel trick, or communistic ploy?
@ 2003-05-30 23:12 Carl Spalletta
  2003-05-31  1:33 ` Werner Almesberger
  0 siblings, 1 reply; 3+ messages in thread
From: Carl Spalletta @ 2003-05-30 23:12 UTC (permalink / raw)
  To: linux-kernel

  Output of program to simulate a /proc file in a stopped kernel,
using the same kernel function(s) used to generate the actual file
when the kernel is up:

(gdb) source ./proc-uptime
$3 = (void *) 0xa1aec000
$4 = (void *) 0xa1da48d4
$5 = (void *) 0xa1da4384
$6 = (void *) 0xa1da48ac
$7 = 0
"remember to 'call(kfree($page))' when finished
"4080219633.89 395.85
(gdb) 

  This program works fine in the um arch but I was wondering what
the pitfalls are in an approach like this. This is a trivial example,
but other /proc files do very complicated bookkeeping and formatting;
and this method should be equally applicable to those.


GDB program 'proc-uptime' (18 lines):

set $gfp_atomic=0x20
call(kmalloc(4096,$gfp_atomic))
set $page=$
call(kmalloc(32,$gfp_atomic))
set $zero=(int *)$
set *$zero=(int)0
call(kmalloc(32,$gfp_atomic))
set $start=(int **)$
set *$start=$zero
call(kmalloc(32,$gfp_atomic))
set $eof=(int *)$
set *$eof=1
call(uptime_read_proc((char *)$page,(char **)$start,(off_t)0,\
  0,$eof,(void *)$zero))
call(kfree($zero))
call(kfree($eof))
call(kfree($start))
echo "remember to 'call(kfree($page))' before continuing\n"
printf "%s\n",$page




^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2003-05-31  3:44 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-05-30 23:12 Cute kernel trick, or communistic ploy? Carl Spalletta
2003-05-31  1:33 ` Werner Almesberger
2003-05-31  3:57   ` Werner Almesberger

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®