daisy
daisy

Reputation: 23541

How to avoid "optimized out" when debug linux kernel

I'm debugging Linux kernel on Mac (VMWare Fusion), using two Linux Virtual Machines.

I've installed kernel-debuginfo-3.10.0-327.36.3.el7.x86_64 and the debugStub works.

enter image description here

Then I added a breakpoint on fchown syscall, it breaks,

Breakpoint 10, SYSC_fchown (group=0, user=0, fd=<optimized out>) at fs/open.c:650

But I can't read fd.file, the value is optimized out,

enter image description here

Any ideas?

Upvotes: 2

Views: 1629

Answers (1)

Employed Russian
Employed Russian

Reputation: 213754

But I can't read fd.file, the value is optimized out

This happens quite often when debugging optimized code.

Your best bet is probably to disassemble the routine. For a small routine like this one, usually it's not difficult to tell which register the value is in, and then you can cast to the right type. E.g. if the value is in $r9:

(gdb) p *(struct file *)$r9

Upvotes: 0

Related Questions