SKIP THE SHIPPING
Use code NOSHIP during checkout to save 40% on eligible eBooks, now through January 5. Shop now.
Register your product to gain access to bonus material or receive a coupon.
The Linux professionals' guide to effectively and efficiently diagnosing software problems and system crashes in the Linux environment.
° Learn to master use the most important problem determination tools that Linux has to offer
° Practical coverage of strace, the /proc filesystem, debugging options for use in compilation, and debugging with gdb
° In-depth coverage of kernel debugging techniques, from adding traps to using kdb
The biggest factor in a company's decision to go with Linux is overcoming thesupport issues. Adopting Linux successfully means taking on a differentapproach to support. Since Linux is open source, there are different methodsto get the support that companies need. This includes deeper skills on how toinvestigate problems, how to get help from the open source community (i.e.how to ask for help on usenet) and how to resolve problems in-house withoutthe extra cost of a consultant. This book should be an essential part of everycompany's Linux adoption plan to keep the total cost of ownership (TCO)down and improve the ROI of their Linux strategy. It is also a book thatadvanced Linux professionals running their own Linux systems will be able touse to troubleshoot. This book gives the staff the basics they need to diagnose most problems that they will face and will go into the nitty-gritty on the toughest problems. It also points users to the appropriate resources so that they may get help quickly.
Download the Source Code file for this book.
Best Practices and Initial Investigation Techniques for Diagnosing Linux Problems
Preface.
1. Best Practices and Initial Investigation.
2. strace and System Call Tracing Explained.
3. The /proc Filesystem.
4. Compiling.
5. The Stack.
6. The GNU Debugger (GDB).
7. Linux System Crashes and Hangs.
8.: Kernel Debugging with KDB.
9.: ELF: Executable and Linking Format.
Appendix A: The Toolbox.
Appendix B: Data Collection Script.
Index.
In the true spirit of Linux, there is a slightly different approach to support than the commercial norm. After all, Linux represents an unparalleled community of experts, it includes industry leading problem determination tools and of course, the product itself includes the source code. These resources are in addition to the professional Linux support services that are available from companies such as IBM and the various Linux vendors such as Redhat and SuSE. Making the most of these additional resources is called "self-service" and is the main topic covered by this book.
Self-service on Linux means different things to different people. For those who use Linux at home, it means a more enjoyable Linux experience. For those who use Linux at work, being able to quickly and effectively diagnose problems on Linux can increase their value as an employee as well as their marketability. For corporate leaders deciding whether to adopt Linux as part of the corporate strategy, self-service for Linux means reduced operation costs and increased Return On Investment (ROI) for any Linux adoption strategy. Regardless of what type of Linux user you are, it is important to make the most of your Linux experience and investment.
Chapter 1 is like a crash course on effective problem determination practices which will help you to diagnose problems like an expert. It covers where and how to look for information on the Internet as well as how to start investigating common types of problems.
Chapter 2 covers strace which is arguably the most frequently used problem determination tool on Linux. This chapter includes both practical usage information as well as details about how strace works. It also includes source code for a simple strace tool and details about how the underlying functionality works with the kernel through the ptrace interface.
Chapter 3 is about the /proc file system which contains a wealth of information about the hardware, kernel and processes that are running on the system. This purpose of this chapter is to point out and examine some of the more advanced features and tricks primarily related to problem determination and system diagnosis. For example, the chapter covers how to use the SysRq Kernel Magic hotkey with /proc/sys/kernel/sysrq.
Chapter 4 provides detailed information about compiling. Why does a book about debugging on Linux include a chapter about compiling? Well, the beginning of this preface mentioned that diagnosing problems on Linux is different than that of commercial environments. The main reason behind this is that the source code is freely available for all of the open sources tools and the operating system itself. This chapter provides vital information whether you need to recompile an open source application with debug information (as is often the case), whether you need to generate an assembly language listing for a tough problem (e.g., to find the line of code for a trap) or whether you run into a problem while recompiling the Linux kernel itself.
Chapter 5 covers intimate details about the stack, one of the most important and fundamental concepts of a computer system. Besides explaining all the gory details about the structure of a stack (which is pretty much required knowledge for any Linux expert), the chapter also includes and explains source code that can be used by the readers to generate stack traces from within their own tools and applications. The code examples are not only useful to illustrate how the stack works but they can save real time and debugging effort when included as part of an application's debugging facilities.
Chapter 6 takes an in-depth and detailed look at debugging applications with GDB and includes an overview of the DDD graphical user interface. Linux has an advantage over most other operating systems in that it includes a feature rich debugger, GDB, for free. Debuggers can be used to debug many types of problems and since GDB is free, it is well worth the effort to understand the basic and more advanced features. This chapter covers hard to find details about debugging C++ applications, threaded applications as well as numerous best practices. Have you ever spawned an xterm to attach to a process with gdb? This chapter will show you how any why!
Chapter 7 covers a detailed overview of system crashes and hangs. With proprietary operating systems a system crash or hang almost certainly requires you to call the OS vendor for help. However, with Linux the end user can debug a kernel problem on their own or at least identify key information to search for known problems. If you do need to get an expert involved, knowing what to collect will help you to get the right data quickly for a fast diagnosis. This chapter describes everything from how to attach a serial console to how to find the line of code for a kernel trap (an "Oops"). For example, the chapter provides step by step details for how to manually add a trap in the kernel and then debug it to find the resulting line of code.
Chapter 8 covers more details about debugging the kernel or debugging with the kernel debugger kdb. The chapter covers how to configure and enable kdb on your system as well as some practical commands that most Linux users can use without being a kernel expert. For example, this chapter will show you how to find out what a process is doing from within the kernel which can be particularly useful if the process is hung and not killable.
Chapter 9 is a detailed, head-on look at ELF (Executable and Linking Format). The details behind ELF are often ignored or just assumed to work. This is really unfortunate since a thorough understanding of ELF can lead to a whole new world of debugging techniques. The chapter covers intimate but practical details of the underlying ELF file format as well as tips and tricks that few people know. There is even sample code and step by step instructions for how to override functions using LD_PRELOAD and how to use the global offset table and the gdb debugger to intercept functions manually and redirect them to debug versions.
Appendix A is a tool box which outlines the most useful tools, facilities and files on Linux. For each tool, there is a description of when it is useful and where to get the latest copy.
Appendix B includes a production ready data collection script that is especially useful for mission critical systems or those who remotely support customers on Linux. The data collection script alone can save many hours or even days for debugging a remote problem.
Lastly, as we wrote this book it became clear to us that we were covering the right information. Reviewers often commented about how they were able to use the information immediately to solve real problems. Not the problems that may come in the future or may have happened in the past but real problems that people were actually struggling with when they reviewed the chapters. We also found ourselves referring to the content of the book to help solve problems as they came up. We hope you find it as useful as it has been to those who have read it thus far.
Readers that casually use Linux at home will also benefit as long as they either have a basic understanding of Linux or are at least willing to learn more about it, the latter being most important.
Lastly, as Linux increases in popularity, there are many seasoned experts who are facing the challenge of translating their knowledge and experience to the Linux platform. Many are already experts with one or more operating systems except that they lack specific knowledge about the various command line incantations or ways to interpret their knowledge for Linux. This book will help such experts to quickly adapt their existing skill set and apply it affectively on Linux.
This power packed book contains real industry experience on many topics and very hard to find information. Without a doubt, it is a must have for any developer, tester, support analyst or anyone that uses Linux.
First we would like to thank the reviewers for their time, patience and valuable feedback. Besides the typos, grammatical errors and technical omissions, in many cases the reviewers allowed us to see other vantage points which in turn helped to make the content more well-rounded and complete. In particular, we would like to thank Richard Moore for reviewing the technical content of many chapters, Robert Haskins for being so thorough with his reviews and comments, Mel Gorman for his valuable feedback on the ELF (Executable and Linking Format) chapter, Scott Dier for his many valuable comments, Jan Kritter for reviewing pretty much the entire book, Joyce Coleman, Ananth Narayan, Pascale Stephenson, Ben Elliston, Hien Nguyen, Jim Keniston as well as the IBM Linux Technology Center for their valuable feedback. We would also like to thank the excellent engineers from SuSE for helping to answer many deep technical questions, especially Andi Kleen, Frank Balzer, and Michael Matz.
We would especially like to thank our wives and family for the support, encouragement and giving us the time to work on this book. Without their support, this book would have never gotten past the casual conversation we had about possibly writing a book many months ago. We truly appreciate the sacrifices that they have made to allow us to finish this book.
Lastly, we would like to thank the open source community as a whole. The open source movement is a truly remarkable phenomenon that has and will continue to raise the bar for computing at home or for commercial environments. Our thanks to the open source community is not specifically for this book but rather for their tireless dedication and technical prowess that make Linux and all open source products a reality. It is our hope that the content in this book will encourage others to adopt, use or support open source products and of course Linux. Every little bit helps.
Thanks for reading this book.
The Open Source Community is much like a distributed development team with skills and experience spanning many different areas of computer science. The source code that is written by the Open Source Community is available for anyone and everyone to see. Not only can this make problem determination easier, having such a large and diverse group of people looking at the code can reduce the number of defects and improve the security of the source code. Open Source Software is open to innovations as much as criticism, both helping to improve the quality and functionality of the software.
One of the most common concerns about adopting Linux is service and support. However, Linux has the Open Source Community, a wide range of freely available problem determination tools, the source code and the Internet itself as a source of information including numerous sites and newsgroups dedicated to Linux. It is important for every Linux user to understand the resources and tools that are available to help them diagnose problems. That is the purpose of this book. It is not intended to be a replacement to a support contract nor does it require one. If you have one, this book is an enhancement that will be sure to help you make the most of your support contract.
Download the Index
file related to this title.