Archive for the 'Linux' Category

754 Appendixes Because the complete Fedora Core 3 (Web host)

Thursday, December 27th, 2007

754 Appendixes Because the complete Fedora Core 3 Linux distribution is included, you have access to a broad range of software packages (more than 1,600), allowing you to get a feel for using Linux as a desktop, server, or programmer s workstation. Details on installing and using Fedora Core 3 are contained in Chapter 8. If you find that you like Fedora Core 3, consider getting the Red Hat Fedora Linux 3 Bible to learn more about that distribution. While some of the material overlaps with this book s, you will get more complete coverage of installation and different kinds of servers that are available with Fedora Core 3. KNOPPIX Linux The KNOPPIX 3.6 LiveCD Linux distribution is configured to boot by default from the DVD that comes with this book. KNOPPIX is the most popular bootable Linux and offers some unique features to set it apart from other bootable Linux distribution (such as ways of saving configuration settings and using it as a persistent desktop Linux). Information on using KNOPPIX and configuring it in various ways is contained in Chapter 11. SUSE Linux The single SUSE 9.1 CD image included on the DVD contains a nice set of features that enable you to install a very usable SUSE desktop system. SUSE Linux is developed and supported by Novell, which offers SUSE as part of a wider range of Enterprise-ready Linux and NetWare software. To install SUSE from the ISO image included on the DVD, you must first burn that image to CD, as described later in this appendix. Then, follow the installation instructions in Chapter 10. Slackware 10 The DVD contains the first Slackware 10 CD. Slackware is the oldest surviving Linux system and continues to have a loyal following among Linux enthusiasts. The first CD contains a good mix of desktop and server software. (You can obtain the second CD from slackware.com if you want to install a full KDE or GNOME desktop for Slackware.) Later in this appendix, you ll find out how to burn the Slackware ISO images to CD from the DVD. Chapter 14 tells how to install Slackware on your computer from that CD. Chapter 3 describes how to configure a simple window manager for Slackware. Note
We highly recommend you visit web and email hosting services if you need stable and cheap web hosting platform for your web applications.

Simple web server - Media The DVD and CD that accompany the

Wednesday, December 26th, 2007

Media The DVD and CD that accompany the Linux Bible 2005 Edition contain ten different Linux distributions. Two of those distributions can be booted directly from the DVD and run live (KNOPPIX) or installed to your hard disk (Fedora Core 3). Two can be booted and run live from the CD (Damn Small Linux) or installed to your hard disk (Debian). The others can be burned to CD-ROM from one of those two media and installed separately. General information on installing or booting the various Linux distributions on the DVD is contained in Chapter 7. Specific instructions for using and installing each Linux distribution are contained in the other chapters in Part III (Chapters 8 to 18). The software contained on the CD and DVD is covered under the GNU Public License (GPL) or other licenses included on the medium for each software distribution. Use the software on this DVD (as you would any GPL software) at your own risk. Refer to README, RELEASE-NOTES, and any licensing files delivered with each distribution, and be sure that you agree with the terms they spell out before using the software. Finding Linux Distributions on the DVD The following sections describe the Linux distributions contained on the DVD. Fedora Core 3 and KNOPPIX are immediately bootable from the DVD. The other distributions are contained in ISO images in the distros directory on the DVD. Fedora Core 3 Linux The DVD includes the entire Fedora Core 3 distribution that normally comes on four installation CDs. This is the recommended Linux distribution for trying out most of the procedures in this book. You can install Fedora Core 3 directly from the DVD without having to create CDs from the DVD to install separately. Caution AAPAP E N D I X
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.

752 Part VI . Programming (Web hosting mysql) in Linux The

Tuesday, December 25th, 2007

752 Part VI . Programming in Linux The search and reverse-search commands are especially helpful in large source files that have dozens or hundreds of lines. One common use of the reverse-search command is to find the file and/or line in which a variable is first used or in which it is defined. The search command similarly enables you to locate with relative ease each location in which a program symbol (variable, macro, or function) is used, perhaps to find the use that changes a variable unexpectedly or the place where a function is called when it shouldn t be. Summary This chapter took you on a whirlwind tour of a few of the most common programs and utilities used by Linux programmers. You learned how to use GCC to compile programs, how to use make to automate compiling programs, and how to find information about programming libraries using programs like ldd, nm, and ldconfig. You also learned enough about the source code control systems RCS and CVS to be comfortable with the terminology and how to use their most basic features. Finally, you learned how to use the GNU debugger GDB to figure out why, or at least where, a program fails. . . .
We would like to recommend you tested and proved virtual web hosting services, which you will surely find to be of great quality.

Free web design - Chapter 28 . Programming Tools and Utilities 751

Monday, December 24th, 2007

Chapter 28 . Programming Tools and Utilities 751 (gdb) break linenum if expr (gdb) break funcname if expr expr can be any expression that evaluates to true (nonzero). For example, the following break command stops execution at line 24 of debugme when the variable i equals 15: (gdb) break 24 if i == 15 Breakpoint 1 at 0×80483cb: file debugme.c, line 24. (gdb) run Starting program: /home/kwall/code/debugme Breakpoint 1, index_to_the_moon (ary=0xbffff4b0) at debugme.c:24 24 ary[i] = i; Stopping when i equals 15 is an arbitrary choice to demonstrate conditional breaks. As you can see, gdb stopped on line 24. A quick print command confirms that it stopped when the value of i reached the requested value: (gdb) print i $1 = 15 To resume executing after hitting a breakpoint, type continue. If you have set many breakpoints and have lost track of what has been set and which ones have been triggered, you can use the info breakpoints command to refresh your memory. Working with Source Code Locating a specific variable or function in a multifile project is a breeze with GDB, provided you use the -d switch to tell it where to find additional source code files. This is a particularly helpful option when not all of your source code is located in your current working directory or in the program s compilation directory (which GCC recorded in its symbol table). To specify one or more additional directories, start GDB using one or more -d dirname options, as this example illustrates: $ gdb -d /source/project1 -d /oldsource/project1 -d /home/b ubba/src killerapp To locate the next occurrence of a particular string in the current file, use the search string command. Use reverse-search string to find the previous occurrence of string. If you want to find the previous occurrence of the word return in debugme.c (see Listing 28-5), for example, use the command reverse-search return. GDB obliges and displays the text: (gdb) reverse-search return 17 return ret;
Note: If you are looking for cheap and reliable webhost to host and run your mysql application check mysql web server services.

750 Part VI . Programming in Linux (gdb) (Sri lanka web server)

Sunday, December 23rd, 2007

750 Part VI . Programming in Linux (gdb) whatis i type = int (gdb) whatis ary type = int * (gdb) whatis index_to_the_moon type = void (int *) This feature may seem rather useless because, of course, you know the types of all the variables in your program (yeah, right!). But, you will change your mind the first time you have to debug someone else s code or have to fix a multifile project for which you haven t seen the source files for a couple of months. The whatis command can also help you track down bugs that result from assigning an inappropriate value to a variable. Setting Breakpoints As you debug problematic code, it is often useful to halt execution at some point. Perhaps you want to stop execution before the code enters a section that is known to have problems. In other cases, you can set breakpoint so you can look at the values of certain variables at a given point in the execution flow. In still other situations, you might find it useful to stop execution so you can step through the code one instruction at a time. GDB enables you to set breakpoints on several different kinds of code constructs, including line numbers and function names, and also enables you to set conditional breakpoints, where the code stops only if a certain condition is met. To set a breakpoint on a line number, use the following syntax: (gdb) break linenum To stop execution when the code enters a function, use: (gdb) break funcname In either case, GDB halts execution before executing the specified line number or entering the specified function. You can then use print to display variable values, for example, or use list to review the code that is about to be executed. If you have a multifile project and want to halt execution on a line of code or in a function that is not in the current source file, use the following forms: (gdb) break filename:linenum (gdb) break filename:funcname Conditional breakpoints are usually more useful. They enable you to temporarily halt program execution if or when a particular condition is met. The correct syntax for setting conditional breakpoints is:
If you are looking for affordable and reliable webhost to host and run your business application visit our ftp web hosting services.

Chapter 28 . Programming (Best web design) Tools and Utilities 749

Saturday, December 22nd, 2007

Chapter 28 . Programming Tools and Utilities 749 The expression $1 is an alias that refers to an entry in GDB s value history. GDB creates value history entries for each command you type that produces computed results. The alias numbers increment sequentially each time you execute a command that produces some sort of computed output. As a result, you can access these computed values using aliases rather than retyping the command. For example, the command $1-5 produces: (gdb) print $1-5 $2 = 719 Notice that the alias incremented to $2. If you later need to use the value 719, you can use the alias $2. The value history is reset each time you start GDB, and the values are not accessible outside GDB. You are not limited to using discrete values because gdb can display the addresses of data stored in an arbitrary region of memory. For example, to print the first 10 memory locations associated with ary, use the following command: (gdb) print ary@10 $3 = {0xbffffc90, 0×40015580, 0×400115800, 0×0, 0×1, 0×2, 0c3, 0×4, 0×5} The notation @10 means to print the 10 values that begin at ary. Say, on the other hand, that you want to print the five values stored in ary beginning with the first element. The command for this would be the following: (gdb) print ary[1]@5 $4 = {1, 2, 3, 4, 5} Why go to the trouble of printing variable or array values? Although it isn t necessary in this particular example because you know where the trouble occurs, it is often necessary to see the value of a variable at a particular point in a program s execution so you monitor what is happening to variables. In the case of arrays, a command that prints the values in an array, such as print ary[1]@5 in the preceding example, enables you to confirm at a glance the values are what you expect them to be. If the values don t match up with your expectations, though, that is a clue that some code is altering the array in a way you didn t intend. As a result, you can focus your bug hunting on a specific section of code. GDB also can tell you the types of variables using the whatis command. GDB s whatis command is comparable to the man -f command, which searches the whatis database of system commands for short descriptions of those system commands (the manual page whatis database is totally separate from the whatis command used by GDB).While man s whatis database works on system commands, GDB s whatis command describes the types of variables and other data structures used in a program.
Note: In case you are looking for affordable and reliable webhost to host and run your j2ee application check Vision J2ee Web Hosting services.

