Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <blockquote> <p>gdb says that all of <code>strncpy</code>'s parameters (dest, src, and nbytes) have been "optimized out", which makes me think it's using uninitialized memory for that call. Am I interpreting this correctly?</p> </blockquote> <p>No. This just means that the optimizer has removed some of the function prologue boilerplate that would allow the debugger to reliably print the arguments to the function. This is very common with simple functions at any reasonable level of optimization.</p> <p>Here's a simple example:</p> <pre><code>int mystrcpy(char *p, const char *q) { while (*p++ = *q++); } </code></pre> <p>compiled with <code>-g -O0</code> you see it spill its arguments to the stack immediately:</p> <pre><code>mystrcpy: .LFB0: .file 1 "t.c" .loc 1 5 0 .cfi_startproc pushq %rbp .cfi_def_cfa_offset 16 movq %rsp, %rbp .cfi_offset 6, -16 .cfi_def_cfa_register 6 movq %rdi, -8(%rbp) &lt;&lt;&lt; here movq %rsi, -16(%rbp) &lt;&lt;&lt; and here ... </code></pre> <p>Then the compiler generated debug info about that:</p> <pre><code> .section .debug_info ... .uleb128 0x7 .string "p" &lt;&lt;&lt; from char *p .byte 0x1 .byte 0x4 .long 0x65 .byte 0x2 .byte 0x91 .sleb128 -24 &lt;&lt;&lt; not 100% sure but this is probably related to frame offset .uleb128 0x7 .string "q" .byte 0x1 .byte 0x4 .long 0x72 .byte 0x2 .byte 0x91 .sleb128 -32 &lt;&lt;&lt; note adjacent to p </code></pre> <p>When you crank up <code>-O2 -g</code>, despite <code>-g</code> the function becomes much smaller:</p> <pre><code>mystrcpy: .LFB11: .file 1 "t.c" .loc 1 5 0 .cfi_startproc (at this point we start copying, using the input regs directly) </code></pre> <p>And now there's no reference to <code>p</code> or <code>q</code> in the debug information. As you can see from this example you can probably find the information you want in registers, but you will have to disassemble and understand the function to interpret them. And if your function has called <em>other</em> functions you may have to find where your registers got spilled to the stack (could be quite far away for callee-saves regs).</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload