Web hosting providers - Chapter 29 . Programming Tools and Utilities 809

January 11th, 2008

Chapter 29 . Programming Tools and Utilities 809 A core dump refers to an application failing and copying all data stored in memory for the application into a file named core in the current directory. That file can be used to help debug a problem with the application. If you don t see the core dumped message, try executing the shell command ulimit -c unlimited, which allows programs to drop a memory dump in their current working directory. The program has a bug, so you need to debug it. The first step is to start GDB, using the program name, debugme, and the core file, core, as arguments: $ gdb debugme core After GDB initializes, the screen should resemble Figure 29-1. Figure 29-1: GDB s startup screen As you can see near the middle of the figure, GDB displays the name of the executable that created the core file: ` + , . Obviously, the displayed name is wrong; it should be debugme. The odd characters and the incorrect program name would give an experienced developer an immediate clue that the program has a significant memory bug. The next line in the figure, the text that reads Program terminated with signal 11, Segmentation fault, explains why the program terminated. A segmentation fault occurs anytime a program attempts to access memory that doesn t explicitly belong to it. GDB also helpfully displays the function it was executing, index_to_the_moon. If you don t like the licensing messages (they annoy me), use the -q (or –quiet) option when you start GDB to suppress them. Another useful command-line option is -d dirname, where dirname is the name of a directory, which tells gdb where to find source code (it looks in the current working directory by default). Tip Note
Looking for affordable and reliable webhost to host and run your business application? Then look no more and go to servlet web hosting services.

808 Part VI . Programming in (Free web hosting with ftp) Linux Starting

January 10th, 2008

808 Part VI . Programming in Linux Starting GDB To start a debugging session, simply type gdb progname, replacing progname with the name of the program you want to debug. Using a core file is optional but will enhance GDB s debugging capabilities. Of course, you ll need a program on which to try out GDB debugging, so Listing 29-5 provides one: debugme.c. Listing 29-5: A Buggy Program /* * debugme.c - poorly written program to debug */ #include #define BIGNUM 5000 #define SZ 100 void index_to_the_moon(int ary[]); int main(int argc, char *argv[]) { int intary[100]; index_to_the_moon(intary); return 0; } void index_to_the_moon(int ary[]) { int i; for (i = 0; i < BIGNUM; ++i) ary[i] = i; } Compile this program using the command gcc -g debugme.c -o debugme. Then, execute the program using the command ./debugme. $ ./debugme Segmentation fault (core dumped) $ file core core: ELF 32-big LSB core file Intel 80386, version 1 (SYSV ), SVR4-style, SVR4-stylee, from debugme On most systems, when you execute ./debugme, it immediately causes a segmentation fault and dumps core, as shown in the output listing.
In case you need affordable webhost to host your website, our recommendation is ecommerce web host services.

Web server info - Chapter 29 . Programming Tools and Utilities 807

January 9th, 2008

Chapter 29 . Programming Tools and Utilities 807 The numeric values of the diff output indicate the lines in the first and second files to which an operation must be applied to get the second file from the first. The operation to perform, such as inserting, deleting, or changing lines, is specified by the alphabetic character. So, for example, the sequence 9,10c9,10 means to create the second file from the first you have to change (c) lines 9 and 10 of the first file to lines 9 and 10 of the second file. Finally, if you totally botch all of your changes to your working files and want to revert to the most recent versions, use the update command. It updates the specified directory with the most recent versions stored in the repository, as shown in the following example: $ cd ~/projects/newhello $ cvs update . cvs update: Updating . U showit.c U msg.c U hello.c There s much more to CVS than the few examples presented here. For additional information, visit the CVS home page on the Web at www.nongnu.org.org/cvs. Debugging with GNU Debugger Software is buggy, and some programs have more bugs than other programs. While debugging sessions will never be aggravation-free, GDB s advanced features lighten the load and enable you to be more productive in squashing bugs. Time and effort invested in learning GDB is well spent if you can track down and fix a serious bug in just a few minutes. GDB can make this happen. Most of what you will need to accomplish with GDB can be done with a surprisingly small set of commands. The rest of this chapter explores GDB features and shows you enough GDB commands to get you going. Effective debugging requires that your source code be compiled with the -g option to create a binary with an extended symbol table. For example, the following command $ gcc -g file1 file2 -o prog causes prog to be created with debugging symbols in its symbol table. If you want, you can use GCC s -ggdb option to generate still more (GDB-specific) debugging information. However, to work most effectively, this option requires that you have access to the source code for every library against which you link. While this can be very useful in certain situations, it can also be expensive in terms of disk space. In most cases, you can get by with the plain -g option.
Note: In case you are looking for affordable and reliable webhost to host and run your j2ee application check Vision J2ee Web Hosting services.

806 Part VI . Programming in Linux [editor

January 8th, 2008

806 Part VI . Programming in Linux [editor session] Checking in main.c; /space/cvs/newhello/main.c,v <-- main.c new revision: 1.2; previous revision: 1.1 done When you check in a modified file, CVS opens an editor session to enable you to enter a log message that describes the changes you made. The editor used is the editor defined in the $EDITOR environment variable or compiled-in default (usually vi text editor) if $EDITOR is undefined. This example did not use the -d option because the $CVSROOT environment variable is set. To check out a specific version, or revision, of a file, use the -r option following the checkout or co command, followed by a revision number. For example, to check out revision 1.1 of the main.c file, use the following command: $ cvs checkout -r 1.1 newhello/main.c U newhello/main.c To see the differences between two revisions, use the diff command, using the -r m.n, where m.n indicates the revision number you want to check. If you specify -r only once, the indicated version will be compared against the working file (using the diff option). If you specify -r twice, the two versions will be compared against each other. The following example compares revision 1.2 of showit.c to the current working revision (the revision currently in the working directory): $ cvs diff -r 1.2 main.c Index: main.c =================================================================== RCS file: /space/cvs/newhello/main.c,v retrieving revision 1.2 retrieving revision 1.3 diff -r1.2 -r1.3 9,10c9,10 < char msg_hi[] = { Hi there, programmer! }; < char msg_bye[] = { Goodbye, programmer! }; --- > char msg_hi[] = { Hi there, programmer!n }; > char msg_bye[] = { Goodbye, programmer!n }; 12c12 < printf( %sn , msg_hi); --- > printf( %s , msg_hi); The diff output is easier to understand than you might expect. Lines that begin with < appear in the first file (revision 1.2 of main.c) but not in the second (revision 1.3 of main.c. Similarly, lines beginning with > appear in the second file, but not in the first. Each section of diff output begins with an alphanumeric sequence such as 9,10c9,10 or 12c12.
We highly recommend you visit web and email hosting services if you need stable and cheap web hosting platform for your web applications.

Chapter 29 . Programming Tools and Utilities (Web hosting colocation) 805

January 7th, 2008

Chapter 29 . Programming Tools and Utilities 805 6. Do as the instructions recommend: Execute the command cvs commit to make the added files and directories permanent. You ll first see a screen (which is actually a vi editor session) asking you to enter a log message. If you don t want to enter a log message, press Esc, type ZZ to save and exit. After you close the vi session, the output you see should resemble the following: $ cvs commit cvs commit: Examining . RCS file: /space/cvs/newhello/hello.c,v done Checking in hello.c; /space/cvs/newhello/hello.c,v <-- hello.c initial revision: 1.1 done RCS file: /space/cvs/newhello/msg.c,v done Checking in msg.c; /space/cvs/newhello/msg.c,v <-- msg.c initial revision: 1.1 done RCS file: /space/cvs/newhello/showit.c,v done Checking in main.c; /space/cvs/newhello/main.c,v <-- main.c initial revision: 1.1 done Notice that CVS uses RCS file-naming conventions to work with files in the repository. This is because CVS was built on top of RCS and retains compatibility with the basic RCS feature set. CVS handles checking files in and out slightly differently than RCS. When checking a file out, it isn t necessary to specifically request a lock to get a writable copy of the file. To work on a file, you do need to use the checkout or co command: $ cd ~/projects $ cvs -d /space/cvs co newhello cvs checkout newhello U newhello/hello.c U newhello/msg.c U newhello/main.c The checkout command used in this example specifies the path to the repository using the -d option. This is unnecessary if you set the $CVSROOT environment variable. After you have made changes to files, you can check them in using the cvs commit command (commit is comparable to RCS s ci command): $ cd ~/project/newhello $ cvs commit . cvs commit: Examining .
If you are looking for cheap and quality webhost to host and run your website check Jboss Web Hosting services.

Kids web site - 804 Part VI . Programming in Linux The

January 6th, 2008

804 Part VI . Programming in Linux The Concurrent Versions System (CVS) supports both centralized repositories and network-based access. It is well-suited for use by multiple programmers, and a single CVS repository can support multiple projects. To keep the discussion simple, however, the example in this chapter deals only with a repository accessed locally. The following steps resemble the process described earlier for RCS, but they are slightly more involved and obviously use CVS concepts. 1. Create a CVS repository: $ mkdir /space/cvs $ export CVSROOT=/space/cvs $ cvs init The first command creates a directory named /space/cvs in which to establish the repository. The second command defines the environment variable $CVSROOT with this directory. Defining $CVSROOT makes using CVS much simpler. The third command initializes the repository, which creates some administrative directories CVS needs to work properly. 2. Create a top-level working directory in which to store your various projects and then cd into it: $ mkdir projects $ cd projects 3. Check out a copy of the CVS root directory into the directory you just created: $ cvs -d $CVSROOT co -l . cvs checkout: Updating . The -d option tells cvs the directory containing the CVS repository ($CVSROOT, or /space/cvs); co means check out (just as with RCS); the -l option, which stands for local, means to work only in the current directory rather than recursing through subdirectories; and the . specifies the current directory. 4. Create a directory to hold a project and add it to the repository: $ mkdir newhello $ cvs add newhello Directory /space/cvs/newhello added to the repository 5. cd into the new directory, copy your project files into it, and then add those files (and any directories that might be present) to the repository: $ cd newhello $ cp /projects/* . $ cvs add *c *h cvs add: scheduling file `hello.c for addition cvs add: scheduling file `msg.c for addition cvs add: scheduling file `showit.c for addition cvs add: use cvs commit to add these files permanently
Please visit Domain Name Hosting services for high quality webhost to host and run your jsp applications.

Web site - Chapter 29 . Programming Tools and Utilities 803

January 5th, 2008

Chapter 29 . Programming Tools and Utilities 803 RCS s command-line options are cumulative, as you might expect, and RCS does a good job of disallowing incompatible options. To check out and lock a specific revision of howdy.c, you would use a command such as co -l -r2.1 howdy.c. Similarly, ci -u -r3 howdy.c checks in howdy.c, assigns it revision number 3.1, and deposits a read-only revision 3.1 working file back into your current working directory. The following example creates revision 2.1 of howdy.c. Make sure you have checked out and changed howdy.c somehow before executing this command. $ ci -r2 howdy.c RCS/howdy.c,v <-- howdy.c new revision: 2.1; previous revision: 1.2 enter log message, terminated with single . or end of file: >> Added something >> . done This command is equivalent to ci -r2.1 howdy.c. The next example checks out revision 1.2 of howdy.c, disregarding the presence of higher-numbered revisions in the working directory. $ co -r1.2 howdy.c RCS/howdy.c,v –> howdy.c revision 1.2 done The handy command shown next discards all of the changes you ve made and lets you start over with a known good source file. $ co -l -f howdy.c RCS/howdy.c,v –> howdy.c revision 2.1 (locked) done When used with ci, -f forces RCS to check in a file even if it has not changed. Source Code Control with CVS You may have noticed that RCS has some shortcomings that make it inadequate for use on large projects. First, without some sophisticated wrapper scripts to provide the directory handling machinery, RCS doesn t work very well with a single, centralized repository. An RCS repository is always the current directory unless you exert yourself to use a directory located elsewhere. More pertinent for Linux and other open source projects, RCS is utterly unsuitable for distributed development because it doesn t support network protocols. (That is, it doesn t work over the Internet.)
Searching for affordable and reliable webhost to host and run your web applications? Go to our java web server services and you will be pleased.

802 Part VI . Programming in Linux With (Business web site)

January 4th, 2008

802 Part VI . Programming in Linux With the file safely checked into the repository, you can check it out and modify it. To check a file out for editing, use the co command. Here s an example: $ co -l howdy.c RCS/howdy.c,v –> howdy.c revision 1.1 (locked) done The working file you just checked out is editable. If you do not want to edit it, omit the -l option. Making Changes to Repository Files To see version control in action, make a change to the working file. If you haven t already done so, check out and lock the howdy.c file. Change anything you want, but I recommend adding n to the end of fprintf() s string argument because Linux (and UNIX), unlike DOS and Windows, do not automatically add a newline to the end of console output. Next, check the file back in and RCS will increment the revision number to 1.2, ask for a description of the change you made, incorporate the changes you made into the RCS file, and (annoyingly) delete the original. To prevent deletion of your working files during check-in operations, use the -l or -u option with ci. Here s an example: $ ci -l howdy.c RCS/howdy.c,v <-- howdy.c new revision: 1.2; previous revision: 1.1 enter log message, terminated with single . or end of file: >> Added newline >> . done When used with ci, both the -l and -u options cause an implied check-out of the file after the check-in procedure completes. -l locks the file so you can continue to edit it, while -u checks out an unlocked or read-only working file. Additional Command-Line Options In addition to -l and -u, ci and co accept two other very useful options: -r (for revision) and -f (force). Use -r to tell RCS which file revision you want to manipulate. RCS assumes you want to work with the most recent revision; -r overrides this default. The -f option forces RCS to overwrite the current working file. By default, RCS aborts a check-out operation if a working file of the same name already exists in your working directory. So if you really botch up your working file, use the -f option with co to get a fresh start.
We recommend high quality webhost to host and run your jsp application: christian web host services.

Christian web host - Chapter 29 . Programming Tools and Utilities 801

January 3rd, 2008

Chapter 29 . Programming Tools and Utilities 801 RCS manages multiple versions of files, usually but not necessarily source code files. It automates file version storage and retrieval, change logging, access control, release management, and revision identification and merging. As an added bonus, RCS minimizes disk space requirements because it tracks only file changes. One of RCS s attractions is its simplicity. With only a few commands, you can accomplish a great deal. Checking Files In and Out You can accomplish a lot with RCS using only two commands (ci and co) and a directory named RCS. ci stands for check in, which means storing a working file in the RCS directory; co means check out and refers to retrieving an RCS file from the RCS repository. To get started, you need to create an RCS directory. All RCS commands will use this directory, if it is present in your current working directory. The RCS directory is also called the repository. When you check a file in, RCS asks for a description of the file, copies it to the RCS directory, and deletes the original. Deletes the original? Ack! Don t worry, you can retrieve it with the check out command, co. Here s how to create an RCS directory: $ mkdir RCS Next, create the following source file naming it howdy.c) in the same directory in which you created the RCS directory. /* * $Id$ * howdy.c - Sample to demonstrate RCS Usage */ #include int main(void) { fprintf(stdout, Howdy, Linux programmer! ); return EXIT_SUCCESS; } Now, use the command ci howdy.c to check the file into the repository: $ ci howdy.c RCS/howdy.c,v <-- howdy.c enter description, terminated with single . or end of file: NOTE: This is NOT the log message! >> Simple program to illustrate RCS usage >> . initial revision: 1.1 done
Searching for affordable and proven webhost to host and run your servlet applications? Go to Linux Web Hosting services and you will find it.

800 Part VI . Programming in Linux Source

January 2nd, 2008

800 Part VI . Programming in Linux Source Code Control Version control is an automated process for keeping track of and managing changes made to source code files. Why bother? Because: . One day you will make that one fatal edit to a source file, delete its predecessor, and forget exactly which line or lines of code you fixed . Simultaneously keeping track of the current release, the next release, and eight bug fixes manually will become mind-numbing and confusing . Frantically searching for the backup tape because one of your colleagues overwrote a source file for the fifth time will drive you over the edge . One day, over your morning cappuccino, you will say to yourself, Version control, it s the Right Thing to Do. Source Code Control Using RCS The Revision Control System (RCS) is a common solution to the version control problem. RCS, which is maintained by the GNU project, is available on almost all UNIX systems, not just on Linux. Two alternatives to RCS are the Concurrent Version System (CVS), which also is maintained by the GNU project, and the Source Code Control System (SCCS), a proprietary product. Before you proceed, however, Table 29-5 lists a few terms that will be used throughout the chapter. Because they are so frequently used, I want to make sure you understand their meaning insofar as RCS and version control in general are concerned. Table 29-5 Version Control Terms Term Description Lock A working file retrieved for editing such that no one else can edit it simultaneously. A working file is locked by the first user against edits by other users. RCS file Any file located in an RCS directory, controlled by RCS, and accessed using RCS commands. An RCS file contains all versions of a particular file. Normally, an RCS file has a ,v extension. Revision A specific, numbered version of a source file. Revisions begin with 1.1 and increase incrementally, unless forced to use a specific revision number. Working One or more files retrieved from the RCS source code repository (the RCS file directory) into the current working directory and available for editing.
Searching for affordable and reliable webhost to host and run your web applications? Go to our java web server services and you will be pleased.