[Home] [Downloads] [Search] [Help/forum]


Register forum user name Search FAQ

Gammon Forum

[Folder]  Entire forum
-> [Folder]  Programming
. -> [Folder]  General
. . -> [Subject]  Problem with breakpoints in gdb

Problem with breakpoints in gdb

It is now over 60 days since the last post. This thread is closed.     [Refresh] Refresh page


Posted by Greven   Canada  (835 posts)  [Biography] bio
Date Thu 05 Feb 2004 10:36 PM (UTC)
Message
I'm trying to set a break point, but I'm getting this error:
Quote:
(gdb) break fight.c:525
Breakpoint 1 at 0x80e1bca: file fight.c, line 525.
(gdb) cont
Continuing.
Warning:
Cannot insert breakpoint 1.
Error accessing memory address 0x80e1bca: Input/output error.
The same program may be running in another process.


I get similar problem when I try to boot it from within gdb,but the breakpoint is -2. My compilation flags are:
Quote:
DEBUG = -ggdb
C_FLAGS = -g3 -g2 -W -Wall $(DEFINES) $(PROF) $(NOCRYPT) $(DBUGFLG) $(DEBUG) -export-dynamic


I'm really unclear on what the problem may be, or what I can do about it.

Nobody ever expects the spanish inquisition!

darkwarriors.net:4848
http://darkwarriors.net
[Go to top] top

Posted by David Haley   USA  (3,881 posts)  [Biography] bio
Date Reply #1 on Fri 06 Feb 2004 01:27 AM (UTC)
Message
Looks like you might have the program running twice (under two separate process.)

David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone

http://david.the-haleys.org
[Go to top] top

Posted by Greven   Canada  (835 posts)  [Biography] bio
Date Reply #2 on Fri 06 Feb 2004 01:27 AM (UTC)

Amended on Fri 06 Feb 2004 01:33 AM (UTC) by Greven

Message
nope, only one, I checked that. This might help:
dwadmins@godlike:~/src$ ps ux
USER       PID %CPU %MEM   VSZ  RSS TTY      STAT START   TIME COMMAND
dwadmins   555  0.0  0.2  2104 1836 ?        S    Feb04   0:00 /bin/bash ./swr-watch
dwadmins   904  0.0  0.4  6232 3204 ?        S    Feb04   0:00 sshd: dwadmins@pts/14
dwadmins   905  0.0  0.3  2372 2432 pts/14   S    Feb04   0:00 -bash
dwadmins   562  1.3  1.4 11528 11496 ?       SN   Feb04  21:13 swr 4848 hotboot 5 0 0 0 -1
dwadmins  2298  0.0  0.1  2788 1368 pts/14   R    18:32   0:00 ps ux
dwadmins@godlike:~/src$ gdb swr 562
GNU gdb 5.3
Copyright 2002 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "i386-slackware-linux"...
Attaching to program: /home/mud/darkwars/dwadmins/src/swr, process 562
Reading symbols from /lib/libdl.so.2...done.
Loaded symbols for /lib/libdl.so.2
Reading symbols from /usr/lib/libz.so.1...done.
Loaded symbols for /usr/lib/libz.so.1
Reading symbols from /lib/libcrypt.so.1...done.
Loaded symbols for /lib/libcrypt.so.1
Reading symbols from /usr/lib/libstdc++.so.5...done.
Loaded symbols for /usr/lib/libstdc++.so.5
Reading symbols from /lib/libm.so.6...done.
Loaded symbols for /lib/libm.so.6
Reading symbols from /usr/lib/libgcc_s.so.1...done.
Loaded symbols for /usr/lib/libgcc_s.so.1
Reading symbols from /lib/libc.so.6...done.
Loaded symbols for /lib/libc.so.6
Reading symbols from /lib/ld-linux.so.2...done.
Loaded symbols for /lib/ld-linux.so.2
Reading symbols from /lib/libnss_files.so.2...done.
Loaded symbols for /lib/libnss_files.so.2
Reading symbols from /lib/libnss_dns.so.2...done.
Loaded symbols for /lib/libnss_dns.so.2
Reading symbols from /lib/libresolv.so.2...done.
Loaded symbols for /lib/libresolv.so.2
0x282765e2 in select () from /lib/libc.so.6
(gdb) break fight.c:525
Breakpoint 1 at 0x80e1bca: file fight.c, line 525.
(gdb) cont
Continuing.
Warning:
Cannot insert breakpoint 1.
Error accessing memory address 0x80e1bca: Input/output error.
The same program may be running in another process.
(gdb) quit
The program is running.  Quit anyway (and detach it)? (y or n) y
Detaching from program: /home/mud/darkwars/dwadmins/src/swr, process 562
dwadmins@godlike:~/src$ 

