Monitoring, Tracing, Debugging (Under Construction)



Similar documents
Example of Standard API

Testing for Security

System Structures. Services Interface Structure

Get the Better of Memory Leaks with Valgrind Whitepaper

Instrumentation Software Profiling

Last Class: OS and Computer Architecture. Last Class: OS and Computer Architecture

Java Application Development using Eclipse. Jezz Kelway Java Technology Centre, z/os Service IBM Hursley Park Labs, United Kingdom

Application-Level Debugging and Profiling: Gaps in the Tool Ecosystem. Dr Rosemary Francis, Ellexus

Chapter 3 Operating-System Structures

Running a Program on an AVD

For Introduction to Java Programming, 5E By Y. Daniel Liang

Mobile Application Hacking for Android and iphone. 4-Day Hands-On Course. Syllabus

CS10110 Introduction to personal computer equipment

Jonathan Worthington Scarborough Linux User Group

9/11/15. What is Programming? CSCI 209: Software Development. Discussion: What Is Good Software? Characteristics of Good Software?

What s Cool in the SAP JVM (CON3243)

How To Use Java On An Ipa (Jspa) With A Microsoft Powerbook (Jempa) With An Ipad And A Microos 2.5 (Microos)

Tuning WebSphere Application Server ND 7.0. Royal Cyber Inc.

Mobile Application Development Android

This presentation will discuss how to troubleshoot different types of project creation issues with Information Server DataStage version 8.

Chapter 2 System Structures

Lecture 1 Introduction to Android

ELEC 377. Operating Systems. Week 1 Class 3

Java VM monitoring and the Health Center API. William Smith

Module 10. Coding and Testing. Version 2 CSE IIT, Kharagpur

Tutorial 5: Developing Java applications

Last Class: OS and Computer Architecture. Last Class: OS and Computer Architecture

CSCI E 98: Managed Environments for the Execution of Programs

Overview of CS 282 & Android

Profiling and Testing with Test and Performance Tools Platform (TPTP)

Chapter 3: Operating-System Structures. Common System Components

Real-time Debugging using GDB Tracepoints and other Eclipse features

Debugging Java Applications

Java Debugging Ľuboš Koščo

Eliminate Memory Errors and Improve Program Stability

Real-Time Systems Prof. Dr. Rajib Mall Department of Computer Science and Engineering Indian Institute of Technology, Kharagpur

CS3600 SYSTEMS AND NETWORKS

GPU Profiling with AMD CodeXL

Operating System Structures

TDA - Thread Dump Analyzer

COS 318: Operating Systems

Modern Software Development Tools on OpenVMS

Basic Unix/Linux 1. Software Testing Interview Prep

CSC 2405: Computer Systems II

Frysk The Systems Monitoring and Debugging Tool. Andrew Cagney

Introducing the IBM Software Development Kit for PowerLinux

Tool - 1: Health Center

11.1 inspectit inspectit

Debugging with TotalView

Kernel comparison of OpenSolaris, Windows Vista and. Linux 2.6

Lecture 17: Mobile Computing Platforms: Android. Mythili Vutukuru CS 653 Spring 2014 March 24, Monday

Topics. Introduction. Java History CS 146. Introduction to Programming and Algorithms Module 1. Module Objectives

