[Gems-users] Re: The process to get pid and related questions


Date: Fri, 3 Jun 2005 12:01:48 -0500
From: "Min Xu (Hsu)" <xu@xxxxxxxxxxx>
Subject: [Gems-users] Re: The process to get pid and related questions
Weihang,

I am not sure I fully grasped the problem. Where is your attachment?

I wonder whether you are getting the right kernel variable for PID. Do you have
the source code for the kernel version you are running? It is possible the
kernel code changes from version to version.

Please provide more information.

Thanks!

-Min

On Fri, 03 Jun 2005 Weihang Jiang wrote :
> The process to get pid from inside simulator:
> 
> 1. find the break address using mdb in the simulation machine
> mdb -k
> 2. find the instruction that modified the pid "stx ... [%l0 + 0x10]"
> >::dis resume (see attachment)
> can't not find "stx ... [%l0 + 0x10]", instead, I pick "resume+0xa8: stx 
> %o0, [%i1 + 0x10]"
> 3. find the starting address of the function "resume"
> > resume=X
> 102da90 
> now the starting address of resume + offset is the break point = 0x102da90 + 
> 0xa8 = 0x102db38
> 4. ./simics -c xxx.check
> break 0x102db38
> c
> @cpu = SIM_current_processor()
> @cwp = SIM_read_register(cpu, SIM_get_register_number(cpu, "cwp"))
> @va = SIM_get_interface(cpu, "sparc-v9").read_window_register(cpu, cwp, 25) 
> + 0x10
> @pa = SIM_logical_to_physical(cpu, Sim_DI_Data, va)
> @print pa 
> output: 50331664 (0x3000010 ) (this is thread_physical_addr)
> 
> 5. @SIM_breakpoint(SIM_get_object 
> ("phys_mem0"),Sim_Break_Physical,Sim_Access_Write,0x3000010,4,0)
> c
> 
> 6. @thread = SIM_read_phys_memory(conf.cpu0, 0x3000010,8)
> (thread = 2890513120576)
> @procp= SIM_read_phys_memory(conf.cpu0, SIM_logical_to_physical(conf.cpu0
> ,Sim_DI_Data,thread+0x130),8)
> (procp = 21012480)
> @pidp= SIM_read_phys_memory(conf.cpu0, SIM_logical_to_physical(conf.cpu0
> ,Sim_DI_Data,procp+0xb0),8)
> (pidp = 21451608)
> @pid= SIM_read_phys_memory(conf.cpu0, SIM_logical_to_physical(conf.cpu0
> ,Sim_DI_Data,pidp+0x4),4)
> (pid = 1)
> 
> The problem is that the pid is always equal to "1" (never changed). Can 
> anyone point out where I made mistake?
> 
> -- 
> Weihang Jiang
[← Prev in Thread] Current Thread [Next in Thread→]