Skip to content

[debug] local variable is <optimized out> #5

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

Open
OccupyMars2025 opened this issue Jun 5, 2023 · 1 comment
Open

[debug] local variable is <optimized out> #5

OccupyMars2025 opened this issue Jun 5, 2023 · 1 comment

Comments

@OccupyMars2025
Copy link
Owner

OccupyMars2025 commented Jun 5, 2023

image

rust-lang/rust#46698

rust-lang/rust#53036

rust-lang/rust#70542

@OccupyMars2025
Copy link
Owner Author

OccupyMars2025 commented Jun 5, 2023

image

rustc --help | less
    -g                  Equivalent to -C debuginfo=2
    -O                  Equivalent to -C opt-level=2

I use dev cargo profile, but the local variable is still optimized out

[profile.dev]
opt-level = 0
debug = true
// os/src/trap/context.rs
    pub fn app_init_context(entry: usize, sp: usize) -> Self {
        let mut sstatus_reg = sstatus::read(); // CSR sstatus
        sstatus_reg.set_spp(SPP::User); //previous privilege mode: user mode
        let mut cx = Self {
            x: [0; 32],
            sstatus: sstatus_reg,
            sepc: entry, // entry point of app
        };
        cx.set_sp(sp); // app's user stack pointer
        cx // return initial Trap Context of app
    }

@OccupyMars2025 OccupyMars2025 changed the title [debug] How NOT to optimize when compiling [debug] local variable is optimized out Jun 5, 2023
@OccupyMars2025 OccupyMars2025 changed the title [debug] local variable is optimized out [debug] local variable is <optimized out> Jun 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant