Lab 3-2: Exploring the Heap

Similar documents
Lab 3-3: Scenario - Fixing a Memory Leak

Section 0 1: Clone a BSP Create, Build, and Run a New OS Design

Lab 4-1: Replacing the Shell with a Custom Full Screen Browser Based UI

Introduction. Key features and lab exercises to familiarize new users to the Visual environment

NetBeans Tutorial. For Introduction to Java Programming By Y. Daniel Liang. This tutorial applies to NetBeans 6, 7, or a higher version.

Hands-on CUDA exercises

OS PORTING AND ABSTRACTION LAB USER MANUAL

Laboratory Assignment #4 Debugging in Eclipse CDT 1

Digi document reference number: _A

7 Cmicro Targeting. Tutorial. Chapter

What s New in Platform Builder 7

ECE 254/MTE241 Lab1 Tutorial Keil IDE and RL-RTX Last updated: 2012/09/25

Required Setup for 32-bit Applications

Migration from HEW to e 2 studio Development Tools > IDEs

Debugging Nios II Systems with the SignalTap II Logic Analyzer

Click on the Start Icon. Click on All Programs

Eclipse Tutorial. For Introduction to Java Programming By Y. Daniel Liang

embos Real-Time Operating System embos plug-in for IAR C-Spy Debugger Document: UM01025 Software Version: 3.1 Revision: 0 Date: May 3, 2018

Eclipse-Based CodeWarrior Debugger

embos Real-Time Operating System embos plug-in for IAR C-Spy Debugger Document: UM01025 Software Version: 3.0 Revision: 0 Date: September 18, 2017

This is a GENERAL Servant Keeper Network Installation help sheet. If you need further assistance, please contact your network administrator.

Exercise 3.1 EGL-CE 1.0 and Tomcat 6.0

Jackson State University Department of Computer Science CSC / Advanced Information Security Spring 2013 Lab Project # 5

IBM VisualAge for Java,Version3.5. Distributed Debugger for Workstations

IBM i Debugger. Overview Service Entry Points Debugger Functions Attach to an IBM i Job Launch Configurations and Settings

Lab Android Development Environment

BASICS OF THE RENESAS SYNERGY PLATFORM

Resource 2 Embedded computer and development environment

Getting Started with Visual Studio

Lab 1: Introduction to C Programming. (Creating a program using the Microsoft developer Studio, Compiling and Linking)

CUDA Development Using NVIDIA Nsight, Eclipse Edition. David Goodwin

6L00IA - Introduction to Synergy Software Package Short Version (SSP v1.2.0) Renesas Synergy Family - S7 Series

An Introduction to Komodo

Lab 3a: Scheduling Tasks with uvision and RTX

BASICS OF THE RENESAS SYNERGY TM

Lab 3b: Scheduling Multithreaded Applications with RTX & uvision

Implementing and Maintaining Microsoft SQL Server 2008 Integration Services

embos Real Time Operating System CPU & Compiler specifics for ARM core with ARM RealView Developer Suite 3.0 Document Rev. 1

Module Road Map. 7. Version Control with Subversion Introduction Terminology

BASICS OF THE RENESAS SYNERGY PLATFORM

IAR EWARM Quick Start for. Holtek s HT32 Series Microcontrollers

Implementing and Maintaining Microsoft SQL Server 2008 Integration Services

Integration for exdi2 on Windows CE Platform Builder

Micrium OS Kernel Labs

Disassemble the machine code present in any memory region. Single step through each assembly language instruction in the Nios II application.

ECE QNX Real-time Lab

Chapter 12 Visual Program Debugger

Tools Basics. Getting Started with Renesas Development Tools R8C/3LX Family

Hands-On Lab. Getting Started with Office 2010 Development. Lab version: Last updated: 2/23/2011

USB TO SERIAL CONVERTER

Introduction to Computation and Problem Solving

Note that FLIP is an Atmel program supplied by Crossware with Atmel s permission.

Embest IDE Pro for ARM 2005

EKK-LM3S811 QUICKSTART

COPYRIGHTED MATERIAL. Contents. Chapter 1: Windows Embedded CE 1. Chapter 2: Development Environment and Tools 15. Introduction

CPE 323: Laboratory Assignment #1 Getting Started with the MSP430 IAR Embedded Workbench

2 TUTORIAL. Overview. VisualDSP Getting Started Guide 2-1 for SHARC DSPs

Keil TM MDK-ARM Quick Start for. Holtek s HT32 Series Microcontrollers

JCreator. Starting JCreator

Laboratory 1 Semester 1 11/12

Mobile Programming Lecture 4. Debugging

CS354 gdb Tutorial Written by Chris Feilbach

Procedure to set up an HPIB 82350B card on an M57. M58 or C20x PC. Table 1: Parts required. Part Number Description Qty

ZCRMZNICE01ZEMG Crimzon In-Circuit Emulator

PathFinder-XD for MIPS Powered Devices. Simulator

Debugging in AVR32 Studio

Enterprise Architect. User Guide Series. Profiling