Web site template - 748 Part VI . Programming in Linux It

Friday, December 21st, 2007

748 Part VI . Programming in Linux It would be helpful, however, to have some idea of the context in which the offending line(s) of code exist. For this purpose, use the list command, which takes the general form, list [m,n], where m and n are the starting and ending line numbers you want displayed. For example: (gdb) list 10,32 would display code lines 10 through 32. A bare list command displays 10 lines of code that includes the line where the error was first detected, as illustrated here: (gdb) list 15 index_to_the_moon(intary); 16 17 exit(EXIT_SUCCESS); 18 } 19 20 void index_to_the_moon(int ary[]) 21 { 22 int i; 23 for (i = 0; i < BIGNUM; ++I { 24 ary[i] = i; Examining Data One of GDB s most useful features is its ability to display both the type and the value of almost any expression, variable, or array in the program being debugged. It can print the value of any expression legal in the language in which your program is written. The command is, predictably enough, print. Here are a couple of print commands and their results: (gdb) print i $1 = 724 (gdb) print ary[i] Cannot access memory at address 0xc0000000. This example continues the earlier examples of debugging debugme.c because you are still trying to identify where and why debug me crashed. Although in this example, the program crashed at the point when the counter variable i equaled 724 (the expression $1 refers to an entry in GDB s value history, explained in a moment), where it crashes on your system depends on the system s memory layout, the process s memory space (especially the kernel s stack space), the amount of available memory on your system, and other factors. The result of the second command (print ary[i]) makes it pretty clear that the program does not have access to the memory location specified, although it does have legal access to the preceding one.
From our experience, we are can tell you that you can find a reliable and cheap webhost service at Java Web Hosting services.

Chapter 28 . Programming Tools and Utilities 747 (Ftp web hosting)

Thursday, December 20th, 2007

Chapter 28 . Programming Tools and Utilities 747 This short output listing shows that the segmentation fault occurred in the function index_to_the_moon at line 24 of debugme.c. Notice the last line of the output; GDB displays the line of code, prefixed with the line number (24), where the segmentation fault occurred. It also shows the memory address (in hexadecimal format) at which the fault occurred, 0xbffff4b0. You can pass any arguments to the run command that your program would ordinarily accept. GDB also creates a full shell environment in which to run the program. Ordinarily, GDB uses the value of the environment variable $SHELL to create the simulated environment. If you want, however, you can use GDB s set and unset commands to set or unset arguments and environment variables before you use the run command to run the program in the debugger. To set command-line arguments to pass to the program, type set args arg1 arg2, where arg1 and arg2 (or any number of arguments) are options and arguments the program being debugged expects. Use set environment env1 env2 to set environment variables (again, env1 and env2 are placeholders for the environment variables you want to set or unset). Inspecting Code in the Debugger What is happening in the function index_to_the_moon that s causing the error? You can execute the backtrace (or bt or back) command to generate the function tree that led to the segmentation fault. The backtrace doesn t usually show you what the problem is, but it does show you more precisely where the problem occurred. Here s how the function trace for the example looks on my system: (gdb) backtrace #0 0×080483db index_to_the_moon (ary=0×7ffffc90) at debugme.c:24 #1 0×080483a6 in main (argc=104,argv=0×69) at debugme.c:15 A backtrace shows the chain of function calls that resulted in the error. The backtrace starts with the most recently called function index_to_the moon() in this case which resides at the hexadecimal memory address shown in the second column of the display (0×0800483db). index_to_the_moon() was called by the main() function. As you can see from the output, the most recently called function was index_to_the_moon(), so, somewhere in the function, the segmentation fault occurred. Incidentally, the backtrace also shows that index_to_the_moon() was called from line 15 of the main() function in debugme.c. It s not necessary to type complete command names while using GDB. Any sufficiently unique abbreviation works. For example, back suffices for backtrace. Tip
Go visit our java server pages services for a reliable, lowcost webhost to satisfy all your needs.

746 Part VI . Programming in Linux After (Free web hosting services)

Wednesday, December 19th, 2007

746 Part VI . Programming in Linux After GDB initializes, the screen should resemble the one shown in Figure 28-1. Figure 28-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, and the line it believes caused the fault (line 24). 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). After you load the program and its core dump into the debugger, run the program in the debugger. To do so, type the command run at the GDB command prompt, (gdb), as the following example shows: (gdb) run Starting program: /home/kwall/code/debugme Program received signal SIGSEGV, Segmentation fault. 0×0804483db in index_to_the_moon (ary=0xbffff4b0) at debugme.c:24 24 ary[i] = i; Tip
Visit our web design programs services for an affordable and reliable webhost to suit all your needs.

Chapter 28 . Programming Tools and Utilities 745 (Web site directory)

Wednesday, December 19th, 2007

Chapter 28 . Programming Tools and Utilities 745 Listing 28-5: A Buggy Program /* * debugme.c - poorly written program to debug */ #include #define BIGNUM 5000 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. 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
We recommend cheap and reliable webhost to host and run your web applications: Coldfusion Web Hosting services.