Remote kernel debugging using serial communication in FreeBSD

Source: Internet
Author: User
Tags requires

Explore how to remotely debug the FreeBSD kernel that is running on the target computer without impacting system performance. This article discusses how to set up a debugging environment using serial communication ports, how to compile modified kernel code, how to debug, and introduce troubleshooting tips.

Introduction

FreeBSD is an advanced operating system derived from BSD, and BSD is a UNIX® version developed by the University of California, Berkeley. It delivers high performance, is more compatible with other systems, and requires less system management. FreeBSD contains kernel-level stateful (Stateful) IP firewalls and many other services, such as IP proxy gateways, access control lists, forced access control, jail based virtual hosts, and storage for encryption protection.

Occasionally, kernel crashes occur when you develop kernel code or when you run the development kernel. It is important to diagnose a core dump in order to extract useful information. If you try to debug this core dump using the same development computer, you may affect your system's performance. You can only debug one core dump at a time. To efficiently debug kernel dumps, it is best to establish a remote debugging session between the development computer and the target computer, and then remotely debug the kernel using serial communications.

The Kgdb utility is a GDB based debugger that allows you to debug kernel core files. The Kgdb utility is available in the FreeBSD 5.3 and later versions. If you have an earlier version of FreeBSD, you can still use Gdb-k to read the core dump file. Kgdb can help you place breakpoints in kernel code so that you can step through breakpoints to observe variables.

This article describes how to use serial communication ports to set up a debugging environment, how to compile modified kernel code, and how to start kernel debugging. Some troubleshooting tips are also described.

Setting up a debugging environment

To set up a remote debugging environment for FreeBSD kernel debugging, you need two computers: a target computer and a development computer. Run a new kernel image on the target computer that requires debugging. The development computer is used to debug the kernel running on the target computer. For better performance, you can use a well configured computer as your development computer.

0 Modem cable (Null modem cable)

A 0 modem (Null modem) is a means of communication using a RS-232 serial cable to connect two computers. The original RS-232 standard only defines how computers are connected using a modem. When using a 0 modem connection, the send and receive lines are crossed. Depending on the purpose of use, it is sometimes necessary to cross one or more handshake lines. There are several ways to connect, because the standard does not cover 0 modem connections.

If the 0 modem cable is connected to the serial port, the debugger can run at its current maximum rate (19200 bps), as compared to the rate at which the modem is used (9600 bps). This configuration is generally considered more reliable than using a modem because:

A 0 modem cable is a serial cable that allows data to be sent between two serial ports. Typically, the serial port is connected to a serial device. In this case, the target computer must be configured to accept the serial port connection to the serial port. It is important to use a 0 modem cable, and if you use a normal serial cable, the target computer expects to communicate with the serial device rather than with the other serial port so that you cannot debug the computer.

When you use a 0 modem cable to establish a direct serial connection between two computers, your cable must be connected in the way shown in Listing 1 below.

Listing 1. 25-Pin 0 Modem Cable   
2  3  Transmit Data
3  2  Receive Data
4  5  Request to Send
5  4  Clear to Send
6  20 Data Set Ready and Carrier Detect
7  7  Signal Ground
20 6  Data Terminal Ready

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.