Nobody ever expects the spanish inquisition!

darkwarriors.net:4848
http://darkwarriors.net
[Go to top] top

Posted by David Haley   USA  (3,881 posts)  [Biography] bio
Date Reply #3 on Fri 06 Feb 2004 01:52 AM (UTC)
Message
One thing you can try is to start the process with GDB directly, i.e.

gdb ../src/swr
(in gdb) run 4848

Not sure if that will help though...

David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone

http://david.the-haleys.org
[Go to top] top

Posted by Greven   Canada  (835 posts)  [Biography] bio
Date Reply #4 on Fri 06 Feb 2004 01:58 AM (UTC)

Amended on Fri 06 Feb 2004 01:59 AM (UTC) by Greven

Message
Quote:

USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
dwadmins 555 0.0 0.2 2104 1836 ? S Feb04 0:00 /bin/bash ./swr-watch
dwadmins 904 0.0 0.4 6232 3204 ? S Feb04 0:00 sshd: dwadmins@pts/14
dwadmins 905 0.0 0.3 2372 2432 pts/14 S Feb04 0:00 -bash
dwadmins 562 1.3 1.4 10888 10976 ? SN Feb04 21:34 swr 4848 hotboot 5 0 0 0 -1
dwadmins 2659 0.0 0.1 2800 1368 pts/14 R 18:57 0:00 ps ux
dwadmins@godlike:~/port/area$ gdb ../src/swr
GNU gdb 5.3
Copyright 2002 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB. Type "show warranty" for details.
This GDB was configured as "i386-slackware-linux"...run
(gdb) run 4872
Starting program: /home/mud/darkwars/dwadmins/port/src/swr 4872
Warning:
Cannot insert breakpoint -2.
Error accessing memory address 0x22a76520: Input/output error.
.


I tried that before, which is what makes this kinda strange

Nobody ever expects the spanish inquisition!

darkwarriors.net:4848
http://darkwarriors.net
[Go to top] top

Posted by Nick Gammon   Australia  (22,990 posts)  [Biography] bio   Forum Administrator
Date Reply #5 on Fri 06 Feb 2004 10:11 PM (UTC)
Message
OK, let's see what you are trying to set the breakpoint on.

In gdb type:

list fight.c:525

Just curious, maybe it is a literal or something.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Nick Gammon   Australia  (22,990 posts)  [Biography] bio   Forum Administrator
Date Reply #6 on Fri 06 Feb 2004 10:15 PM (UTC)
Message
Quote:

dwadmins 562 1.3 1.4 10888 10976 ? SN Feb04 21:34 swr 4848 hotboot 5 0 0 0 -1
dwadmins 2659 0.0 0.1 2800 1368 pts/14 R 18:57 0:00 ps ux
dwadmins@godlike:~/port/area$ gdb ../src/swr


In your example you have two copies - the one running in process 562, and the new one you are gdb'ing.

If the process ID is 562, try typing:

gdb swr 562

(In the earlier posts 4848 is the port, not the PID).

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Greven   Canada  (835 posts)  [Biography] bio
Date Reply #7 on Fri 06 Feb 2004 10:17 PM (UTC)

Amended on Fri 06 Feb 2004 10:18 PM (UTC) by Greven

