VMWARE+FEDORA+KGDB Environment Construction and commissioning

Source: Internet
Author: User
Tags install perl

First, prepare the environment

1. Download Fedora, version Fedora-live-desktop-x86_64-20-1.iso

2. Install VMware10.0.0 build-1295980

3. VMware virtual two Fedora, the first one named fedora-client-host:

Step 1:

Step2:

Step3:

STEP4:

STEP5:

STEP6:

STEP7:

Step 8:

4. After Fedora is installed, install the necessary software:

[[email protected] xxxxx]# Yum install gcc

[[email protected] xxxxx]# Yum Install Perl

[email protected] xxxxx]# Yum install Ncurses-devel

5. Now the kernel is not open kgdb debugging, so need to recompile the kernel. The Fedora-live-desktop-x86_64-20-1kernel version is 3.11.10-301.fc20.x86_64 from the website https://www.kernel.org/ Download the source code linux-3.12.1 version, unzip and copy the extracted content to the/usr/work/directory, note the root account, because kernel compilation is to root permissions.

6. Enter the source directory linux-3.12.1, execute make menuconfig to kgdb kernel option configuration ( These options are default and do not need to be modified ).

(1) Config_debug_info = y This option allows the compiled kernel to contain debugging information that makes debugging easier.

Location:---->kernel hacking
---->compile-time checks and compiler options
---->compile the kernel with debug info
(2) Config_frame_pointer = y This option causes the kernel to use the frame pointer register to maintain the stack, so that stack backtracking can be performed correctly, that is, function call stack information.
Location:---->kernel hacking
---->compile-time checks and compiler options
---->compile the kernel with frame pointers
(3) Config_magic_sysrq = y (If you selected Kgdb_serial_console, this option will be selected automatically) activates the "Magic SysRq" key. This option is useful for KGDBOC debugging, where Kgdb is registered with the ' G ' magic key to activate Kgdb.
Location:---->kernel hacking
---->magic SYSRQ Key
Options to turn off

(4) Config_debug_rodata = n This option sets some of the kernel's memory area space to read-only, which may result in the KGDB setting of the soft breakpoint function invalid. So it is recommended to turn this option off.
Location:---->kernel hacking
---->write protect kernel READ-ONLY data structures
(5) Config_debug_set_module_ronx =n, this option sets the kernel module space to read-only, which causes the breakpoint function to fail when the kernel module is debugged, the following error when setting a breakpoint, (a kernel that has been lost and recompiled while debugging the kernel module), so it is turned off.
Cannot insert Breakpoint 1.
Error Accessing memory address 0xf90f6000:unknown error-1.
Location:---->kernel hacking
---->set loadable kernel module data as NX and test as RO.
The option that must be enabled
(5) Config_kgdb = y
Location:---->kernel hacking
---->kgdb:kernel Debugger
(6) Config_kgdb_serial_console = y enables KGDB to communicate using a serial port.
Location:---->kernel hacking
---->kgdb:kernel Debugger
---->kgdb:use KGDB over the serial console
(7) Remaining:
In the kernel Hacking-->kgdb:kernel debugger directory, the options except kgdb:internal test suite all enable Y.

7. Compile the kernel to perform make and shut down after completion.

8. Create a second virtual machine, named Fedora-server-target, from the previous clone as shown below

9. After cloning is complete, open "Edit Virtual machine settings" and change the serial port configuration as follows:

  

10. Test serial communication, now VMware has two virtual machines, Fedora-server-target and Fedora-client-host, now the two virtual machines to start up.

Executing cat/dev/ttys1 on the fedora-server-target side "is ttyS1 because the pipeline is Com_1"

Performing echo qwerrttt >/dev/ttys1 on the Fedora-client-host side "is ttyS1 because the pipeline is Com_1"

Switch to the Fedora-server-target side, see if you can see QWERRTTT, see the serial connection is not a problem.

11. Install the kernel module in Fedora-server-target and the Make Modules_install module is installed in the/lib/modules/3.12.1 directory.

12. Install the kernel binary image file in Fedora-server-target and perform the Make install:

(1) During this process, the config-3.12.1 file is generated in the/boot directory, the root file system initrd.img-3.12.1 file is generated automatically, the kernel image file is vmlinuz-3.12.1 file, and the symbol table system.map-3.12.1 file.

(2) and automatically modifies the Grub.cfg file to automatically add the boot options of the 3.12.1 kernel to the file.

(3) Note that the original boot directory of the old kernel files should not be deleted, in case the new kernel can not boot.

13. Restart fedora-server-target and use the uname-a command to view the kernel version. And again test the serial communication, the test passed after modifying/boot/grub2/grub.cfg in the new kernel first add kgdbwait kgdboc=1 "serial number or ttyS1", 115200 "baud rate" and remove the quiet " Displays some information, such as the baud rate setting command: Stty ispeed 115200 ospeed 115200-f/dev/ttys1

(1) Kgdboc=0,9600:kgdb over console, where the KGDB connected console is set to ttyS0 with a baud rate of 9600 if the parameter is not configured in the kernel boot key

(2) kgdbwait: Allow kernel to wait for GDB to connect during startup.

(3) Then restart target, the system will be paused at kgdbwait, waiting for the host side of the GDB connection.

14.fedora-client-host End

(1) Enter the/usr/work/linux-3.12.1 directory

(2) GdB vmlinux//loading uncompressed kernel image

(3) Set Remotebaud 9600//Set serial port rate

(4) Target REMOTE/DEV/TTYS1//connection serial 1

"Note" To determine that two machines must be able to communicate at the baud rate set

VMWARE+FEDORA+KGDB Environment Construction and commissioning

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.