milo
milo

Reputation: 1220

how do i continue on breakpoint in gdb automatically

I'm debugging my linux kernel module. It causes deadlock and i'm trying to figure out how. I'm using vmware + gdb. The idea is to hook the function and log backtrace into the file. I'm trying the following:

(gdb) br _raw_spin_lock
Breakpoint 5 at 0xffffffff815eb700: file kernel/spinlock.c, line 136.
(gdb) commands 5
Type commands for breakpoint(s) 5, one per line.
End with a line saying just "end".
>silent
>bt
>continue
>end

but continue doesn't work here. If i replace bt with echo 1 it works. Is there way to log information every time the function is called?

Thank you.

Upvotes: 3

Views: 7708

Answers (2)

Viesturs
Viesturs

Reputation: 1691

Most likely you are hitting gdb pagination prompt. https://sourceware.org/gdb/onlinedocs/gdb/Screen-Size.html

Run this before setting the breakpoint

set height 0

Upvotes: 1

Tom Tromey
Tom Tromey

Reputation: 22519

You don't say why it doesn't work. What exactly goes wrong?

Normally this kind of thing works fine. Putting "continue" into a breakpoint's commands is something I've done routinely for years. It isn't without problems (it interferes with "next") but if you are just doing logging or the like, it works great.

One guess would be that the "bt" is failing with an error. This would cause the commands to abort and, I believe, the inferior to stop at the breakpoint. Then the question is, what exact error message is emitted? Or perhaps you're hitting pagination. Or maybe some other thing I haven't thought of :-)

If it's an error, one possible option might be to limit the backtrace.

Upvotes: 0

Related Questions