lkcd
[Top] [All Lists]

Re: Question on lcrash usage

To: "James Washer" <washer@xxxxxxxxxx>
Subject: Re: Question on lcrash usage
From: "Andreas Herrmann" <AHERRMAN@xxxxxxxxxx>
Date: Mon, 8 Oct 2001 18:58:15 +0200
Cc: lkcd@xxxxxxxxxxx
Importance: Normal
Sender: owner-lkcd@xxxxxxxxxxx
James Washer wrote:
>First, if this is the WRONG list to be asking usage questions... please
>direct me to the correct place.
>
>Ok, if you've read this far...
>
>Is there a nice (and easy) way to find user address space pages? (or do I
>have to walk the page tables myself?)
>
>
> - jim


If you want to get a list of user pages: Currently there is no
nice and easy way to do it.

But there is a way to look at memory of user processes. (But currently
it is neither really nice nor easy ...)

The problem is that address translation of virtual addresses to physical
ones
is automatically done only for kernel addresses.
For user addresses you have to translate the virtual address of the user
space
using the "vtop" command. You have to know the address of the mm_struct
of the user process in interest.
Then you can use the received kernel address as input for further commands
like
"print" or "dump".

I give you an example.
Obviously, there is much room for improvements with respect to memory
mapping.
But currently, this is the way it works.

Example:
I used lcrash as an user process.
Using lcrash itself, I want to read the value of the global variable
"iter_threshold" (type long int), which is set to 10.000 and which is
stored at virtual memory address 0x8169730 of the user process.
(I've used gdb to get the address of the variable.)
Following the corresponding lcrash session (comments starting with #):

>> task
ACTIVE TASKS:

      ADDR    UID    PID   PPID  STATE     FLAGS CPU  NAME
===============================================================================
0xc0256000      0      0      0      0         0   -  swapper
0xcffea000      0      1      0      1     0x100   -  init
0xcff34000      0      2      1      1      0x40   -  kflushd
0xcff32000      0      3      1      1      0x40   -  kupdate

...


0xcdddc000      0   3110   3103      1         0   -  gdb
0xc47aa000      0   3112   3110      8  0x200010   -  lcrash
===============================================================================
61 active task structs found

>> task -f 0xc47aa000
      ADDR    UID    PID   PPID  STATE     FLAGS CPU  NAME
===============================================================================
0xc47aa000      0   3112   3110      8  0x200010   -  lcrash

  MM:0xca6103c0    # this is the address of lcrash's mm_struct structure

THREAD:
  ESP0:0xc47ac000, ESP:0xc47abed8, EIP:0xc0111786
  FS:0, GS:0

===============================================================================
1 active task struct found

>> vtop -m 0xca6103c0 0x8169730 # translate virtual address to physical one
     VADDR      KADDR      PADDR      PFN
=========================================
 0x8169730 0xc1cec730  0x1cec730 30328624
=========================================

# We have to look at KADDR.
# PADDR would be translated again, because it does not fall between
# PAGE_OFFSET (0xc000000) and value of high_memory (0xcfff0000)

>> dump 0xc1cec730 2
0xc1cec730: 00002710 00000000                   : .'......

>> print *(long int *) 0xc1cec730
10000 # this is exactly what I expected at this address


Hope this is of some use for you.

Regards,

Andreas

--
Linux for eServer Development
Tel :  +49-7031-16-4640
Notes mail :  Andreas Herrmann/GERMANY/IBM@IBMDE
email :  aherrman@xxxxxxxxxx



<Prev in Thread] Current Thread [Next in Thread>