0

I'm trying to debug a live Linux kernel running on virtualbox. I added the appropriate settings in the kernel (using the .config file, by enabling KGDB and adding the debug info in the kernel).

My serial port is a named pipe (socket) which I then redirect using socat to get the corresponding PTY.

$ socat -d -d ./slackpipe PTY
2015/03/16 00:04:02 socat[2723] N opening connection to AF=1 "./slackpipe"
2015/03/16 00:04:02 socat[2723] N successfully connected from local address AF=1 "\x82q\xEE\x7E"
2015/03/16 00:04:02 socat[2723] N successfully connected via <anon>
2015/03/16 00:04:02 socat[2723] N PTY is /dev/pts/15
2015/03/16 00:04:02 socat[2723] N starting data transfer loop with FDs [3,3] and [4,4]

Then I fire up gdb with the corresponding vmlinux file and target the PTY obtained from the socat above

$ gdb vmlinux 
GNU gdb (Ubuntu 7.7-0ubuntu3.1) 7.7
Copyright (C) 2014 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from vmlinux...done.
(gdb) c
The program is not being run.
(gdb) target remote /dev/pts/15
Remote debugging using /dev/pts/15
qTStatus: Target returns error code '22'.
kgdb_breakpoint () at kernel/kgdb.c:1748
1748    kernel/kgdb.c: No such file or directory.
qTStatus: Target returns error code '22'.

What I do not understand is, this never used to be happen earlier. All of a sudden this seems to be appearing.

Keen for your input

AjB
  • 890
  • 13
  • 34
  • are you sure you are running gdb from right location? I see that vmlinux is loaded properly but gdb cant find kernel/kgdb.c – Milind Dumbare Mar 16 '15 at 09:17
  • Well that is actually not related to this problem. However I was able to solve that using the gdb command `dir` to tell it where the source files were. However, could you please shed some light on that error code '22' that I seem to be getting here? – AjB Mar 16 '15 at 17:36
  • 22 is errno probably. As you see gdb could not find kernel/kgdb.c. What exactly did you do with gdb dir command? – Milind Dumbare Mar 16 '15 at 17:37
  • I told gdb where the kernel source files are like so: `dir 'path-to-top-level-kernel-source'` and voila gdb now sees the code. Anyways, do you know something about this errno? I've only seen one post and it was unanswered. And it was related to the pintos OS. Not linux – AjB Mar 16 '15 at 17:42
  • Need to see the gdb source code. So you werre not running gdb from the correct kernel sources? – Milind Dumbare Mar 16 '15 at 17:45
  • you are not getting me. actually you can gdb wherever you want but you need to explicitly tell gdb where to look for the source files __if__ you are not running it from a standard location. – AjB Mar 16 '15 at 17:48
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/73096/discussion-between-miline-and-pegasus). – Milind Dumbare Mar 16 '15 at 17:50

0 Answers0