Message
Ok, here is what I get
Quote:
wadmins@godlike:~$ gdb /src/swr 562
GNU gdb 5.3
Copyright 2002 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB. Type "show warranty" for details.
This GDB was configured as "i386-slackware-linux"...
Attaching to program: /home/mud/darkwars/dwadmins/src/swr, process 562
Reading symbols from /lib/libdl.so.2...done.
Loaded symbols for /lib/libdl.so.2
Reading symbols from /usr/lib/libz.so.1...done.
Loaded symbols for /usr/lib/libz.so.1
Reading symbols from /lib/libcrypt.so.1...done.
Loaded symbols for /lib/libcrypt.so.1
Reading symbols from /usr/lib/libstdc++.so.5...done.
Loaded symbols for /usr/lib/libstdc++.so.5
Reading symbols from /lib/libm.so.6...done.
Loaded symbols for /lib/libm.so.6
Reading symbols from /usr/lib/libgcc_s.so.1...done.
Loaded symbols for /usr/lib/libgcc_s.so.1
Reading symbols from /lib/libc.so.6...done.
Loaded symbols for /lib/libc.so.6
Reading symbols from /lib/ld-linux.so.2...done.
Loaded symbols for /lib/ld-linux.so.2
Reading symbols from /lib/libnss_files.so.2...done.
Loaded symbols for /lib/libnss_files.so.2
Reading symbols from /lib/libnss_dns.so.2...done.
Loaded symbols for /lib/libnss_dns.so.2
Reading symbols from /lib/libresolv.so.2...done.
Loaded symbols for /lib/libresolv.so.2
0x282765e2 in select () from /lib/libc.so.6
(gdb) break fight.c:525
Breakpoint 1 at 0x80e1bca: file fight.c, line 525.
(gdb) list fight.c:525
520 case 4: *gsn_ptr = gsn_flexible_arms; break;
521 case 5: *gsn_ptr = gsn_knives; break;
522 case 6: *gsn_ptr = gsn_blasters; break;
523 case 8: *gsn_ptr = gsn_bludgeons; break;
524 case 9: *gsn_ptr = gsn_bowcasters; break;
525 case 11: *gsn_ptr = gsn_force_pikes; break;
526
527 }
528 if ( *gsn_ptr != -1 )
529 bonus = (int) ( ch->pcdata->learned[*gsn_ptr] );
(gdb)


I can understand how it might not work depending where I am setting the break point, but it doesn't seem to mattter where I actually put the break, I get the same error when I've attached to the pid.

Nobody ever expects the spanish inquisition!

darkwarriors.net:4848
http://darkwarriors.net
[Go to top] top

Posted by Nick Gammon   Australia  (22,990 posts)  [Biography] bio   Forum Administrator
Date Reply #8 on Sat 07 Feb 2004 07:35 PM (UTC)
Message
I cannot reproduce this, as you might expect, as I did all the breakpoint stuff in my recent forum post without any problems.

However a Google search for:

gdb "cannot insert breakpoint -2"

reveals quite a few posts from people with similar problems.

Sounds it might be a problem with shared libraries, which doesn't seem to apply in your case, or just a bug in the particular Linux kernel.

All I can suggest doing is:

* Upgrade your Linux version; or
* Download and compile a newer version of gdb, if applicable

Try searching for your particular OS version (is it Slackware?, it looks like it might be) and see if there is a known problem with gdb and that version.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Greven   Canada  (835 posts)  [Biography] bio
Date Reply #9 on Sun 08 Feb 2004 07:45 AM (UTC)
Message
Actually, I'm on a payed server, so I can't do any upgrades myself. If thats the case, I'll contact my admin, thanks.

Nobody ever expects the spanish inquisition!

darkwarriors.net:4848
http://darkwarriors.net
[Go to top] top

The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).

To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.


21,346 views.

It is now over 60 days since the last post. This thread is closed.     [Refresh] Refresh page

Go to topic:           Search the forum


[Go to top] top

Quick links: MUSHclient. MUSHclient help. Forum shortcuts. Posting templates. Lua modules. Lua documentation.

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.

[Home]


Written by Nick Gammon - 5K   profile for Nick Gammon on Stack Exchange, a network of free, community-driven Q&A sites   Marriage equality

Comments to: Gammon Software support
[RH click to get RSS URL] Forum RSS feed ( https://gammon.com.au/rss/forum.xml )

[Best viewed with any browser - 2K]    [Hosted at HostDash]