Enterprise Architect. User Guide Series. Profiling. Author: Sparx Systems. Date: 10/05/2018. Version: 1.0 CREATED WITH

System Debug. This material exempt per Department of Commerce license exception TSU Xilinx, Inc. All Rights Reserved

Windows NT Server Printer Driver Upgrade Instructions

Introduction to a NIC Wire App in P4

Hello World on the ATLYS Board. Building the Hardware

EE475 Lab #3 Fall Memory Placement and Interrupts

TREX Set-Up Guide: Creating a TREX Executable File for Windows

MEDIA COMPUTATION DRJAVA. Lecture 11.3 November 7, 2008

CodeWarrior Development Studio for Freescale 68HC12/HCS12/HCS12X/XGATE Microcontrollers Quick Start SYSTEM REQUIREMENTS Hardware Operating System 200

Supplement: Visual C++ Debugging

Intel Parallel Studio XE 2017 Composer Edition BETA C++ - Debug Solutions Release Notes

CSE 4342/ 5343 Lab 1: Introduction

CS 201 Software Development Methods Spring Tutorial #1. Eclipse

CSE 101 Introduction to Computers Development / Tutorial / Lab Environment Setup

3 TUTORIAL. In This Chapter. Figure 1-0. Table 1-0. Listing 1-0.

Computer Science II Lab 3 Testing and Debugging

Getting Started with STK200 Dragon

Debugging Applications with the JTAG In-Circuit Emulator

Creating and Simulate/Emulating an ASM Project in Atmel Introduction Procedure File New Project Assembler

IAR C-SPY Hardware Debugger Systems User Guide

How-to Build: Windows Embedded Compact 7 Network Projector Adapter

Client Configuration Guide

Visual Studio.NET. Although it is possible to program.net using only the command OVERVIEW OF VISUAL STUDIO.NET

The ThreadX C-SPY plugin

Code Composer Studio Development Tools v3.3. Getting Started Guide

Laboratory Exercise 3 Comparative Analysis of Hardware and Emulation Forms of Signed 32-Bit Multiplication

Developing Applications using Universal Driver 6.0x in Windows CE 6.0

Renesas PE-HMI1 Synergy S7 with Clarinox SPP Application

Code Composer Studio IDE Getting Started Guide. User's Guide

As CCS starts up, a splash screen similar to one shown below will appear.

Lab 0 Introduction to the MSP430F5529 Launchpad-based Lab Board and Code Composer Studio

Debugging a Platform Related Topics

Section 2: Getting Started with a FPU Demo Project using EK-LM4F232

Transcription:

Lab 3-2: Exploring the Heap Objectives Become familiar with the Windows Embedded CE 6.0 heap Prerequisites Completed Lab 2-1 Estimated time to complete this lab: 30 minutes Lab Setup To complete this lab, you must have: A development workstation running Windows XP Visual Studio 2005 (Version 8) with Platform Builder plug-in A running emulator image from Lab 2-1

2 Lab 3-2 Exploring the Heap Exercise 1 Create and build the HeapTest1 subproject The purpose of this exercise is to create, configure and build the subproject that we will use to examine the Windows Embedded CE 6.0 heap. Create HeapTest1 Subproject 1. Select Project Add New Subproject from the Visual Studio menu. 2. Enter the WCE Application subproject name: HeapTest1 as shown below. Note By default, new subprojects are located in the current OS design folder. 3. Click Next to continue the New Subproject Wizard. 4. Select A simple Windows Embedded CE application. 5. Click Finish to finish the wizard. The HeapTest1 subproject can be accessed in the Subprojects folder in Solution Explorer. Configure Subproject For Debug 6. From the Solution Explorer, right-click on the TrainingOSDesign project and select Properties. 7. Expand the Configuration Properties tree select Subproject Image Settings.

Lab 3-2 Exploring the Heap 3 8. Double click the HeapTest1 subproject to bring up the Edit Run Time Image Settings dialog. 9. Check the boxes Exclude from image and Always build and link as debug and click OK. Note Exclude from image will prevent the subproject from being included in the OS run-time image if it is built in the future. This is one way to allow the application to be run directly from the operating system build output folder (typically referred to as the flat release directory.) Always build and link as debug will make the kernel debugger experience better by disabling compiler optimizations in a release build for this application. 10. Click OK to close the TrainingOSDesign Property Pages dialog. Build the application subproject 11. Right click on the HeapTest1 subproject in the Solution Explorer and select Build. The application should build with zero errors and warnings. Note This is referred to as a Targeted build. We built a specific subproject in the Solution Explorer. Builds that are initiated from the Visual Studio Build menu will cause the entire solution or project to be built (sometimes referred to as a Global build). Global builds and Targeted builds can be separately configured with regard to whether they also cause the OS run-time image to be rebuilt. These settings are located in Build Global Build Settings and Build Targeted Build Settings from the Visual Studio menu. We previously configured the Targeted Build Settings to not also rebuild the OS run-time image. Set a breakpoint in the application 12. Expand the HeapTest1 subproject in the Solution Explorer. 13. Open the Source files branch and double-click on the HeapTest1.cpp file to open it in the Visual Studio editor. 14. Set a breakpoint in this source file by clicking on the return statement and pressing F9. We will know that we have built and run the application successfully when we hit this breakpoint.

4 Lab 3-2 Exploring the Heap Run the application on the target device 15. Select Target Run Programs from the Visual Studio menu to bring up Run Program dialog. 16. Select HeapTest1.exe, and click Run. 17. Observe that the kernel debugger halts execution at the previously set breakpoint. We have successfully created, built and run our application.

18. Leave the application at the breakpoint. Lab 3-2 Exploring the Heap 5

6 Lab 3-2 Exploring the Heap Exercise 2 Explore Process Model of Simple Application This exercise will use some of the debug capabilities of Platform Builder to explore some features of the HeapTest1 application. Examine HeapTest1 process details 1. Select Debug Windows Threads from the Visual Studio menu to bring up the Threads window. This window will allow you to see information for all the threads in a particular process, 2. Select heaptest1.exe from the Process drop down box. Note that heaptest1.exe has a single thread running at the default thread priority. 3. Expand the thread node to show the call stack. Note You can double click on any of the entries in the call stack to attempt to see the source code at that point. If you have installed the Shared Source you would be able to view the source code for all of these functions. Otherwise you will see the disassembly view. 4. Close the Threads and Call Stack windows. 5. Select Debug Windows Modules from the Visual Studio menu. The Modules window will appear. This view shows all modules running on the target device.

Lab 3-2 Exploring the Heap 7 6. Observe that the heaptest1.exe module has an Image Address starting at 0x00010000. This same starting address is used by all processes on the device. 7. Select heaptest1.exe from the Process drop down box. This shows just the module information related to the heaptest1.exe process. 8. Observe that the only module listed other than heaptest1.exe is coredll.dll. Coredll.dll is generally loaded by every process as it provides access to most system APIs. 9. Close the Modules window. 10. Press F5 to allow this application to continue running, and it will exit. Remove breakpoint 11. Click on the line containing the breakpoint in heaptest1.cpp 12. Press F9 to remove the breakpoint.

8 Lab 3-2 Exploring the Heap Exercise 3 Local Heap The purpose of this exercise is to explore the implementation of Local Heap memory in a simple Windows CE application. This application will allocate a number of blocks, free the blocks and allocate the blocks again. You will use Platform Builder tools to view the heap structures and to demonstrate the behavior of the heap management algorithm. Copy HeapTest1 code to HeapTest1.cpp 1. Open HeapTest1.cpp file from HeapTest1 subproject. 2. Open Lab 3-2 HeapTest code.txt file from the Student CD, and then copy the code snippet to HeapTest1.cpp as below. 3. Save HeapTest1.cpp. Build and run HeapTest1.exe 4. Right click on the HeapTest1 subproject in the Solution Explorer and select Build. 5. Run HeapTest1.exe using the Target Run Programs menu in Visual Studio. 6. Examine the debug output window in Visual Studio, which should be similar to the following:

Lab 3-2 Exploring the Heap 9 Three identically sized blocks were allocated from the local heap and then freed in the same sequence they were allocated. Three more identically sized blocks were then allocated again. Observe the addresses of each heap allocation in the debug output. Notice that the second group of allocations did not start at the same point as the first group even though those blocks had been freed and were available for use. Instead, the second set of allocations was given addresses starting with the address of the last item in the original group. The virtual address range that originally backed the first two memory allocations is now unused. This demonstrates one of the characteristics of Windows Embedded CE 6.0 heaps. New heap allocations are taken from the last allocated or freed item first; the heap manager does not start allocation attempts at the beginning of the heap. In this case, only block 3 was reused because it was the last one previously freed. The virtual memory would have been used more efficiently if the application had freed the memory in the reverse order that it had been allocated. Run Remote Heap Walker Viewer 7. From the Visual Studio Platform Builder menu, select Target Remote Tools Heap Walker. 8. Click OK to select the Default Device configuration. The Remote Heap Walker window will appear. 9. Double click on the line containing HeapTest1.exe in the process list. A second window containing the process heap information will appear.

10 Lab 3-2 Exploring the Heap 10. Double click on the heap entry at the address corresponding to block 4 in the debug window. This will be the first Fixed block after the first Free block.

Lab 3-2 Exploring the Heap 11 11. Observe the first byte is a 4 (0x34). This entry was written by the HeapTest1 application to identify its memory block. 12. Take some time and explore the source code to the application and what the tools can tell you about it. Step through the code and examine the various Platform builder tools as you go through. 13. Close the Remote Heap Walker window. Terminate the HeapTest1 application 14. Select Debug Windows Processes from the Visual Studio menu. 15. Right click on the heaptest1.exe process and select Terminate. 16. Click Yes to confirm. 17. Close the Processes window. If you are continuing with the next Hands-On Lab, keep your emulated image running.