Debugging a Program … Using the PC/370 Emulator Interactively !

Slides:



Advertisements
Similar presentations
Getting started with MPLAB Launch MPLAB Set Toolbar as in the next slide by clicking the leftmost icon Open a new Source file by choosing [FILE][NEW] Type.
Advertisements

Instruction Set Design
Interrupts Chapter 8 – pp Chapter 10 – pp Appendix A – pp 537 &
Chapter 12 CPU Structure and Function. CPU Sequence Fetch instructions Interpret instructions Fetch data Process data Write data.
The Little man computer
Chapter 6: Machine dependent Assembler Features
Execution of an instruction
Savio Chau Single Cycle Controller Design Last Time: Discussed the Designing of a Single Cycle Datapath Control Datapath Memory Processor (CPU) Input Output.
Some thoughts: If it is too good to be true, it isn’t. Success is temporary. It is hard work to make it simple. Knowing you did it right is enough reward.
The IDE (Integrated Development Environment) provides a DEBUGGER for locating and correcting errors in program logic (logic errors not syntax errors) The.
Systems Environment 3 Quick Revision Review of Exercises Introduction to TOM TOM Exercises.
Chapters 5 - The LC-3 LC-3 Computer Architecture Memory Map
Chapter 4 H1 Assembly Language: Part 2. Direct instruction Contains the absolute address of the memory location it accesses. ld instruction:
ARM 7 Datapath. Has “BIGEND” input bit, which defines whether the memory is big or little endian Modes: ARM7 supports six modes of operation: (1) User.
8051 ASSEMBLY LANGUAGE PROGRAMMING
OllyDbg Debuger.
Group 5 Alain J. Percial Paula A. Ortiz Francis X. Ruiz.
Assembly & Machine Languages
What are Exception and Interrupts? MIPS terminology Exception: any unexpected change in the internal control flow – Invoking an operating system service.
Chapter 2 Software Tools and Assembly Language Syntax.
The von Neumann Model – Chapter 4 COMP 2620 Dr. James Money COMP
Micro-Computer Applications: Procedures & Interrupts Dr. Eng. Amr T. Abdel-Hamid ELECT 707 Fall 2011.
Interrupts. What Are Interrupts? Interrupts alter a program’s flow of control  Behavior is similar to a procedure call »Some significant differences.
Presented by: Sergio Ospina Qing Gao. Contents ♦ 12.1 Processor Organization ♦ 12.2 Register Organization ♦ 12.3 Instruction Cycle ♦ 12.4 Instruction.
COSC 3430 L08 Basic MIPS Architecture.1 COSC 3430 Computer Architecture Lecture 08 Processors Single cycle Datapath PH 3: Sections
Debugging in Java. Common Bugs Compilation or syntactical errors are the first that you will encounter and the easiest to debug They are usually the result.
Testing and Debugging Version 1.0. All kinds of things can go wrong when you are developing a program. The compiler discovers syntax errors in your code.
CS 320 Assignment 1 Rewriting the MISC Osystem class to support loading machine language programs at addresses other than 0 1.
CIS 020 Assembly Programming Chapter 10 - Understanding the Assembly Process © John Urrutia 2012, All Rights Reserved.5/27/20121.
Chapter 10 The Assembly Process. What Assemblers Do Translates assembly language into machine code. Assigns addresses to all symbolic labels (variables.
Copyright 2006 by Timothy J. McGuire, Ph.D. 1 MIPS Assembly Language CS 333 Sam Houston State University Dr. Tim McGuire.
BMTRY 789 Lecture 11: Debugging Readings – Chapter 10 (3 rd Ed) from “The Little SAS Book” Lab Problems – None Homework Due – None Final Project Presentations.
Interrupt driven I/O. MIPS RISC Exception Mechanism The processor operates in The processor operates in user mode user mode kernel mode kernel mode Access.
C HAPTER 5 T HE PROCESSOR : D ATAPATH AND C ONTROL M ULTICYCLE D ESIGN.
IT253: Computer Organization Lecture 9: Making a Processor: Single-Cycle Processor Design Tonga Institute of Higher Education.
Interrupt driven I/O Computer Organization and Assembly Language: Module 12.
Computer Systems – Machine & Assembly code. Objectives Machine Code Assembly Language Op-code Operand Instruction Set.
Copyright 2006 by Timothy J. McGuire, Ph.D. 1 MIPS Assembly Language CS 333 Sam Houston State University Dr. Tim McGuire.
CS61C L20 Datapath © UC Regents 1 Microprocessor James Tan Adapted from D. Patterson’s CS61C Copyright 2000.
CIS 020 Assembly Programming
Elements of Datapath for the fetch and increment The first element we need: a memory unit to store the instructions of a program and supply instructions.
The LC-3 – Chapter 5 COMP 2620 Dr. James Money COMP
Computer Organization Instructions Language of The Computer (MIPS) 2.
COM181 Computer Hardware Lecture 6: The MIPs CPU.
Single Cycle Controller Design
Introduction to Computing Systems and Programming Programming.
Dynamic Black-Box Testing Part 1 What is dynamic black-box testing? How to reduce the number of test cases using: Equivalence partitioning Boundary value.
Writing an Assembly-language program MIPS assembly language using MARS: MIPS Assembler and Runtime Simulator CS-2710 Dr. Mark L. Hornick 1.
Displacement (Indexed) Stack
Machine dependent Assembler Features
Computer Organization
Addressing Modes in Microprocessors
Assembly Language Programming Part 3
Malware Incident Response  Dynamic Analysis - 2
Arithmetic using a stack
SCHOOL OF ELECTRONICS ENGINEERING Electronics and Communication
Assemblers - 2 CSCI/CMPE 3334 David Egle.
CSCI206 - Computer Organization & Programming
Instruction encoding We’ve already seen some important aspects of processor design. A datapath contains an ALU, registers and memory. Programmers and compilers.
The Processor Lecture 3.2: Building a Datapath with Control
Computer Architecture
Other ISAs Next, we’ll first we look at a longer example program, starting with some C code and translating it into our assembly language. Then we discuss.
Instruction encoding We’ve already seen some important aspects of processor design. A datapath contains an ALU, registers and memory. Programmers and compilers.
The branch instruction
8051 ASSEMBLY LANGUAGE PROGRAMMING
Program Execution.
Basic components Instruction processing
COMS 361 Computer Organization
Chapter 6 Programming.
Presentation transcript:

Debugging a Program … Using the PC/370 Emulator Interactively !

Debug features available? Program Flow Trace with Breakpoints Display register contents Display memory contents Data and/or address stop, if needed

Interactive Debug Options: There are more options, but these are the ones you will most likely use. PSW automatically displays each time. Debug OptionExplanation DDump (display) a memory location MModify a memory location RDisplay general purpose registers

Enter option- D,M,R (‘H’ lists all options) EP = Entry Point A=Address Following 370 A = Failing Address in PSW OP = instruction at the failing PSW address Remember that most times, the failing address (0002B6 in this example) points to the next instruction to be executed. The failing instruction has already had its PSW address updated to point to the next instruction, but this instruction failed in execution. In PC/370, programs are loaded into memory at , so relating the failing instruction address to your program, this would be the instruction (in your PRN listing) at offset 0000B6, actually the instruction before this one, that failed. You most likely would wish to see the registers first, so enter option ‘R’

Other Debug Aids Assembler Output Listing Fragment (.PRN file) Location Counter (Displacement from location zero) Object Code Addr1Addr2 (Displacements of operands from zero) Assembler Statement Number

Other Debug Aids A Test Plan –Unit Testing: each module functions properly –System Testing: all modules function together –Acceptance Testing: User sign-off Before testing, develop & document a plan –Test all possible conditions – major ones 1 st –Develop test data –Test: comparing & documenting results against expected results From Experience –Don’t try to test too much of a program at one time. Create little chunks. –If you make a change to your code, save the old code before changing it

So – your program ends abnormally ?? 1.Find the instruction that led to the problem Location immediately following the failing instruction Instruction following the failing instruction

2.Find the cause of the error 3.Fix it So – your program ends abnormally ?? PSW Address when program failed and the instruction at that location. We know that it was the instruction prior to the instruction that failed (SVC 0000B4). This is instruction is part of the CLOSE that has the to the left. We probably have something wrong with either our DCB or the data file that is being closed.

You may also get yourself an abnormal completion code … CodeTypeMeaning 0C1OperationInvalid operation code 0C4SecurityProtection Exception 0C5AddressingAddress is out of range 0C7DataInvalid Data for Instruct. 0CADecimalDecimal Overflow If so, examine the completion code meaning:

When the program abnormally terminates you can enter most any of the debugging codes (‘R’ was used in this case) to display the current registers. The PSW also is displayed and the ABEND code appears as well.

Finding the Failing Instruction Subtract START address from the Interrupt address. Use.PRN listing to locate failing instruction using the Location Counter Failing instruction is the one before the difference calculated in number 1 above

Failing Address Fail Addr 02B4 Load Addr B4 PSW PSW 02B4 Enter ‘R’ for Register display, PSW, and memory fragment

Program failed in GET …

Back to the source code

REALTORS file is not located on H: drive. It’s on the same drive as the program (f:) – note the DDNAME parameter …

Another Example 49C C Data at loc. ’49C’ looks like EBCDIC data. You can’t execute data …

So What Happened? Program is trying to execute instructions at location X’29C’ which is the beginning of the output DCB Instruction is the op.code ‘C1’ What is op.code ‘C1’ ? There is no valid op.code ‘C1’ So how did the location counter get to be ’29C’?

Harmlessly and minding its own business, program is executing along to a F4, jump to 10C and execute along some more to a B OUTPUT… Where is OUTPUT defined?

OUTPUT is the DCB the program was trying to execute. That makes for an invalid Branch instruction

Invalid Branch probably should have been a BR 5 – since we were in a subroutine that program did a BAL to

Register 5 BAL instruction B OUTPUT BAL executed correctly – note contents of Reg 5 But addess in B OUTPUT probably should be the address in Reg 5, but it’s not

A Real Example

When you get into trouble, the first thing you should ask for is to see the registers at the time of the failure. This also provides the PSW at the time of the failure and 16 bytes of memory at the location of the failure. This also includes the ABEND code, if present. In this case, the ABEND code is 0C7, which is a data exception

Here is the failing instruction – actually the failing instruction is the instruction above the one that the PSW highlights – the first CVB instruction.

For both CVB instructions, the data locations are defined as shown. Do you see something wrong?

CURRPRC(7) F 53B CURRENTP(7) F3F6F5F2F9F8F7 CALCPACKCURRPRC(7),CURRENTP(7) APCURRTOTL(7),CURRPRC(7) CVB4,CURRPRC CURRTOTL(7) C R4

So what is the error ? Memory Location for CVB and CVD must be an eight- byte field. In this case, it is defined as 7-bytes

Not Always That Easy … Develop a foolproof approach –Find Completion Code, if one exists –Obtain Location counter value by subtracting START from failing address –Find the instruction in assembly listing –Now you may need register contents, memory locations, and more –Insert WTOs into your code at key points –Rerun, retest, etc.

Consider Printing the Debug Guide \FULL \DOC \USER.DOC