Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Makefile] Add unoptimized build targets #204

Open
wants to merge 1 commit into
base: riscv
Choose a base branch
from

Commits on Sep 27, 2023

  1. [Makefile] Add unoptimized build targets

    Problem:
    When debugging xv6, many variables could not be examined and would
    return the message "optimized out". For example, in the `readi` function
    of `kernel/fs.c` the variable `m` is optimized out at various points of
    the debugging process:
    
        Breakpoint 1, readi (ip=.., user_dst=.., dst=.., off=.., n=..) at kernel/fs.c:477
        477       if(off > ip->size || off + n < off)
        (gdb) n
        479       if(off + n > ip->size)
        (gdb) n
        482       for(tot=0; tot<n; tot+=m, off+=m, dst+=m){
        (gdb) p m
        $1 = <optimized out>
        (gdb)
    
    Issue:
    Both the `qemu` and `qemu-gdb` targets in the Makefile build the kernel
    using the `-O` general optimization option for gcc. This is appropriate
    for a non-debug run of xv6, but causes problems viewing the content of
    variables that have been optimized out.
    
    Solution:
    Two new build targets are added to the Makefile:
    
    * qemu-noopt - Builds the xv6 kernel with optimization turned off
    * qemu-gdb-noopt - Builds the xv6 kernel with optimization turned off
      and starts qemu as a gdb server.
    
    This preserves the functionality of the original build targets while
    allowing the build of non-optimized kernels for debugging purposes.
    jjolly committed Sep 27, 2023
    Configuration menu
    Copy the full SHA
    aabd9ca View commit details
    Browse the repository at this point in the history