rammanoj
rammanoj

Reputation: 497

Use of target remote localhost:26000

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

Upvotes: 0

Views: 8700

Answers (4)

Jiaxin Xiao
Jiaxin Xiao

Reputation: 1

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

Upvotes: 0

laizililove
laizililove

Reputation: 37

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...

Upvotes: 0

Kaiwen Sheng
Kaiwen Sheng

Reputation: 11

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 :)

Upvotes: 1

Employed Russian
Employed Russian

Reputation: 213879

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.

Upvotes: 1

Related Questions