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