aboutsummaryrefslogtreecommitdiffstats
path: root/Documentation/s390/Debugging390.txt
diff options
context:
space:
mode:
Diffstat (limited to 'Documentation/s390/Debugging390.txt')
-rw-r--r--Documentation/s390/Debugging390.txt493
1 files changed, 237 insertions, 256 deletions
diff --git a/Documentation/s390/Debugging390.txt b/Documentation/s390/Debugging390.txt
index 08911b5c6b0e..3df8babcdc41 100644
--- a/Documentation/s390/Debugging390.txt
+++ b/Documentation/s390/Debugging390.txt
@@ -1,14 +1,14 @@
1 1
2 Debugging on Linux for s/390 & z/Architecture 2 Debugging on Linux for s/390 & z/Architecture
3 by 3 by
4 Denis Joseph Barrow (djbarrow@de.ibm.com,barrow_dj@yahoo.com) 4 Denis Joseph Barrow (djbarrow@de.ibm.com,barrow_dj@yahoo.com)
5 Copyright (C) 2000-2001 IBM Deutschland Entwicklung GmbH, IBM Corporation 5 Copyright (C) 2000-2001 IBM Deutschland Entwicklung GmbH, IBM Corporation
6 Best viewed with fixed width fonts 6 Best viewed with fixed width fonts
7 7
8Overview of Document: 8Overview of Document:
9===================== 9=====================
10This document is intended to give a good overview of how to debug 10This document is intended to give a good overview of how to debug Linux for
11Linux for s/390 & z/Architecture. It isn't intended as a complete reference & not a 11s/390 and z/Architecture. It is not intended as a complete reference and not a
12tutorial on the fundamentals of C & assembly. It doesn't go into 12tutorial on the fundamentals of C & assembly. It doesn't go into
13390 IO in any detail. It is intended to complement the documents in the 13390 IO in any detail. It is intended to complement the documents in the
14reference section below & any other worthwhile references you get. 14reference section below & any other worthwhile references you get.
@@ -35,7 +35,6 @@ Examining core dumps
35ldd 35ldd
36Debugging modules 36Debugging modules
37The proc file system 37The proc file system
38Starting points for debugging scripting languages etc.
39SysRq 38SysRq
40References 39References
41Special Thanks 40Special Thanks
@@ -44,18 +43,20 @@ Register Set
44============ 43============
45The current architectures have the following registers. 44The current architectures have the following registers.
46 45
4716 General propose registers, 32 bit on s/390 64 bit on z/Architecture, r0-r15 or gpr0-gpr15 used for arithmetic & addressing. 4616 General propose registers, 32 bit on s/390 and 64 bit on z/Architecture,
48 47r0-r15 (or gpr0-gpr15), used for arithmetic and addressing.
4916 Control registers, 32 bit on s/390 64 bit on z/Architecture, ( cr0-cr15 kernel usage only ) used for memory management, 48
50interrupt control,debugging control etc. 4916 Control registers, 32 bit on s/390 and 64 bit on z/Architecture, cr0-cr15,
51 50kernel usage only, used for memory management, interrupt control, debugging
5216 Access registers ( ar0-ar15 ) 32 bit on s/390 & z/Architecture 51control etc.
53not used by normal programs but potentially could 52
54be used as temporary storage. Their main purpose is their 1 to 1 5316 Access registers (ar0-ar15), 32 bit on both s/390 and z/Architecture,
55association with general purpose registers and are used in 54normally not used by normal programs but potentially could be used as
56the kernel for copying data between kernel & user address spaces. 55temporary storage. These registers have a 1:1 association with general
57Access register 0 ( & access register 1 on z/Architecture ( needs 64 bit 56purpose registers and are designed to be used in the so-called access
58pointer ) ) is currently used by the pthread library as a pointer to 57register mode to select different address spaces.
58Access register 0 (and access register 1 on z/Architecture, which needs a
5964 bit pointer) is currently used by the pthread library as a pointer to
59the current running threads private area. 60the current running threads private area.
60 61
6116 64 bit floating point registers (fp0-fp15 ) IEEE & HFP floating 6216 64 bit floating point registers (fp0-fp15 ) IEEE & HFP floating
@@ -90,18 +91,19 @@ s/390 z/Architecture
90 91
916 6 Input/Output interrupt Mask 926 6 Input/Output interrupt Mask
92 93
937 7 External interrupt Mask used primarily for interprocessor signalling & 947 7 External interrupt Mask used primarily for interprocessor
94 clock interrupts. 95 signalling and clock interrupts.
95 96
968-11 8-11 PSW Key used for complex memory protection mechanism not used under linux 978-11 8-11 PSW Key used for complex memory protection mechanism
98 (not used under linux)
97 99
9812 12 1 on s/390 0 on z/Architecture 10012 12 1 on s/390 0 on z/Architecture
99 101
10013 13 Machine Check Mask 1=enable machine check interrupts 10213 13 Machine Check Mask 1=enable machine check interrupts
101 103
10214 14 Wait State set this to 1 to stop the processor except for interrupts & give 10414 14 Wait State. Set this to 1 to stop the processor except for
103 time to other LPARS used in CPU idle in the kernel to increase overall 105 interrupts and give time to other LPARS. Used in CPU idle in
104 usage of processor resources. 106 the kernel to increase overall usage of processor resources.
105 107
10615 15 Problem state ( if set to 1 certain instructions are disabled ) 10815 15 Problem state ( if set to 1 certain instructions are disabled )
107 all linux user programs run with this bit 1 109 all linux user programs run with this bit 1
@@ -165,21 +167,23 @@ s/390 z/Architecture
165 when loading the address with LPSWE otherwise a 167 when loading the address with LPSWE otherwise a
166 specification exception occurs, LPSW is fully backward 168 specification exception occurs, LPSW is fully backward
167 compatible. 169 compatible.
168 170
169 171
170Prefix Page(s) 172Prefix Page(s)
171-------------- 173--------------
172This per cpu memory area is too intimately tied to the processor not to mention. 174This per cpu memory area is too intimately tied to the processor not to mention.
173It exists between the real addresses 0-4096 on s/390 & 0-8192 z/Architecture & is exchanged 175It exists between the real addresses 0-4096 on s/390 and between 0-8192 on
174with a 1 page on s/390 or 2 pages on z/Architecture in absolute storage by the set 176z/Architecture and is exchanged with one page on s/390 or two pages on
175prefix instruction in linux'es startup. 177z/Architecture in absolute storage by the set prefix instruction during Linux
176This page is mapped to a different prefix for each processor in an SMP configuration 178startup.
177( assuming the os designer is sane of course :-) ). 179This page is mapped to a different prefix for each processor in an SMP
178Bytes 0-512 ( 200 hex ) on s/390 & 0-512,4096-4544,4604-5119 currently on z/Architecture 180configuration (assuming the OS designer is sane of course).
179are used by the processor itself for holding such information as exception indications & 181Bytes 0-512 (200 hex) on s/390 and 0-512, 4096-4544, 4604-5119 currently on
180entry points for exceptions. 182z/Architecture are used by the processor itself for holding such information
181Bytes after 0xc00 hex are used by linux for per processor globals on s/390 & z/Architecture 183as exception indications and entry points for exceptions.
182( there is a gap on z/Architecture too currently between 0xc00 & 1000 which linux uses ). 184Bytes after 0xc00 hex are used by linux for per processor globals on s/390 and
185z/Architecture (there is a gap on z/Architecture currently between 0xc00 and
1860x1000, too, which is used by Linux).
183The closest thing to this on traditional architectures is the interrupt 187The closest thing to this on traditional architectures is the interrupt
184vector table. This is a good thing & does simplify some of the kernel coding 188vector table. This is a good thing & does simplify some of the kernel coding
185however it means that we now cannot catch stray NULL pointers in the 189however it means that we now cannot catch stray NULL pointers in the
@@ -192,26 +196,26 @@ Address Spaces on Intel Linux
192 196
193The traditional Intel Linux is approximately mapped as follows forgive 197The traditional Intel Linux is approximately mapped as follows forgive
194the ascii art. 198the ascii art.
1950xFFFFFFFF 4GB Himem ***************** 1990xFFFFFFFF 4GB Himem *****************
196 * * 200 * *
197 * Kernel Space * 201 * Kernel Space *
198 * * 202 * *
199 ***************** **************** 203 ***************** ****************
200User Space Himem (typically 0xC0000000 3GB )* User Stack * * * 204User Space Himem * User Stack * * *
201 ***************** * * 205(typically 0xC0000000 3GB ) ***************** * *
202 * Shared Libs * * Next Process * 206 * Shared Libs * * Next Process *
203 ***************** * to * 207 ***************** * to *
204 * * <== * Run * <== 208 * * <== * Run * <==
205 * User Program * * * 209 * User Program * * *
206 * Data BSS * * * 210 * Data BSS * * *
207 * Text * * * 211 * Text * * *
208 * Sections * * * 212 * Sections * * *
2090x00000000 ***************** **************** 2130x00000000 ***************** ****************
210 214
211Now it is easy to see that on Intel it is quite easy to recognise a kernel address 215Now it is easy to see that on Intel it is quite easy to recognise a kernel
212as being one greater than user space himem ( in this case 0xC0000000). 216address as being one greater than user space himem (in this case 0xC0000000),
213& addresses of less than this are the ones in the current running program on this 217and addresses of less than this are the ones in the current running program on
214processor ( if an smp box ). 218this processor (if an smp box).
215If using the virtual machine ( VM ) as a debugger it is quite difficult to 219If using the virtual machine ( VM ) as a debugger it is quite difficult to
216know which user process is running as the address space you are looking at 220know which user process is running as the address space you are looking at
217could be from any process in the run queue. 221could be from any process in the run queue.
@@ -247,8 +251,8 @@ Our addressing scheme is basically as follows:
247Himem 0x7fffffff 2GB on s/390 ***************** **************** 251Himem 0x7fffffff 2GB on s/390 ***************** ****************
248currently 0x3ffffffffff (2^42)-1 * User Stack * * * 252currently 0x3ffffffffff (2^42)-1 * User Stack * * *
249on z/Architecture. ***************** * * 253on z/Architecture. ***************** * *
250 * Shared Libs * * * 254 * Shared Libs * * *
251 ***************** * * 255 ***************** * *
252 * * * Kernel * 256 * * * Kernel *
253 * User Program * * * 257 * User Program * * *
254 * Data BSS * * * 258 * Data BSS * * *
@@ -301,10 +305,10 @@ Virtual Addresses on s/390 & z/Architecture
301=========================================== 305===========================================
302 306
303A virtual address on s/390 is made up of 3 parts 307A virtual address on s/390 is made up of 3 parts
304The SX ( segment index, roughly corresponding to the PGD & PMD in linux terminology ) 308The SX (segment index, roughly corresponding to the PGD & PMD in Linux
305being bits 1-11. 309terminology) being bits 1-11.
306The PX ( page index, corresponding to the page table entry (pte) in linux terminology ) 310The PX (page index, corresponding to the page table entry (pte) in Linux
307being bits 12-19. 311terminology) being bits 12-19.
308The remaining bits BX (the byte index are the offset in the page ) 312The remaining bits BX (the byte index are the offset in the page )
309i.e. bits 20 to 31. 313i.e. bits 20 to 31.
310 314
@@ -368,9 +372,9 @@ each processor as follows.
368 * ( 8K ) * 372 * ( 8K ) *
36916K aligned ************************ 37316K aligned ************************
370 374
371What this means is that we don't need to dedicate any register or global variable 375What this means is that we don't need to dedicate any register or global
372to point to the current running process & can retrieve it with the following 376variable to point to the current running process & can retrieve it with the
373very simple construct for s/390 & one very similar for z/Architecture. 377following very simple construct for s/390 & one very similar for z/Architecture.
374 378
375static inline struct task_struct * get_current(void) 379static inline struct task_struct * get_current(void)
376{ 380{
@@ -403,8 +407,8 @@ Note: To follow stackframes requires a knowledge of C or Pascal &
403limited knowledge of one assembly language. 407limited knowledge of one assembly language.
404 408
405It should be noted that there are some differences between the 409It should be noted that there are some differences between the
406s/390 & z/Architecture stack layouts as the z/Architecture stack layout didn't have 410s/390 and z/Architecture stack layouts as the z/Architecture stack layout
407to maintain compatibility with older linkage formats. 411didn't have to maintain compatibility with older linkage formats.
408 412
409Glossary: 413Glossary:
410--------- 414---------
@@ -440,7 +444,7 @@ The code generated by the compiler to return to the caller.
440 444
441frameless-function 445frameless-function
442A frameless function in Linux for s390 & z/Architecture is one which doesn't 446A frameless function in Linux for s390 & z/Architecture is one which doesn't
443need more than the register save area ( 96 bytes on s/390, 160 on z/Architecture ) 447need more than the register save area (96 bytes on s/390, 160 on z/Architecture)
444given to it by the caller. 448given to it by the caller.
445A frameless function never: 449A frameless function never:
4461) Sets up a back chain. 4501) Sets up a back chain.
@@ -588,8 +592,8 @@ A sample program with comments.
588 592
589Comments on the function test 593Comments on the function test
590----------------------------- 594-----------------------------
5911) It didn't need to set up a pointer to the constant pool gpr13 as it isn't used 5951) It didn't need to set up a pointer to the constant pool gpr13 as it is not
592( :-( ). 596used ( :-( ).
5932) This is a frameless function & no stack is bought. 5972) This is a frameless function & no stack is bought.
5943) The compiler was clever enough to recognise that it could return the 5983) The compiler was clever enough to recognise that it could return the
595value in r2 as well as use it for the passed in parameter ( :-) ). 599value in r2 as well as use it for the passed in parameter ( :-) ).
@@ -743,35 +747,34 @@ Debugging under VM
743Notes 747Notes
744----- 748-----
745Addresses & values in the VM debugger are always hex never decimal 749Addresses & values in the VM debugger are always hex never decimal
746Address ranges are of the format <HexValue1>-<HexValue2> or <HexValue1>.<HexValue2> 750Address ranges are of the format <HexValue1>-<HexValue2> or
747e.g. The address range 0x2000 to 0x3000 can be described as 2000-3000 or 2000.1000 751<HexValue1>.<HexValue2>
752For example, the address range 0x2000 to 0x3000 can be described as 2000-3000
753or 2000.1000
748 754
749The VM Debugger is case insensitive. 755The VM Debugger is case insensitive.
750 756
751VM's strengths are usually other debuggers weaknesses you can get at any resource 757VM's strengths are usually other debuggers weaknesses you can get at any
752no matter how sensitive e.g. memory management resources,change address translation 758resource no matter how sensitive e.g. memory management resources, change
753in the PSW. For kernel hacking you will reap dividends if you get good at it. 759address translation in the PSW. For kernel hacking you will reap dividends if
754 760you get good at it.
755The VM Debugger displays operators but not operands, probably because some 761
756of it was written when memory was expensive & the programmer was probably proud that 762The VM Debugger displays operators but not operands, and also the debugger
757it fitted into 2k of memory & the programmers & didn't want to shock hardcore VM'ers by 763displays useful information on the same line as the author of the code probably
758changing the interface :-), also the debugger displays useful information on the same line & 764felt that it was a good idea not to go over the 80 columns on the screen.
759the author of the code probably felt that it was a good idea not to go over 765This isn't as unintuitive as it may seem as the s/390 instructions are easy to
760the 80 columns on the screen. 766decode mentally and you can make a good guess at a lot of them as all the
761 767operands are nibble (half byte aligned).
762As some of you are probably in a panic now this isn't as unintuitive as it may seem 768So if you have an objdump listing by hand, it is quite easy to follow, and if
763as the 390 instructions are easy to decode mentally & you can make a good guess at a lot 769you don't have an objdump listing keep a copy of the s/390 Reference Summary
764of them as all the operands are nibble ( half byte aligned ) & if you have an objdump listing 770or alternatively the s/390 principles of operation next to you.
765also it is quite easy to follow, if you don't have an objdump listing keep a copy of
766the s/390 Reference Summary & look at between pages 2 & 7 or alternatively the
767s/390 principles of operation.
768e.g. even I can guess that 771e.g. even I can guess that
7690001AFF8' LR 180F CC 0 7720001AFF8' LR 180F CC 0
770is a ( load register ) lr r0,r15 773is a ( load register ) lr r0,r15
771 774
772Also it is very easy to tell the length of a 390 instruction from the 2 most significant 775Also it is very easy to tell the length of a 390 instruction from the 2 most
773bits in the instruction ( not that this info is really useful except if you are trying to 776significant bits in the instruction (not that this info is really useful except
774make sense of a hexdump of code ). 777if you are trying to make sense of a hexdump of code).
775Here is a table 778Here is a table
776Bits Instruction Length 779Bits Instruction Length
777------------------------------------------ 780------------------------------------------
@@ -780,9 +783,6 @@ Bits Instruction Length
78010 4 Bytes 78310 4 Bytes
78111 6 Bytes 78411 6 Bytes
782 785
783
784
785
786The debugger also displays other useful info on the same line such as the 786The debugger also displays other useful info on the same line such as the
787addresses being operated on destination addresses of branches & condition codes. 787addresses being operated on destination addresses of branches & condition codes.
788e.g. 788e.g.
@@ -853,8 +853,8 @@ Displaying & modifying Registers
853-------------------------------- 853--------------------------------
854D G will display all the gprs 854D G will display all the gprs
855Adding a extra G to all the commands is necessary to access the full 64 bit 855Adding a extra G to all the commands is necessary to access the full 64 bit
856content in VM on z/Architecture obviously this isn't required for access registers 856content in VM on z/Architecture. Obviously this isn't required for access
857as these are still 32 bit. 857registers as these are still 32 bit.
858e.g. DGG instead of DG 858e.g. DGG instead of DG
859D X will display all the control registers 859D X will display all the control registers
860D AR will display all the access registers 860D AR will display all the access registers
@@ -870,10 +870,11 @@ Displaying Memory
870----------------- 870-----------------
871To display memory mapped using the current PSW's mapping try 871To display memory mapped using the current PSW's mapping try
872D <range> 872D <range>
873To make VM display a message each time it hits a particular address & continue try 873To make VM display a message each time it hits a particular address and
874continue try
874D I<range> will disassemble/display a range of instructions. 875D I<range> will disassemble/display a range of instructions.
875ST addr 32 bit word will store a 32 bit aligned address 876ST addr 32 bit word will store a 32 bit aligned address
876D T<range> will display the EBCDIC in an address ( if you are that way inclined ) 877D T<range> will display the EBCDIC in an address (if you are that way inclined)
877D R<range> will display real addresses ( without DAT ) but with prefixing. 878D R<range> will display real addresses ( without DAT ) but with prefixing.
878There are other complex options to display if you need to get at say home space 879There are other complex options to display if you need to get at say home space
879but are in primary space the easiest thing to do is to temporarily 880but are in primary space the easiest thing to do is to temporarily
@@ -884,8 +885,8 @@ restore it.
884 885
885Hints 886Hints
886----- 887-----
887If you want to issue a debugger command without halting your virtual machine with the 888If you want to issue a debugger command without halting your virtual machine
888PA1 key try prefixing the command with #CP e.g. 889with the PA1 key try prefixing the command with #CP e.g.
889#cp tr i pswa 2000 890#cp tr i pswa 2000
890also suffixing most debugger commands with RUN will cause them not 891also suffixing most debugger commands with RUN will cause them not
891to stop just display the mnemonic at the current instruction on the console. 892to stop just display the mnemonic at the current instruction on the console.
@@ -903,9 +904,10 @@ This sends a message to your own console each time do_signal is entered.
903script with breakpoints on every kernel procedure, this isn't a good idea 904script with breakpoints on every kernel procedure, this isn't a good idea
904because there are thousands of these routines & VM can only set 255 breakpoints 905because there are thousands of these routines & VM can only set 255 breakpoints
905at a time so you nearly had to spend as long pruning the file down as you would 906at a time so you nearly had to spend as long pruning the file down as you would
906entering the msg's by hand ),however, the trick might be useful for a single object file. 907entering the msgs by hand), however, the trick might be useful for a single
907On linux'es 3270 emulator x3270 there is a very useful option under the file ment 908object file. In the 3270 terminal emulator x3270 there is a very useful option
908Save Screens In File this is very good of keeping a copy of traces. 909in the file menu called "Save Screen In File" - this is very good for keeping a
910copy of traces.
909 911
910From CMS help <command name> will give you online help on a particular command. 912From CMS help <command name> will give you online help on a particular command.
911e.g. 913e.g.
@@ -920,7 +922,8 @@ SET PF9 IMM B
920This does a single step in VM on pressing F8. 922This does a single step in VM on pressing F8.
921SET PF10 ^ 923SET PF10 ^
922This sets up the ^ key. 924This sets up the ^ key.
923which can be used for ^c (ctrl-c),^z (ctrl-z) which can't be typed directly into some 3270 consoles. 925which can be used for ^c (ctrl-c),^z (ctrl-z) which can't be typed directly
926into some 3270 consoles.
924SET PF11 ^- 927SET PF11 ^-
925This types the starting keystrokes for a sysrq see SysRq below. 928This types the starting keystrokes for a sysrq see SysRq below.
926SET PF12 RETRIEVE 929SET PF12 RETRIEVE
@@ -1014,8 +1017,8 @@ Tracing Program Exceptions
1014-------------------------- 1017--------------------------
1015If you get a crash which says something like 1018If you get a crash which says something like
1016illegal operation or specification exception followed by a register dump 1019illegal operation or specification exception followed by a register dump
1017You can restart linux & trace these using the tr prog <range or value> trace option. 1020You can restart linux & trace these using the tr prog <range or value> trace
1018 1021option.
1019 1022
1020 1023
1021The most common ones you will normally be tracing for is 1024The most common ones you will normally be tracing for is
@@ -1057,9 +1060,10 @@ TR GOTO INITIAL
1057 1060
1058Tracing linux syscalls under VM 1061Tracing linux syscalls under VM
1059------------------------------- 1062-------------------------------
1060Syscalls are implemented on Linux for S390 by the Supervisor call instruction (SVC) there 256 1063Syscalls are implemented on Linux for S390 by the Supervisor call instruction
1061possibilities of these as the instruction is made up of a 0xA opcode & the second byte being 1064(SVC). There 256 possibilities of these as the instruction is made up of a 0xA
1062the syscall number. They are traced using the simple command. 1065opcode and the second byte being the syscall number. They are traced using the
1066simple command:
1063TR SVC <Optional value or range> 1067TR SVC <Optional value or range>
1064the syscalls are defined in linux/arch/s390/include/asm/unistd.h 1068the syscalls are defined in linux/arch/s390/include/asm/unistd.h
1065e.g. to trace all file opens just do 1069e.g. to trace all file opens just do
@@ -1070,12 +1074,12 @@ SMP Specific commands
1070--------------------- 1074---------------------
1071To find out how many cpus you have 1075To find out how many cpus you have
1072Q CPUS displays all the CPU's available to your virtual machine 1076Q CPUS displays all the CPU's available to your virtual machine
1073To find the cpu that the current cpu VM debugger commands are being directed at do 1077To find the cpu that the current cpu VM debugger commands are being directed at
1074Q CPU to change the current cpu VM debugger commands are being directed at do 1078do Q CPU to change the current cpu VM debugger commands are being directed at do
1075CPU <desired cpu no> 1079CPU <desired cpu no>
1076 1080
1077On a SMP guest issue a command to all CPUs try prefixing the command with cpu all. 1081On a SMP guest issue a command to all CPUs try prefixing the command with cpu
1078To issue a command to a particular cpu try cpu <cpu number> e.g. 1082all. To issue a command to a particular cpu try cpu <cpu number> e.g.
1079CPU 01 TR I R 2000.3000 1083CPU 01 TR I R 2000.3000
1080If you are running on a guest with several cpus & you have a IO related problem 1084If you are running on a guest with several cpus & you have a IO related problem
1081& cannot follow the flow of code but you know it isn't smp related. 1085& cannot follow the flow of code but you know it isn't smp related.
@@ -1101,10 +1105,10 @@ D TX0.100
1101 1105
1102Alternatively 1106Alternatively
1103============= 1107=============
1104Under older VM debuggers ( I love EBDIC too ) you can use this little program I wrote which 1108Under older VM debuggers (I love EBDIC too) you can use following little
1105will convert a command line of hex digits to ascii text which can be compiled under linux & 1109program which converts a command line of hex digits to ascii text. It can be
1106you can copy the hex digits from your x3270 terminal to your xterm if you are debugging 1110compiled under linux and you can copy the hex digits from your x3270 terminal
1107from a linuxbox. 1111to your xterm if you are debugging from a linuxbox.
1108 1112
1109This is quite useful when looking at a parameter passed in as a text string 1113This is quite useful when looking at a parameter passed in as a text string
1110under VM ( unless you are good at decoding ASCII in your head ). 1114under VM ( unless you are good at decoding ASCII in your head ).
@@ -1114,14 +1118,14 @@ TR SVC 5
1114We have stopped at a breakpoint 1118We have stopped at a breakpoint
1115000151B0' SVC 0A05 -> 0001909A' CC 0 1119000151B0' SVC 0A05 -> 0001909A' CC 0
1116 1120
1117D 20.8 to check the SVC old psw in the prefix area & see was it from userspace 1121D 20.8 to check the SVC old psw in the prefix area and see was it from userspace
1118( for the layout of the prefix area consult P18 of the s/390 390 Reference Summary 1122(for the layout of the prefix area consult the "Fixed Storage Locations"
1119if you have it available ). 1123chapter of the s/390 Reference Summary if you have it available).
1120V00000020 070C2000 800151B2 1124V00000020 070C2000 800151B2
1121The problem state bit wasn't set & it's also too early in the boot sequence 1125The problem state bit wasn't set & it's also too early in the boot sequence
1122for it to be a userspace SVC if it was we would have to temporarily switch the 1126for it to be a userspace SVC if it was we would have to temporarily switch the
1123psw to user space addressing so we could get at the first parameter of the open in 1127psw to user space addressing so we could get at the first parameter of the open
1124gpr2. 1128in gpr2.
1125Next do a 1129Next do a
1126D G2 1130D G2
1127GPR 2 = 00014CB4 1131GPR 2 = 00014CB4
@@ -1208,9 +1212,9 @@ Here are the tricks I use 9 out of 10 times it works pretty well,
1208 1212
1209When your backchain reaches a dead end 1213When your backchain reaches a dead end
1210-------------------------------------- 1214--------------------------------------
1211This can happen when an exception happens in the kernel & the kernel is entered twice 1215This can happen when an exception happens in the kernel and the kernel is
1212if you reach the NULL pointer at the end of the back chain you should be 1216entered twice. If you reach the NULL pointer at the end of the back chain you
1213able to sniff further back if you follow the following tricks. 1217should be able to sniff further back if you follow the following tricks.
12141) A kernel address should be easy to recognise since it is in 12181) A kernel address should be easy to recognise since it is in
1215primary space & the problem state bit isn't set & also 1219primary space & the problem state bit isn't set & also
1216The Hi bit of the address is set. 1220The Hi bit of the address is set.
@@ -1260,8 +1264,8 @@ V000FFFD0 00010400 80010802 8001085A 000FFFA0
1260 1264
1261our 3rd return address is 8001085A 1265our 3rd return address is 8001085A
1262 1266
1263as the 04B52002 looks suspiciously like rubbish it is fair to assume that the kernel entry routines 1267as the 04B52002 looks suspiciously like rubbish it is fair to assume that the
1264for the sake of optimisation don't set up a backchain. 1268kernel entry routines for the sake of optimisation don't set up a backchain.
1265 1269
1266now look at System.map to see if the addresses make any sense. 1270now look at System.map to see if the addresses make any sense.
1267 1271
@@ -1289,67 +1293,75 @@ Congrats you've done your first backchain.
1289s/390 & z/Architecture IO Overview 1293s/390 & z/Architecture IO Overview
1290================================== 1294==================================
1291 1295
1292I am not going to give a course in 390 IO architecture as this would take me quite a 1296I am not going to give a course in 390 IO architecture as this would take me
1293while & I'm no expert. Instead I'll give a 390 IO architecture summary for Dummies if you have 1297quite a while and I'm no expert. Instead I'll give a 390 IO architecture
1294the s/390 principles of operation available read this instead. If nothing else you may find a few 1298summary for Dummies. If you have the s/390 principles of operation available
1295useful keywords in here & be able to use them on a web search engine like altavista to find 1299read this instead. If nothing else you may find a few useful keywords in here
1296more useful information. 1300and be able to use them on a web search engine to find more useful information.
1297 1301
1298Unlike other bus architectures modern 390 systems do their IO using mostly 1302Unlike other bus architectures modern 390 systems do their IO using mostly
1299fibre optics & devices such as tapes & disks can be shared between several mainframes, 1303fibre optics and devices such as tapes and disks can be shared between several
1300also S390 can support up to 65536 devices while a high end PC based system might be choking 1304mainframes. Also S390 can support up to 65536 devices while a high end PC based
1301with around 64. Here is some of the common IO terminology 1305system might be choking with around 64.
1302 1306
1303Subchannel: 1307Here is some of the common IO terminology:
1304This is the logical number most IO commands use to talk to an IO device there can be up to
13050x10000 (65536) of these in a configuration typically there is a few hundred. Under VM
1306for simplicity they are allocated contiguously, however on the native hardware they are not
1307they typically stay consistent between boots provided no new hardware is inserted or removed.
1308Under Linux for 390 we use these as IRQ's & also when issuing an IO command (CLEAR SUBCHANNEL,
1309HALT SUBCHANNEL,MODIFY SUBCHANNEL,RESUME SUBCHANNEL,START SUBCHANNEL,STORE SUBCHANNEL &
1310TEST SUBCHANNEL ) we use this as the ID of the device we wish to talk to, the most
1311important of these instructions are START SUBCHANNEL ( to start IO ), TEST SUBCHANNEL ( to check
1312whether the IO completed successfully ), & HALT SUBCHANNEL ( to kill IO ), a subchannel
1313can have up to 8 channel paths to a device this offers redundancy if one is not available.
1314 1308
1309Subchannel:
1310This is the logical number most IO commands use to talk to an IO device. There
1311can be up to 0x10000 (65536) of these in a configuration, typically there are a
1312few hundred. Under VM for simplicity they are allocated contiguously, however
1313on the native hardware they are not. They typically stay consistent between
1314boots provided no new hardware is inserted or removed.
1315Under Linux for s390 we use these as IRQ's and also when issuing an IO command
1316(CLEAR SUBCHANNEL, HALT SUBCHANNEL, MODIFY SUBCHANNEL, RESUME SUBCHANNEL,
1317START SUBCHANNEL, STORE SUBCHANNEL and TEST SUBCHANNEL). We use this as the ID
1318of the device we wish to talk to. The most important of these instructions are
1319START SUBCHANNEL (to start IO), TEST SUBCHANNEL (to check whether the IO
1320completed successfully) and HALT SUBCHANNEL (to kill IO). A subchannel can have
1321up to 8 channel paths to a device, this offers redundancy if one is not
1322available.
1315 1323
1316Device Number: 1324Device Number:
1317This number remains static & Is closely tied to the hardware, there are 65536 of these 1325This number remains static and is closely tied to the hardware. There are 65536
1318also they are made up of a CHPID ( Channel Path ID, the most significant 8 bits ) 1326of these, made up of a CHPID (Channel Path ID, the most significant 8 bits) and
1319& another lsb 8 bits. These remain static even if more devices are inserted or removed 1327another lsb 8 bits. These remain static even if more devices are inserted or
1320from the hardware, there is a 1 to 1 mapping between Subchannels & Device Numbers provided 1328removed from the hardware. There is a 1 to 1 mapping between subchannels and
1321devices aren't inserted or removed. 1329device numbers, provided devices aren't inserted or removed.
1322 1330
1323Channel Control Words: 1331Channel Control Words:
1324CCWS are linked lists of instructions initially pointed to by an operation request block (ORB), 1332CCWs are linked lists of instructions initially pointed to by an operation
1325which is initially given to Start Subchannel (SSCH) command along with the subchannel number 1333request block (ORB), which is initially given to Start Subchannel (SSCH)
1326for the IO subsystem to process while the CPU continues executing normal code. 1334command along with the subchannel number for the IO subsystem to process
1327These come in two flavours, Format 0 ( 24 bit for backward ) 1335while the CPU continues executing normal code.
1328compatibility & Format 1 ( 31 bit ). These are typically used to issue read & write 1336CCWs come in two flavours, Format 0 (24 bit for backward compatibility) and
1329( & many other instructions ) they consist of a length field & an absolute address field. 1337Format 1 (31 bit). These are typically used to issue read and write (and many
1330For each IO typically get 1 or 2 interrupts one for channel end ( primary status ) when the 1338other) instructions. They consist of a length field and an absolute address
1331channel is idle & the second for device end ( secondary status ) sometimes you get both 1339field.
1332concurrently, you check how the IO went on by issuing a TEST SUBCHANNEL at each interrupt, 1340Each IO typically gets 1 or 2 interrupts, one for channel end (primary status)
1333from which you receive an Interruption response block (IRB). If you get channel & device end 1341when the channel is idle, and the second for device end (secondary status).
1334status in the IRB without channel checks etc. your IO probably went okay. If you didn't you 1342Sometimes you get both concurrently. You check how the IO went on by issuing a
1335probably need a doctor to examine the IRB & extended status word etc. 1343TEST SUBCHANNEL at each interrupt, from which you receive an Interruption
1344response block (IRB). If you get channel and device end status in the IRB
1345without channel checks etc. your IO probably went okay. If you didn't you
1346probably need to examine the IRB, extended status word etc.
1336If an error occurs, more sophisticated control units have a facility known as 1347If an error occurs, more sophisticated control units have a facility known as
1337concurrent sense this means that if an error occurs Extended sense information will 1348concurrent sense. This means that if an error occurs Extended sense information
1338be presented in the Extended status word in the IRB if not you have to issue a 1349will be presented in the Extended status word in the IRB. If not you have to
1339subsequent SENSE CCW command after the test subchannel. 1350issue a subsequent SENSE CCW command after the test subchannel.
1340 1351
1341 1352
1342TPI( Test pending interrupt) can also be used for polled IO but in multitasking multiprocessor 1353TPI (Test pending interrupt) can also be used for polled IO, but in
1343systems it isn't recommended except for checking special cases ( i.e. non looping checks for 1354multitasking multiprocessor systems it isn't recommended except for
1344pending IO etc. ). 1355checking special cases (i.e. non looping checks for pending IO etc.).
1345 1356
1346Store Subchannel & Modify Subchannel can be used to examine & modify operating characteristics 1357Store Subchannel and Modify Subchannel can be used to examine and modify
1347of a subchannel ( e.g. channel paths ). 1358operating characteristics of a subchannel (e.g. channel paths).
1348 1359
1349Other IO related Terms: 1360Other IO related Terms:
1350Sysplex: S390's Clustering Technology 1361Sysplex: S390's Clustering Technology
1351QDIO: S390's new high speed IO architecture to support devices such as gigabit ethernet, 1362QDIO: S390's new high speed IO architecture to support devices such as gigabit
1352this architecture is also designed to be forward compatible with up & coming 64 bit machines. 1363ethernet, this architecture is also designed to be forward compatible with
1364upcoming 64 bit machines.
1353 1365
1354 1366
1355General Concepts 1367General Concepts
@@ -1406,37 +1418,40 @@ sometimes called Bus-and Tag & sometimes Original Equipment Manufacturers
1406Interface (OEMI). 1418Interface (OEMI).
1407 1419
1408This byte wide Parallel channel path/bus has parity & data on the "Bus" cable 1420This byte wide Parallel channel path/bus has parity & data on the "Bus" cable
1409& control lines on the "Tag" cable. These can operate in byte multiplex mode for 1421and control lines on the "Tag" cable. These can operate in byte multiplex mode
1410sharing between several slow devices or burst mode & monopolize the channel for the 1422for sharing between several slow devices or burst mode and monopolize the
1411whole burst. Up to 256 devices can be addressed on one of these cables. These cables are 1423channel for the whole burst. Up to 256 devices can be addressed on one of these
1412about one inch in diameter. The maximum unextended length supported by these cables is 1424cables. These cables are about one inch in diameter. The maximum unextended
1413125 Meters but this can be extended up to 2km with a fibre optic channel extended 1425length supported by these cables is 125 Meters but this can be extended up to
1414such as a 3044. The maximum burst speed supported is 4.5 megabytes per second however 14262km with a fibre optic channel extended such as a 3044. The maximum burst speed
1415some really old processors support only transfer rates of 3.0, 2.0 & 1.0 MB/sec. 1427supported is 4.5 megabytes per second. However, some really old processors
1428support only transfer rates of 3.0, 2.0 & 1.0 MB/sec.
1416One of these paths can be daisy chained to up to 8 control units. 1429One of these paths can be daisy chained to up to 8 control units.
1417 1430
1418 1431
1419ESCON if fibre optic it is also called FICON 1432ESCON if fibre optic it is also called FICON
1420Was introduced by IBM in 1990. Has 2 fibre optic cables & uses either leds or lasers 1433Was introduced by IBM in 1990. Has 2 fibre optic cables and uses either leds or
1421for communication at a signaling rate of up to 200 megabits/sec. As 10bits are transferred 1434lasers for communication at a signaling rate of up to 200 megabits/sec. As
1422for every 8 bits info this drops to 160 megabits/sec & to 18.6 Megabytes/sec once 143510bits are transferred for every 8 bits info this drops to 160 megabits/sec
1423control info & CRC are added. ESCON only operates in burst mode. 1436and to 18.6 Megabytes/sec once control info and CRC are added. ESCON only
1437operates in burst mode.
1424 1438
1425ESCONs typical max cable length is 3km for the led version & 20km for the laser version 1439ESCONs typical max cable length is 3km for the led version and 20km for the
1426known as XDF ( extended distance facility ). This can be further extended by using an 1440laser version known as XDF (extended distance facility). This can be further
1427ESCON director which triples the above mentioned ranges. Unlike Bus & Tag as ESCON is 1441extended by using an ESCON director which triples the above mentioned ranges.
1428serial it uses a packet switching architecture the standard Bus & Tag control protocol 1442Unlike Bus & Tag as ESCON is serial it uses a packet switching architecture,
1429is however present within the packets. Up to 256 devices can be attached to each control 1443the standard Bus & Tag control protocol is however present within the packets.
1430unit that uses one of these interfaces. 1444Up to 256 devices can be attached to each control unit that uses one of these
1445interfaces.
1431 1446
1432Common 390 Devices include: 1447Common 390 Devices include:
1433Network adapters typically OSA2,3172's,2116's & OSA-E gigabit ethernet adapters, 1448Network adapters typically OSA2,3172's,2116's & OSA-E gigabit ethernet adapters,
1434Consoles 3270 & 3215 ( a teletype emulated under linux for a line mode console ). 1449Consoles 3270 & 3215 (a teletype emulated under linux for a line mode console).
1435DASD's direct access storage devices ( otherwise known as hard disks ). 1450DASD's direct access storage devices ( otherwise known as hard disks ).
1436Tape Drives. 1451Tape Drives.
1437CTC ( Channel to Channel Adapters ), 1452CTC ( Channel to Channel Adapters ),
1438ESCON or Parallel Cables used as a very high speed serial link 1453ESCON or Parallel Cables used as a very high speed serial link
1439between 2 machines. We use 2 cables under linux to do a bi-directional serial link. 1454between 2 machines.
1440 1455
1441 1456
1442Debugging IO on s/390 & z/Architecture under VM 1457Debugging IO on s/390 & z/Architecture under VM
@@ -1475,9 +1490,9 @@ or the halt subchannels
1475or TR HSCH 7C08-7C09 1490or TR HSCH 7C08-7C09
1476MSCH's ,STSCH's I think you can guess the rest 1491MSCH's ,STSCH's I think you can guess the rest
1477 1492
1478Ingo's favourite trick is tracing all the IO's & CCWS & spooling them into the reader of another 1493A good trick is tracing all the IO's and CCWS and spooling them into the reader
1479VM guest so he can ftp the logfile back to his own machine.I'll do a small bit of this & give you 1494of another VM guest so he can ftp the logfile back to his own machine. I'll do
1480 a look at the output. 1495a small bit of this and give you a look at the output.
1481 1496
14821) Spool stdout to VM reader 14971) Spool stdout to VM reader
1483SP PRT TO (another vm guest ) or * for the local vm guest 1498SP PRT TO (another vm guest ) or * for the local vm guest
@@ -1593,8 +1608,8 @@ undisplay : undo's display's
1593 1608
1594info breakpoints: shows all current breakpoints 1609info breakpoints: shows all current breakpoints
1595 1610
1596info stack: shows stack back trace ( if this doesn't work too well, I'll show you the 1611info stack: shows stack back trace (if this doesn't work too well, I'll show
1597stacktrace by hand below ). 1612you the stacktrace by hand below).
1598 1613
1599info locals: displays local variables. 1614info locals: displays local variables.
1600 1615
@@ -1619,7 +1634,8 @@ next: like step except this will not step into subroutines
1619stepi: steps a single machine code instruction. 1634stepi: steps a single machine code instruction.
1620e.g. stepi 100 1635e.g. stepi 100
1621 1636
1622nexti: steps a single machine code instruction but will not step into subroutines. 1637nexti: steps a single machine code instruction but will not step into
1638subroutines.
1623 1639
1624finish: will run until exit of the current routine 1640finish: will run until exit of the current routine
1625 1641
@@ -1721,7 +1737,8 @@ e.g.
1721outputs: 1737outputs:
1722$1 = 11 1738$1 = 11
1723 1739
1724You might now be thinking that the line above didn't work, something extra had to be done. 1740You might now be thinking that the line above didn't work, something extra had
1741to be done.
1725(gdb) call fflush(stdout) 1742(gdb) call fflush(stdout)
1726hello world$2 = 0 1743hello world$2 = 0
1727As an aside the debugger also calls malloc & free under the hood 1744As an aside the debugger also calls malloc & free under the hood
@@ -1804,26 +1821,17 @@ man gdb or info gdb.
1804core dumps 1821core dumps
1805---------- 1822----------
1806What a core dump ?, 1823What a core dump ?,
1807A core dump is a file generated by the kernel ( if allowed ) which contains the registers, 1824A core dump is a file generated by the kernel (if allowed) which contains the
1808& all active pages of the program which has crashed. 1825registers and all active pages of the program which has crashed.
1809From this file gdb will allow you to look at the registers & stack trace & memory of the 1826From this file gdb will allow you to look at the registers, stack trace and
1810program as if it just crashed on your system, it is usually called core & created in the 1827memory of the program as if it just crashed on your system. It is usually
1811current working directory. 1828called core and created in the current working directory.
1812This is very useful in that a customer can mail a core dump to a technical support department 1829This is very useful in that a customer can mail a core dump to a technical
1813& the technical support department can reconstruct what happened. 1830support department and the technical support department can reconstruct what
1814Provided they have an identical copy of this program with debugging symbols compiled in & 1831happened. Provided they have an identical copy of this program with debugging
1815the source base of this build is available. 1832symbols compiled in and the source base of this build is available.
1816In short it is far more useful than something like a crash log could ever hope to be. 1833In short it is far more useful than something like a crash log could ever hope
1817 1834to be.
1818In theory all that is missing to restart a core dumped program is a kernel patch which
1819will do the following.
18201) Make a new kernel task structure
18212) Reload all the dumped pages back into the kernel's memory management structures.
18223) Do the required clock fixups
18234) Get all files & network connections for the process back into an identical state ( really difficult ).
18245) A few more difficult things I haven't thought of.
1825
1826
1827 1835
1828Why have I never seen one ?. 1836Why have I never seen one ?.
1829Probably because you haven't used the command 1837Probably because you haven't used the command
@@ -1868,7 +1876,7 @@ Breakpoint 2 at 0x4d87a4: file top.c, line 2609.
1868#3 0x5167e6 in readline_internal_char () at readline.c:454 1876#3 0x5167e6 in readline_internal_char () at readline.c:454
1869#4 0x5168ee in readline_internal_charloop () at readline.c:507 1877#4 0x5168ee in readline_internal_charloop () at readline.c:507
1870#5 0x51692c in readline_internal () at readline.c:521 1878#5 0x51692c in readline_internal () at readline.c:521
1871#6 0x5164fe in readline (prompt=0x7ffff810 "\177ÿøx\177ÿ÷Ø\177ÿøxÀ") 1879#6 0x5164fe in readline (prompt=0x7ffff810)
1872 at readline.c:349 1880 at readline.c:349
1873#7 0x4d7a8a in command_line_input (prompt=0x564420 "(gdb) ", repeat=1, 1881#7 0x4d7a8a in command_line_input (prompt=0x564420 "(gdb) ", repeat=1,
1874 annotation_suffix=0x4d6b44 "prompt") at top.c:2091 1882 annotation_suffix=0x4d6b44 "prompt") at top.c:2091
@@ -1929,8 +1937,8 @@ cat /proc/sys/net/ipv4/ip_forward
1929On my machine now outputs 1937On my machine now outputs
19301 19381
1931IP forwarding is on. 1939IP forwarding is on.
1932There is a lot of useful info in here best found by going in & having a look around, 1940There is a lot of useful info in here best found by going in and having a look
1933so I'll take you through some entries I consider important. 1941around, so I'll take you through some entries I consider important.
1934 1942
1935All the processes running on the machine have their own entry defined by 1943All the processes running on the machine have their own entry defined by
1936/proc/<pid> 1944/proc/<pid>
@@ -2060,7 +2068,8 @@ if the device doesn't say up
2060try 2068try
2061/etc/rc.d/init.d/network start 2069/etc/rc.d/init.d/network start
2062( this starts the network stack & hopefully calls ifconfig tr0 up ). 2070( this starts the network stack & hopefully calls ifconfig tr0 up ).
2063ifconfig looks at the output of /proc/net/dev & presents it in a more presentable form 2071ifconfig looks at the output of /proc/net/dev and presents it in a more
2072presentable form.
2064Now ping the device from a machine in the same subnet. 2073Now ping the device from a machine in the same subnet.
2065if the RX packets count & TX packets counts don't increment you probably 2074if the RX packets count & TX packets counts don't increment you probably
2066have problems. 2075have problems.
@@ -2086,34 +2095,6 @@ of the device.
2086See the manpage chandev.8 &type cat /proc/chandev for more info. 2095See the manpage chandev.8 &type cat /proc/chandev for more info.
2087 2096
2088 2097
2089
2090Starting points for debugging scripting languages etc.
2091======================================================
2092
2093bash/sh
2094
2095bash -x <scriptname>
2096e.g. bash -x /usr/bin/bashbug
2097displays the following lines as it executes them.
2098+ MACHINE=i586
2099+ OS=linux-gnu
2100+ CC=gcc
2101+ CFLAGS= -DPROGRAM='bash' -DHOSTTYPE='i586' -DOSTYPE='linux-gnu' -DMACHTYPE='i586-pc-linux-gnu' -DSHELL -DHAVE_CONFIG_H -I. -I. -I./lib -O2 -pipe
2102+ RELEASE=2.01
2103+ PATCHLEVEL=1
2104+ RELSTATUS=release
2105+ MACHTYPE=i586-pc-linux-gnu
2106
2107perl -d <scriptname> runs the perlscript in a fully interactive debugger
2108<like gdb>.
2109Type 'h' in the debugger for help.
2110
2111for debugging java type
2112jdb <filename> another fully interactive gdb style debugger.
2113& type ? in the debugger for help.
2114
2115
2116
2117SysRq 2098SysRq
2118===== 2099=====
2119This is now supported by linux for s/390 & z/Architecture. 2100This is now supported by linux for s/390 & z/Architecture.