Objectives. Chapter 2: Operating-System Structures. Operating System Services (Cont.) Operating System Services. Operating System Services (Cont.

Optimizing Linux Performance

2015 ej-technologies GmbH. All rights reserved. JProfiler Manual

Interpreters and virtual machines. Interpreters. Interpreters. Why interpreters? Tree-based interpreters. Text-based interpreters

B M C S O F T W A R E, I N C. BASIC BEST PRACTICES. Ross Cochran Principal SW Consultant

Q N X S O F T W A R E D E V E L O P M E N T P L A T F O R M v Steps to Developing a QNX Program Quickstart Guide

RED HAT DEVELOPER TOOLSET Build, Run, & Analyze Applications On Multiple Versions of Red Hat Enterprise Linux

Eclipse Visualization and Performance Monitoring

CPS221 Lecture: Operating System Structure; Virtual Machines

x86 ISA Modifications to support Virtual Machines

Java Troubleshooting and Performance

10 STEPS TO YOUR FIRST QNX PROGRAM. QUICKSTART GUIDE Second Edition

SCADA/HMI MOVICON TRAINING COURSE PROGRAM

DS-5 ARM. Using the Debugger. Version 5.7. Copyright 2010, 2011 ARM. All rights reserved. ARM DUI 0446G (ID092311)

Restraining Execution Environments

All Your Code Belongs To Us Dismantling Android Secrets With CodeInspect. Steven Arzt Secure Software Engineering Group Steven Arzt 1

How To Improve Performance On An Asa 9.4 Web Application Server (For Advanced Users)

Debugging & Profiling with Open Source SW Tools

THE BUSY DEVELOPER'S GUIDE TO JVM TROUBLESHOOTING

2 Introduction to Java. Introduction to Programming 1 1

Using jvmstat and visualgc to Solve Memory Management Problems

Effective Java Programming. efficient software development

GDB Tutorial. A Walkthrough with Examples. CMSC Spring Last modified March 22, GDB Tutorial

BEAJRockit Mission Control. Using JRockit Mission Control in the Eclipse IDE

Sequential Performance Analysis with Callgrind and KCachegrind

Development Environment and Tools for Java. Brian Hughes IBM

Reminders. Lab opens from today. Many students want to use the extra I/O pins on

OPERATING SYSTEM SERVICES

ERIKA Enterprise pre-built Virtual Machine

Introduction to Automated Testing

IBM Software Group. SW5706 JVM Tools IBM Corporation 4.0. This presentation will act as an introduction to JVM tools.

Software Engineering for LabVIEW Applications. Elijah Kerry LabVIEW Product Manager

Real Time Programming: Concepts

Operating Systems and Networks

vmprof Documentation Release 0.1 Maciej Fijalkowski, Antonio Cuni, Sebastian Pawlus

NetBeans Profiler is an

Data Sheet VISUAL COBOL WHAT S NEW? COBOL JVM. Java Application Servers. Web Tools Platform PERFORMANCE. Web Services and JSP Tutorials

Hypercosm. Studio.

WebSphere Architect (Performance and Monitoring) 2011 IBM Corporation

Practical Performance Understanding the Performance of Your Application

Oracle Solaris Studio Code Analyzer

Introduction to Synoptic

IBM Support Assistant v5. Review and hands-on by Joseph

Building Applications Using Micro Focus COBOL

AMD CodeXL 1.7 GA Release Notes

Transcription:

Monitoring, Tracing, Debugging (Under Construction) I was already tempted to drop this topic from my lecture on operating systems when I found Stephan Siemen's article "Top Speed" in Linux World 10/2003. He mentions a whole range of useful tools for performance tracking and bug finding on Linux and I decided to take his list and give some additional background on how these things work.after being a unix kernel hacker for some year I moved into user space and started to develop more and more user level code. I soon realized that the style of development used for kernel hacking is quite different to the one needed for servers, frameworks and applications. Some concepts still apply, like logging events. Others change, e.g. using garbage collectors. Some of the tools that made the biggest impression where Pure Atria's Purify (now IBM Rational) - object code instrumentation the easy way. And the Visual Age (now Eclipse) Debugger which made me give up on printf/println style of finding bugs. Look at the resource section at the end for links.

Introduction 2 / 30

Goals 1. A word on monitoring, tracing, debugging. 2. Modern approaches for tracing, logging and auditing. 3. Understanding interfaces within and between programs and environments. Remember: every problem in computer science is solved with one more level of indirection. And interfaces are the locations where program flow can be re-directed. 4. Monitoring Levels 5. Different techniques for monitoring 6. Performance and memory tracking. How garbage collection works will be explained in detail in our session on virtual memory. Here we will do wiht the basic concept of memory colloring to find wrong reads/writes. 7. There are still developers out there using printf/println for DEBUGGING or LOGGING. After these slides I don't want to see this practice EVER again in your work!. The basics of debugging (breakpoints, stack, threads). Introduction 3 / 30

What monitoring, logging and debugging really means 4 / 30

Overview What monitoring, logging and debugging really means 5 / 30

Overview (Continued) What monitoring, logging and debugging really means 6 / 30

The basic pattern behind monitoring, logging and The interceptor pattern underlies all these mechanisms. To get information about a certain control flow it needs to be intercepted and written into a log somehow. Depending on where the program flow is intercepted we know different levels of monitoring. What monitoring, logging and debugging really means 7 / 30

Monitoring Levels Kernel Kernel monitoring means tracking the performance or behavior of a whole system. It is only possible with the help of the kernel itself, either through device driver modules or through kernel functionality directly. Control and data are usually maintained in userspace. Process Level How does the process behave with respect to resource consumption? How much time is spent in user vs. system mode? How much memory is allocated? Garbage Collectors provide monitoring interfaces which allow the tracking of memory usage. Utilities like ps, top, taskmanager show process activity. System Call Level Library Level (static) Applications (and user level servers) finally need to call the operating system for critical functions like I/O. This is done through kernel traps - an ideal place to watch what a program does without further interfering with it (or having to modify it) Many applications use additional libraries or organize their own code into libs. If those libraries are linked statically into the program they become a fixed part of the application. Sometimes special versions of those libraries exist (with additional functions for tracking problems). The applications gets rebuilt wiht such a library and runs now in a "debugging" mode. What monitoring, logging and debugging really means 8 / 30

Monitoring Levels (Continued) Library Level (dynamic, dll) Method or Function call level (with or without VM) Intra-function or intramethod level Libraries can be loaded at runtime. In this case it is easy to replace the lib with a dummy or debug version or just intercept the call from the application to the library function, do some monitoring and then forward the call to the real lib. Most programming languages offer no easy way to intercept program-internal calls to its own methods or functions. The compiler needs to help here. Driven by compile time arguments the compiler inserts extra code between function calls which performs monitoring functions. Applications need to be recompiled of course. It is easier if the program runs under the control of a virtual machine because the VM usually has a monitoring interface which allows the user to switch into special monitoring or profiling modes. At this level people start talking about "profiling" the applications control flow via the "call graph" (the order of funtion or method calls). Performance optimizations usually require this level of analysis. Due to the lack of interfaces this level is tracked by inserting debugging code (println/printf) into the program. Requires code changes of course and needs to be removed after the problems are found. An alternative is the use of a debugger which frequently also requires a recompilation with special debug What monitoring, logging and debugging really means 9 / 30

Monitoring Levels (Continued) Intra-expression level arguments. Only debuggers can reach this level. With virtual machines one could possibly also single step through the bytecode. What monitoring, logging and debugging really means 10 / 30

Memory Tracking 11 / 30

Memory Access Errors A dynamically allocated piece of memory can be accessed in several illegal ways. 1. Read before write: This is a read of uninitialized data and can lead to random results. Repeated runs of the program cause different results depending on which memory chunk is allocated. 2. Write before or after allocation: This happens when a process writes beyond borders, e.g. makes mistakes in array arithmetics. Or the memory has been given back to the system (via free) and the process still writes to it. Memory Tracking 12 / 30

Memory tracking techniques Two very powerful ones are the placement of control areas e.g. after arrays by writing a certain unique pattern after the end of the array. If the pattern is destroyed then we know that the process writes out of bounds. Memory coloring tracks the state of each memory chunk as "uninitialized, initialized or freed" and logs violations in the order of access. (Purify) Memory Tracking 13 / 30

Debugging Technology 14 / 30

How do breakpoints work? Debugging Technology 15 / 30

Control of the child process in systems with virtual Debugging Technology 16 / 30

Remote Debugging Debugging Technology 17 / 30

Linux Tools and Utilities for Monitoring 18 / 30

System Call Tracking STrace LTrace ldd Use STrace to track all activity between a user process and the kernel. No application change necessary. Good if you want to know about the major external functions that your program calls. The utility probably needs to find all kernel traps and route those to itself Same as STrace just for dynamic link libraries (shared libraries) All dynamic mechanisms have the problem that one has to know exactly WHICH library will be loaded, WHICH class loaded. This utility does it and there is one also for the Windows world but I forgot it, sorry. BTW: the unix shell also has a dynamic load mechanism and that is what the WHICH utility is for: it tells you which utility is loaded from which path. There might be duplicates in different places and the PATH variable will decide which one gets loaded. Linux Tools and Utilities for Monitoring 19 / 30

Method or function profiling GProf KProf Function Check GCov Use GProf to create call graph information for an application. Take the functions which use the most processing time and start optimizing those. The tool writes profiling output to a file. The application needs to be compiled with special profiling options. Nicer GUI for GProf output. Generates profiling information but needs an extra library. Also a profiler. Writes results right into source code of program. Linux Tools and Utilities for Monitoring 20 / 30

Monitoring Memory Valgrind Libmalloc Memprof Processor simulator which tracks all memory accesses by a process. Use -g -O0 to prevent optimization by the compiler. Instrumented versions of malloc/free exist which can be linked into a program as a replacement for the original versions. The debugging versions allow fine-grained tracking of memory allocation errors No program changes are necessary. This tool just tracks which function needs how much memory. It also tracks unused memory areas which have been allocated but are no longer reachable. Linux Tools and Utilities for Monitoring 21 / 30

System Monitoring 22 / 30

OProfile Collects profile data about all processes. Needs to load a kernel module dynamically. No program changes or recompilations are needed. Typical design with kernel part to collect data and postprocessing in user space. System Monitoring 23 / 30

Resource Tracking Utilities Try "PS" and "TOP" to see how many resources are allocated by your process. System Monitoring 24 / 30

Virtual Machines 25 / 30

Java Profiling 13. Debug Tracer -------------------------------------- Categories: Product, JPDA by Olivier Dedieu - rating: 1/5 Debug Tracer is an XML-based scripting tool for debugging, tracing, and monitoring the JavaTM Virtual Machine (JVM). It is useful for debugging problems quickly, almost "real-time," when a number of problems manifest themselves. The tool does not require any modification to code and can be used to monitor not only the... http://www.java-channel.org/display.jsp?id=c_16823 Virtual Machines 26 / 30

Eclipse plug-ins for memory and call-graph profiling Virtual Machines 27 / 30

Exercises 28 / 30

Java Based 1. Check the JVM command line arguments for monitoring memory or generating a profile. 2. Take a small Java program, create a profile and inspect it with the java profiler 3. Download an Eclipse profiling plug-in (sourceforge.com or eclipse.org) and generate a detailed call-graph and memory usage diagram. Which method takes most of the time? Which one uses the most memory? 4. Get your favorite Java debugger and try setting breakpoints. Can you find the calling hierarchy (stack)? How many threads do you have? Monitor the value of a variable in a for or while loop. Dump the values of local class members of a class. 5. Dump the bytecode of your java program using jprof. 6. Use a decompiler (DJ) to recreate the java code from your program. Exercises 29 / 30

Unix/Linux Process related Exercises 1. Exercises 30 / 30