⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 debugging390.txt

📁 嵌入式系统设计与实例开发实验教材二源码 多线程应用程序设计 串行端口程序设计 AD接口实验 CAN总线通信实验 GPS通信实验 Linux内核移植与编译实验 IC卡读写实验 SD驱动使
💻 TXT
📖 第 1 页 / 共 5 页
字号:
grep task /proc/<pid>/statusfrom this you should see something liketask: 0f160000 ksp: 0f161de8 pt_regs: 0f161f68This now gives you a pointer to the task structure.Now make CC:="s390-gcc -g" kernel/sched.sTo get the task_struct stabinfo.( task_struct is defined in include/linux/sched.h ).Now we want to look attask->active_mm->pgdon my machine the active_mm in the task structure stab isactive_mm:(4,12),672,32its offset is 672/8=84=0x54the pgd member in the mm_struct stab ispgd:(4,6)=*(29,5),96,32so its offset is 96/8=12=0xcso we'llhexdump -s 0xf160054 /dev/mem | morei.e. task_struct+active_mm offsetto look at the active_mm memberf160054 0fee cc60 0019 e334 0000 0000 0000 0011hexdump -s 0x0feecc6c /dev/mem | morei.e. active_mm+pgd offsetfeecc6c 0f2c 0000 0000 0001 0000 0001 0000 0010we get something likenow do TR I R STD <pgd|0x7f> 0.7fffffffi.e. the 0x7f is added because the pgd onlygives the page table origin & we need to set the low bitsto the maximum possible segment table length.TR I R STD 0f2c007f 0.7fffffffon z/Architecture you'll probably need to doTR I R STD <pgd|0x7> 0.ffffffffffffffffto set the TableType to 0x1 & the Table length to 3.Tracing Program Exceptions--------------------------If you get a crash which says something likeillegal operation or specification exception followed by a register dumpYou can restart linux & trace these using the tr prog <range or value> trace option.The most common ones you will normally be tracing for is1=operation exception2=privileged operation exception4=protection exception5=addressing exception6=specification exception10=segment translation exception11=page translation exceptionThe full list of these is on page 22 of the current s/390 Reference Summary.e.g.tr prog 10 will trace segment translation exceptions.tr prog on its own will trace all program interruption codes.Trace Sets----------On starting VM you are initially in the INITIAL trace set.You can do a Q TR to verify this.If you have a complex tracing situation where you wish to wait for instance till a driver is open before you start tracing IO, but know in yourheart that you are going to have to make several runs through the code till youhave a clue whats going on. What you can do isTR I PSWA <Driver open address>hit b to continue till breakpointreach the breakpointnow do yourTR GOTO B TR IO 7c08-7c09 inst int run or whatever the IO channels you wish to trace are & hit bTo got back to the initial trace set doTR GOTO INITIAL& the TR I PSWA <Driver open address> will be the only active breakpoint again.Tracing linux syscalls under VM-------------------------------Syscalls are implemented on Linux for S390 by the Supervisor call instruction (SVC) there 256 possibilities of these as the instruction is made up of a  0xA opcode & the second byte beingthe syscall number. They are traced using the simple command.TR SVC  <Optional value or range>the syscalls are defined in linux/include/asm-s390/unistd.he.g. to trace all file opens just doTR SVC 5 ( as this is the syscall number of open )SMP Specific commands---------------------To find out how many cpus you haveQ CPUS displays all the CPU's available to your virtual machineTo find the cpu that the current cpu VM debugger commands are being directed at doQ CPU to change the current cpu cpu VM debugger commands are being directed at doCPU <desired cpu no>On a SMP guest issue a command to all CPUs try prefixing the command with cpu all.To issue a command to a particular cpu try cpu <cpu number> e.g.CPU 01 TR I R 2000.3000If you are running on a guest with several cpus & you have a IO related problem& cannot follow the flow of code but you know it isnt smp related.from the bash prompt issueshutdown -h now or halt.do a Q CPUS to find out how many cpus you havedetach each one of them from cp except cpu 0 by issueing a DETACH CPU 01-(number of cpus in configuration)& boot linux again.TR SIGP will trace inter processor signal processor instructions.DEFINE CPU 01-(number in configuration) will get your guests cpus back.Help for displaying ascii textstrings-------------------------------------On the very latest VM Nucleus'es VM can now display ascii( thanks Neale for the hint ) by doingD TX<lowaddr>.<len>e.g.D TX0.100Alternatively=============Under older VM debuggers ( I love EBDIC too ) you can use this little program I wrote whichwill convert a command line of hex digits to ascii text which can be compiled under linux & you can copy the hex digits from your x3270 terminal to your xterm if you are debuggingfrom a linuxbox.This is quite useful when looking at a parameter passed in as a text stringunder VM ( unless you are good at decoding ASCII in your head ).e.g. consider tracing an open syscallTR SVC 5We have stopped at a breakpoint000151B0' SVC   0A05     -> 0001909A'   CC 0D 20.8 to check the SVC old psw in the prefix area & see was it from userspace( for the layout of the prefix area consult P18 of the s/390 390 Reference Summary if you have it available ).V00000020  070C2000 800151B2The problem state bit wasn't set &  it's also too early in the boot sequencefor it to be a userspace SVC if it was we would have to temporarily switch the psw to user space addressing so we could get at the first parameter of the open ingpr2.Next do a D G2GPR  2 =  00014CB4Now display what gpr2 is pointing toD 00014CB4.20V00014CB4  2F646576 2F636F6E 736F6C65 00001BF5V00014CC4  FC00014C B4001001 E0001000 B8070707Now copy the text till the first 00 hex ( which is the end of the stringto an xterm & do hex2ascii on it.hex2ascii 2F646576 2F636F6E 736F6C65 00 outputsDecoded Hex:=/ d e v / c o n s o l e 0x00 We were opening the console device,You can compile the code below yourself for practice :-),/* *    hex2ascii.c *    a useful little tool for converting a hexadecimal command line to ascii * *    Author(s): Denis Joseph Barrow (djbarrow@de.ibm.com,barrow_dj@yahoo.com) *    (C) 2000 IBM Deutschland Entwicklung GmbH, IBM Corporation. */   #include <stdio.h>int main(int argc,char *argv[]){  int cnt1,cnt2,len,toggle=0;  int startcnt=1;  unsigned char c,hex;    if(argc>1&&(strcmp(argv[1],"-a")==0))     startcnt=2;  printf("Decoded Hex:=");  for(cnt1=startcnt;cnt1<argc;cnt1++)  {    len=strlen(argv[cnt1]);    for(cnt2=0;cnt2<len;cnt2++)    {       c=argv[cnt1][cnt2];       if(c>='0'&&c<='9')	  c=c-'0';       if(c>='A'&&c<='F')	  c=c-'A'+10;       if(c>='a'&&c<='F')	  c=c-'a'+10;       switch(toggle)       {	  case 0:	     hex=c<<4;	     toggle=1;	  break;	  case 1:	     hex+=c;	     if(hex<32||hex>127)	     {		if(startcnt==1)		   printf("0x%02X ",(int)hex);		else		   printf(".");	     }	     else	     {	       printf("%c",hex);	       if(startcnt==1)		  printf(" ");	     }	     toggle=0;	  break;       }    }  }  printf("\n");}Stack tracing under VM----------------------A basic backtrace-----------------Here are the tricks I use 9 out of 10 times it works pretty well,When your backchain reaches a dead end--------------------------------------This can happen when an exception happens in the kernel & the kernel is entered twiceif you reach the NULL pointer at the end of the back chain you should beable to sniff further back if you follow the following tricks.1) A kernel address should be easy to recognise since it is inprimary space & the problem state bit isn't set & alsoThe Hi bit of the address is set.2) Another backchain should also be easy to recognise since it is an address pointing to another address approximately 100 bytes or 0x70 hexbehind the current stackpointer.Here is some practice.boot the kernel & hit PA1 at some random timed g to display the gprs, this should display something likeGPR  0 =  00000001  00156018  0014359C  00000000GPR  4 =  00000001  001B8888  000003E0  00000000GPR  8 =  00100080  00100084  00000000  000FE000GPR 12 =  00010400  8001B2DC  8001B36A  000FFED8Note that GPR14 is a return address but as we are real men we are going totrace the stack.display 0x40 bytes after the stack pointer.V000FFED8  000FFF38 8001B838 80014C8E 000FFF38V000FFEE8  00000000 00000000 000003E0 00000000V000FFEF8  00100080 00100084 00000000 000FE000V000FFF08  00010400 8001B2DC 8001B36A 000FFED8Ah now look at whats in sp+56 (sp+0x38) this is 8001B36A our saved r14 ifyou look above at our stackframe & also agrees with GPR14.now backchain d 000FFF38.40we now are taking the contents of SP to get our first backchain.V000FFF38  000FFFA0 00000000 00014995 00147094V000FFF48  00147090 001470A0 000003E0 00000000V000FFF58  00100080 00100084 00000000 001BF1D0V000FFF68  00010400 800149BA 80014CA6 000FFF38This displays a 2nd return address of 80014CA6now do d 000FFFA0.40 for our 3rd backchainV000FFFA0  04B52002 0001107F 00000000 00000000V000FFFB0  00000000 00000000 FF000000 0001107FV000FFFC0  00000000 00000000 00000000 00000000V000FFFD0  00010400 80010802 8001085A 000FFFA0our 3rd return address is 8001085Aas the 04B52002 looks suspiciously like rubbish it is fair to assume that the kernel entry routinesfor the sake of optimisation dont set up a backchain.now look at System.map to see if the addresses make any sense.grep -i 0001b3 System.mapoutputs among other things0001b304 T cpu_idle so 8001B36Ais cpu_idle+0x66 ( quiet the cpu is asleep, don't wake it )grep -i 00014 System.map produces among other things00014a78 T start_kernel  so 0014CA6 is start_kernel+some hex number I can't add in my head.grep -i 00108 System.map this produces00010800 T _stextso   8001085A is _stext+0x5aCongrats you've done your first backchain.s/390 & z/Architecture IO Overview==================================I am not going to give a course in 390 IO architecture as this would take me quite awhile & I'm no expert. Instead I'll give a 390 IO architecture summary for Dummies if you have the s/390 principles of operation available read this instead. If nothing else you may find a few useful keywords in here & be able to use them on a web search engine like altavista to find more useful information.Unlike other bus architectures modern 390 systems do their IO using mostlyfibre optics & devices such as tapes & disks can be shared between several mainframes,also S390 can support upto 65536 devices while a high end PC based system might be choking with around 64. Here is some of the c

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -