Getting Started: Developing Code with Cloud9

Slides:



Advertisements
Similar presentations
Introduction to Eclipse. Start Eclipse Click and then click Eclipse from the menu: Or open a shell and type eclipse after the prompt.
Advertisements

Chapter 3: Editing and Debugging SAS Programs. Some useful tips of using Program Editor Add line number: In the Command Box, type num, enter. Save SAS.
Utilizing the GDB debugger to analyze programs Background and application.
Lab6 – Debug Assembly Language Lab
Georgia Institute of Technology DrJava Appendix A Barb Ericson Georgia Institute of Technology May 2006.
Introducing the Command Line CMSC 121 Introduction to UNIX Much of the material in these slides was taken from Dan Hood’s CMSC 121 Lecture Notes.
Course Introduction and Getting Started with C 1 USF - COP C for Engineers Summer 2008.
Guide To UNIX Using Linux Third Edition
Introduction to Unix (CA263) Introduction to Shell Script Programming By Tariq Ibn Aziz.
1 Introduction to Programming Environment Using MetroWerks CodeWarrior and Palm Emulator.
1 Chapter One A First Program Using C#. 2 Objectives Learn about programming tasks Learn object-oriented programming concepts Learn about the C# programming.
A First Program Using C#
Introduction to Shell Script Programming
Compiling & Debugging Quick tutorial. What is gcc? Gcc is the GNU Project C compiler A command-line program Gcc takes C source files as input Outputs.
Old Chapter 10: Programming Tools A Developer’s Candy Store.
CPSC1301 Computer Science 1 Overview of Dr. Java.
Active-HDL Interfaces Debugging C Code Course 10.
Getting Started with MATLAB 1. Fundamentals of MATLAB 2. Different Windows of MATLAB 1.
9/2/ CS171 -Math & Computer Science Department at Emory University.
Fall 08, Oct 31ELEC Lecture 8 (Updated) 1 Lecture 8: Design, Simulation Synthesis and Test Tools ELEC 2200: Digital Logic Circuits Nitin Yogi
A Tutorial on Introduction to gdb By Sasanka Madiraju Graduate Assistant Center for Computation and Technology.
1 SEEM3460 Tutorial Compiling and Debugging C programs.
Data Display Debugger (DDD)
CPS120: Introduction to Computer Science Compiling a C++ Program From The Command Line.
Debugging tools in Flash CIS 126. Debugging Flash provides several tools for testing ActionScript in your SWF files. –The Debugger, lets you find errors.
Lab 9 Department of Computer Science and Information Engineering National Taiwan University Lab9 - Debugging I 2014/11/4/ 28 1.
Debugging Lab Antonio Gómez-Iglesias Texas Advanced Computing Center.
Some of the utilities associated with the development of programs. These program development tools allow users to write and construct programs that the.
1 Using an Integrated Development Environment. Integrated Development Environments An Integrated Development Environment, or IDE, permits you to edit,
Linux CSE 1222 CSE1222: Lecture 1BThe Ohio State University1.
Bash Scripting CIRC Summer School 2016 Baowei Liu CIRC Summer School 2016 Baowei Liu.
LINGO TUTORIAL.
VLSI Synthesis and Simulation Tools Nitin Yogi 01/09/2009
First Day in Lab Making a C++ program
Appendix A Barb Ericson Georgia Institute of Technology May 2006
Development Environment
CS1010: Intro Workshop.
Development Environment Basics
CIRC Winter Boot Camp 2017 Baowei Liu
ATS Application Programming: Java Programming
Appendix A Barb Ericson Georgia Institute of Technology May 2006
Eclipse Navigation & Usage.
Software Tools Recitation 1
Introduction to Programming the WWW I
Lab: ssh, scp, gdb, valgrind
Intro to UNIX System and Homework 1
Instructor: Prasun Dewan (FB 150,
CIS 470 Mobile App Development
Unreal Engine and C++ We’re finally at a point where we can start working in C++ with Unreal Engine To get everything set up for this properly, we’re going.
Getting Started: Amazon AWS Account Creation
GNU DEBUGGER TOOL. What is the GDB ? GNU Debugger It Works for several languages – including C/C++ [Assembly, Fortran,Go,Objective-C,Pascal]
CSC235 - Visual Studio Tutorial
The National Reference Metadata Editor (NRME)
Stata Basic Course Lab 2.
CIS 470 Mobile App Development
Lab 4: Introduction to Scripting
Video Notes.
Running a Java Program using Blue Jay.
The Role of Command Line Compiler (csc.exe)
CSCE 206 Lab Structured Programming in C
Review of Previous Lesson
Debugging.
Makefiles, GDB, Valgrind
The National Reference Metadata Editor (NRME)
Workshop for Programming And Systems Management Teachers
Selenium IDE Installation and Use.
CIS 694/EEC 693 Android Sensor Programming
ECE 3567 Microcontrollers Lab
Presentation transcript:

Getting Started: Developing Code with Cloud9 Creating code Navigate directories Navigate source code Write code Format code Compiler options Optimization flags Debug flags Debugging simple code Step through code Set breakpoints Examine variables Examine memory Debugging a complex program Multiple functions Multiple files Multiple directories Libraries Make files CLI arguments

Part 1: Starting a Cloud9 Session To open a new session in the Cloud 9 environment: Go to this URL: https://us-east-2.console.aws.amazon.com/cloud9/home Enter in your login credential. Select “ECE_1111” (if you only have one environment installed, this will be done automatically. The circle should have a white dot in it. Select the “Open IDE” button to open up the environment. To ssh to the VM we are using for the course, execute this command from your terminal tool: ssh picone@52.203.1.33 If you have set up your ssh keys properly, you should be logged in without typing your password and should see the screen to the right. For this tutorial, you need to be running the Cloud9 IDE.

Part 1: Copy Sample Code to Your Account The sample source code that we will use in this example is located here: /data/courses/ece_1111/current/lectures/lectures_01 From your home directory, run the following commands: cd cp -r /data/courses/ece_1111/current/lectures/lectures_01 ece_1111/ A more interesting and useful way to do this is to use the rsync command: Copy the labs to your directory using the following command: rsync –auxv /data/courses/ece_1111/current/labs ece_1111/ This command will copy only the files that you have not previously copied or any files that have been updated since your last copy. For example, if you repeat this command a second time, nothing will be copied since there are no new or missing files to be copied. We will use rsync repeatedly during the semester to copy files and data. You can also use this command to back up your computer.

Part 1: Load Sample Code into the IDE On the left hand side of the IDE, you will see your directory tree. The directories and files that you see here reside in your home directory ($HOME/ece_1111). To see your hidden files and directories, select the gear symbol: Select “Show Hidden Files” Load the file named “myprog.cc” from the directory named “lecture_01” into a window: Select lecture_01 ➔ myprog.cc You can now browse, edit and run this program from your browser. The program you have loaded is a simple program that prints “hello world” to the screen. Type “ls –l” and “pwd” in the command window.

Part 1: Edit Code The IDE includes Emacs keybindings Open a new line at line 32 and type this line: float x = 27.0; Then type these two lines after the second print statement: fprintf(stdout, “my name is Jane Doe\n”); fprintf(stdout, “x = %f\n”, x); The editor will automatically space/format your code and gives you options to autocomplete your function. These features are part of the reason programmers use IDEs. Select “File” ➔ “Save as” ➔ Type in “myprog_new.cc” for “Filename” Then right click on “myprog.cc” and select “Delete”. If you keep this file, the IDE will throw an error due to the way the compiler is configured.

Part 1: Compile and Run Code Run the program in “no-debug” mode by selecting: Run ➔ Run with ➔ Ece_cpp This will create an executable (exe) file and an object file. To execute, right click on the .exe file and select run. The “no-debug” mode compiles the source files only and runs the program. You cannot stop the program before it crashes and examine its status or restart the program from specific locations. Run the code in debug mode: Click on the bug icon. Select “Run”. This will create a .gdb file and run the program in the debugger.

Part 2: Load, Compile and Run l01_01 To compile the first lab example, l01_01, into an executable file with no debugging information but with optimization from the command line: cd ~/ece_1111/labs/01/l01_01 g++ -O2 myprog.cc –o myprog.exe To compile this example into a .gdb file with debugging enabled and optimization from the command line: g++ -g –O2 myprog.cc –o myprog.gdb To run these programs: ./myprog.exe ./myprog.gdb In the following slides we will explain the compiler options and some of the behind the scenes logistics.

Part 2: Check Your g++ Version To check the location of the compiler you are using, type: which gcc The which command can be used to locate any Unix command. To check the g++ version: simply run this command on a terminal in cloud9: g++ --version The gcc compiler that is currently in use on nedc_999 is 8.1.0. Compiler versions change constantly and often cause compatibility problems. Compilers are machine-dependent because machines have different microarchitectures, and hence they require a different version of the compiler to create binaries that run as fast and efficiently as possible.

Part 2: Compilation, Optimization and Debug Flags Compilation flags are options that use to see debugging warnings, to spot lethal typos, speed up the program, etc. -o [filename]: specify the output file name -s: to produce assembly code -c: to produce only the compiled code, no linking -l: to link with shared libraries type “man gcc” to learn more about the compiler Optimization flags are options that tells the compiler how much you would like it to perform some special hardware instruction or architectural manipulation to make your code run faster and increase performance: -O0 : fast compilation with no optimization -O1: limited optimization that does not increase code size -O2: moderate optimization, recommended -O3: strong optimization, longer compiling time Debug options allow you to do source level debugging on the code: -g: compile the code debug

Part 2: Runner Files These runner files are located in the directory ~/ece_1111/.c9/runners (“~” denotes your home directory.) You can view the directory tree on the left hand side of the IDE to see the runner files. Double click on one to see the contents. Runner files are configuration files that are executed whenever you hit the green Run button in the Cloud9 IDE environment. They obey a simple bash-like scripting language that allows you to program the behavior of your IDE. To see the contents of a runner file from the command line, run these commands: cd ~/ece_1111/.c9/runners ls –l (to see the files) more <filename> You should see a file like the one shown to the right. Note that in this course we emphasize documenting all of your code with detailed comments.

Part 3: Compiling and Running a Simple Program To open up the second lab example, l01_02 source file: Navigate into the l01_02 directory Execute the runner file Ece_cpp Click on the myprog.exe file and select “Run” You should observe this output:

Part 3: Debugging a Simple Program To create an executable called myprog.gdb in debug mode: Select the bug icon ➔ Select Run Breakpoints are simply ways to notify the computer to stop running the program at a particular line of code. To add a breakpoint at line 21 in my_functs00.cc source file: Select myfuncts_00.cc ➔ Click to the left of the line number 21 and a red circle will pop up, indicating that a breakpoint has been set at that line. Right click on the myprog.gdb file and select “Run”. You will see that the breakpoint will stop the program at line 21. To run the rest of program, select the Play button.

Part 3: What Is a Make File? Make files are a way to program a recipe describing how to compile and link a program efficiently. Open the third example, l01_03, by navigating your directory tree. Select the file named “Makefile”. The IDE will display the make file. For the moment, don’t worry about what code is in this file. It has all the necessary code to compile, link and debug your program. This code supports commands like: “make”: compiles and links your program in “no-debug” mode. “make debug”: compiles and links your program in debug mode. “make clean”: deletes the previously compiled code so you can recompile.

Part 3: Program Execution with a Make File To build an executable called myprog.exe, select “run”. After running the make file, you should see the following output in the lower window. The output shows that all of the source code (*.cc files) was compiled, and then these object files were linked to create an executable. You can run the executable that was created, which is called “myprog.exe”, by right clicking on it and selecting “Run”. The program output will appear in the lower window.

Part 3: Debugging l01_03 code To build an executable called myprog.gdb from multiple source files in debug mode: Simply type “debug” after the path name and select “Run” The program will run to completion because no breakpoints were set. To add a breakpoint at line 21 in my_functs00.cc source file: Select myfuncts_00.cc ➔ click to the left of the line number 21 and a red circle will pop up, indicating that a breakpoint has been set at that line. Right click on the myprog.gdb file and select “Run”. You will see that the breakpoint will stop the program at line 21.

Part 4: Compiling a Library in a Complex Program To open up the fourth lab’s Makefile that is for building a library: Navigate into the l01_04 directory and then the src directory. Navigate to the functs directory. Click on the Makefile to load it. Select Run to compile the source code into object files. Type “install” after the file path and select Run to create a static library. You should see this output. The library is now located in the lib directory.

Part 4: Compiling and Running a Complex Program To open up the fourth lab’s Makefile that is for compiling an executable: Navigate into the l01_04 directory and then the src directory. Navigate to the main directory. Click on the Makefile to load it. Select Run to compile the source code. Type “install” after the file path and select Run to create an executable called myprog.exe. You should see this out put. This executable will now exist in the bin directory.

Part 4: Compiling a Library in Debug in a Complex Program To open up the fourth lab’s Makefile that is for compiling a library: Navigate into the l01_04 directory and then the src directory. Navigate to the functs directory. Click on the Makefile to load it. Select Run to compile the source code. Type “debug” after the file path and select Run to compile object files in debug mode. You should see this out put. Type “install” after the file path and select Run to install a new library in debug mode. You should see this out put.

Part 4: Compiling a Binary in Debug in a Complex Program To open up the fourth lab’s Makefile that is for compiling an executable/binary: Navigate into the l01_04 directory and then the src directory. Navigate to the main directory. Click on the Makefile to load it. Select Run to compile the source code. Type “debug” after the file path and select Run to compile object files in debug mode. You should see this out put. Type “install” after the file path and select Run to install a new executable in debug mode. You should see this out put. An new executable with debugging information called myprog.gdb now exists in the bin directory.

Part 4: Debugging a Complex Program To add a breakpoint at line 21 in my_functs00.cc source file: Select myfuncts_00.cc ➔ Click to the left of the line number 21 and a red circle will pop up, indicating that a breakpoint has been set at that line. Follow the above instruction to set a breakpoint at line 35 in myfuncts_01.cc source file. Right click on the myprog.gdb file and select “Run”. You will see that the breakpoint will stop the program at line 21 in myfuncts_00.cc. To run the rest of program, select the Play button. You will see that the breakpoint will stop the program at line 35 in myfuncts_01.cc

Part 4: Examine Variable Values in a Complex Program You can observe a local or multiple local variables’ values and type in the debugging window. After the breakpoint at line 21 in myfuncts_00.cc source file is invoked, you can observe the value of variable called value_a, which is 27. This variable only exists within the function called set_value_long. If you continue the program to the next breakpoint at line 35 in myfuncts_01.cc, you can observe the value of variables called value1_a and value2_a. These variables only exist within the function called set_value_long.

Part 4: Command line arguments To run a program that reads in and prints out the content of a file: Navigate into the /data/courses/ece_1111/current/labs/03 directory and then copy myprog.cc to your ece_1111 directory. If you have your own code, that is fine since this is just an example. Open up myprog.cc Execute the runner file Ece_cpp (refer to slide 10 if you do not know how to do this) Run myprog.exe by right clicking and select Run. You should see this output. It means that it needs to have a filename as a command line argument. Type in the filename and select the Run button again. You should see the content of the file that you pass as a command line argument in.