0

I have been trying to debug my xv6 locally (It is a 32-bit code). But I am working on a 64 bit machine and my gdb is 64 bit. Whenever I type

make gdb

I encountered the following error

+ target remote localhost:26000
.gdbinit:23: Error in sourced command file:
localhost:26000: Connection timed out.
(gdb) target remote localhost:26000
localhost:26000: Connection timed out.

I have a .gdbinit file. I have the following line in it

target remote localhost:26000

It's returning an error at this line. I initially thought it is because of 32-bit architecture of my machine. But if I go to some other directory and type the same message in the gdb console I am receiving the same error. I can't actually understand why it should connect to localhost(i.e what is need of a server here? ) as GDB is a normal GNU debugger right? and what is the reason for its failure in the above case?

Thanks in advance

rammanoj
  • 479
  • 8
  • 26

4 Answers4

1

Your question doesn't make any sense (to me).

As far as I can tell, you are asking: "why does GDB try to connect to localhost:2600".

The answer is: because you asked GDB to do so with the target remote localhost:26000 entry in your ~/.gdbinit.

Update:

I am asking what does that command do?

It instructs GDB to perform remote debugging, and to connect to gdbserver listening on the given port.

In general, you should never put anything into your ~/.gdbinit (or any other initialization file) that you don't understand. Doing so is akin to to taking an unknown object (a gun), putting it to your head, and squeezing a little lever on the side (a trigger).

and executing it giving me the above error so can you please say what is the error? and how to resolve it

Just delete the command (and any other commands that you don't know the meaning of) from ~/.gdbinit.

Employed Russian
  • 199,314
  • 34
  • 295
  • 362
  • Thanks for the reply. I am asking what does that command do? and executing it giving me the above error so can you please say what is the error? and how to resolve it I can't it – rammanoj May 04 '18 at 13:10
  • Thanks for the answer I am following a course in building jos at https://pdos.csail.mit.edu/6.828/2017/tools.html. In lab1 portion(i.e https://pdos.csail.mit.edu/6.828/2017/labs/lab1/ ) on running command 'make gdb' it is giving above error. .gdbinit is their configuration file I think deleting it can't solve this issue right? – rammanoj May 04 '18 at 14:06
  • Unless your system doesn't have GDB, you probably don't need to build GDB at all. And *yes* you should absolutely remove anything from `.gdbinit` until you understand what it's for. – Employed Russian May 04 '18 at 14:23
1

I've just solved the same problem u described. U can have a look at the GNUmakefile to search the port number your gdb-qemu attempted to connect to. In my GNUmakefile, the port number is # try to generate a unique GDB port GDBPORT := $(shell exprid -u% 5000 + 25000)
So when I try to run sudo make gdb-qemu, I got the result as follows:

qemu-system-i386 -drive file=obj/kern/kernel.img,index=0,media=disk,format=raw -serial mon:stdio -gdb tcp::25000 -D qemu.log  -S  

But when I run another terminal to run sudo make gdb, I got the result:

Type "apropos word" to search for commands related to "word".
+ target remote localhost:26000

The port number didn't match.
So by simply modify the port number in the GNUmakefile to 26000, we can get the ideal results.
Hope it's helpful :)

0

I had ever met the same problem as you. I had been troubled by this problem for hours. But this problem is so easy.Please excute the following commands .

  1. make qemu-gdb enter image description here

  2. make gdb (in another terminal.)

The reason for this problem is that when you execute the make gdb command, you end the execution of the make gdb .So the qemu server connection timed out . In the picture, we can't alse find the infomation like remote gdb port...

0

You should change the port in the .gdbint file. It tells GDB which port to detach. I solved this problem in this way.

Laurel
  • 5,965
  • 14
  • 31
  • 57