Replacing a quake3 function

nexus024
Posts: 148
Joined: Fri Oct 06, 2006 7:26 pm

Post by nexus024 »

Code: Select all

(gdb) run bt
Starting program: /home/nick/Desktop/q3as-sourceOLD/source/game/OBJS/Q3/qagamei386.so bt
warning: shared library handler failed to enable breakpoint

Program received signal SIGSEGV, Segmentation fault.
0x00000002 in ?? ()
^misantropia^
Posts: 4022
Joined: Sat Mar 12, 2005 6:24 pm

Post by ^misantropia^ »

You'll need to type `bt` after the SIGSEGV. PS: it's the engine you'll want to run inside gdb, not the bare .so.
nexus024
Posts: 148
Joined: Fri Oct 06, 2006 7:26 pm

Post by nexus024 »

I am new to this as you all are well aware. I am not sure what you mean by I need to run gdb on the engine and not the .so file. When I compile q3as all it gives me is an OBJ/Q3 folder with a bunch of object files and the .so file. What exactly is the engine that you are referring to?
^misantropia^
Posts: 4022
Joined: Sat Mar 12, 2005 6:24 pm

Post by ^misantropia^ »

That would be the quake3 executable.
nexus024
Posts: 148
Joined: Fri Oct 06, 2006 7:26 pm

Post by nexus024 »

- Create a Makefile.local in the same directory where the Makefile resides
- Add this line to it: CFLAGS="-static"
- Run: `make debug`
Is that all that should be in the Makefile.local.... that one line of code?

I
nexus024
Posts: 148
Joined: Fri Oct 06, 2006 7:26 pm

Post by nexus024 »

I seem to always get errors. :confused:

Code: Select all

/debug-linux-i386/client/cl_curl.o -c code/client/cl_curl.c
code/client/cl_curl.c:30:17: error: SDL.h: No such file or directory
code/client/cl_curl.c:31:24: error: SDL_loadso.h: No such file or directory
code/client/cl_curl.c: In function ‘GPA’:
code/client/cl_curl.c:99: warning: implicit declaration of function ‘SDL_LoadFun ction’
code/client/cl_curl.c:99: warning: assignment makes pointer from integer without  a cast
code/client/cl_curl.c: In function ‘CL_cURL_Init’:
code/client/cl_curl.c:127: warning: implicit declaration of function ‘SDL_LoadOb ject’
code/client/cl_curl.c:127: warning: assignment makes pointer from integer withou t a cast
code/client/cl_curl.c:137: warning: assignment makes pointer from integer withou t a cast
code/client/cl_curl.c: In function ‘CL_cURL_Shutdown’:
code/client/cl_curl.c:192: warning: implicit declaration of function ‘SDL_Unload Object’
make[1]: *** [build/debug-linux-i386/client/cl_curl.o] Error 1
make[1]: Leaving directory `/home/nick/quake3'
make: *** [build_debug] Error 2
Sevensins
Posts: 444
Joined: Tue Jul 17, 2001 7:00 am

Post by Sevensins »

You need the SDL dev package

http://ioquake3.org/?page=get&method=source
nexus024
Posts: 148
Joined: Fri Oct 06, 2006 7:26 pm

Post by nexus024 »

More errors...

Code: Select all

 build/debug-linux-i386/client/sdl_snd.o build/debug-linux-i386/client/linux_joystick.o build/debug-linux-i38 6/client/linux_glimp.o build/debug-linux-i386/client/sdl_glimp.o -L/usr/lib -lSDL -lpthread -lopenal -ldl -lm  -m32
/usr/bin/ld: cannot find -lopenal
collect2: ld returned 1 exit status
make[1]: *** [build/debug-linux-i386/ioquake3.i386] Error 1
make[1]: Leaving directory `/home/nick/quake3'
make: *** [build_debug] Error 2
Sevensins
Posts: 444
Joined: Tue Jul 17, 2001 7:00 am

Post by Sevensins »

you need openAL unless you disable it...as it says in the link I gave you
nexus024
Posts: 148
Joined: Fri Oct 06, 2006 7:26 pm

Post by nexus024 »

Ok I now have a compiled debug version of ioquake3.i386. So now I must do a gdb ioquake3.i386, type run and when it encounters an error type run bt. Correct?

Code: Select all

Starting program: /home/nick/quake3/build/debug-linux-i386/ioquake3.i386 bt
/home/nick/quake3/build/debug-linux-i386/ioquake3.i386: error while loading shared libraries: libopenal.so.0: cannot open shared object file: No such file or directory

Program exited with code 0177.
^misantropia^
Posts: 4022
Joined: Sat Mar 12, 2005 6:24 pm

Post by ^misantropia^ »

Your build still depends on OpenAL. Just to be sure: add the line "USE_OPENAL=0" to your Makefile.local, then type `make clean && make debug`.
nexus024
Posts: 148
Joined: Fri Oct 06, 2006 7:26 pm

Post by nexus024 »

Ok, I think I am now confused as to what I need to be debugging. Do I want to run gdb on ioq3ded.i386 or ioquake3.i386. And where does the testing of the q3as mod that I compiled come into play?
Sevensins
Posts: 444
Joined: Tue Jul 17, 2001 7:00 am

Post by Sevensins »

you should be able to type:

gdb quake3 +set fs_game=modname

or this if you are not using vm's:

gdb quake3 +set fs_game=modname +sv_pure 0 +set vm_Game 0 +set vm_cgame 0 +set vm_ui 0


obviously, replace modname with the name of your mod

when the program crashes, type bt and then you should see your call stack
nexus024
Posts: 148
Joined: Fri Oct 06, 2006 7:26 pm

Post by nexus024 »

Code: Select all

nick@nick-desktop:~/Desktop/quake3$ gdb quake3 +set fs_game=baseq3 +set sv_pure 0 +set vm_game 0 +set vm_cgame 0 +set vm_ui 0 Excess command line arguments ignored. (fs_game=baseq3 ...)
GNU gdb 6.4-debian
Copyright 2005 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 "i486-linux-gnu"..."/home/nick/Desktop/quake3/quake3": not in executable format: File format not recognized

/home/nick/Desktop/quake3/+set: No such file or directory.
(gdb)

Are you sure its not q3ded so you are running it as a server? I have tried it with q3ded also and it doesn't crash, but it doesn't run as a server either. (it never loads the bots... just hangs.)
^misantropia^
Posts: 4022
Joined: Sat Mar 12, 2005 6:24 pm

Post by ^misantropia^ »

Inside gdb, type "set args +set fs_game yourmod +set sv_pure 0" etc.
Sevensins
Posts: 444
Joined: Tue Jul 17, 2001 7:00 am

Post by Sevensins »

^misantropia^ wrote:Inside gdb, type "set args +set fs_game yourmod +set sv_pure 0" etc.
oh right, sorry :p it's actually been a while since I've used gdb:

gdb quake3

then in gdb:

set args +set fs_game yourmod +set sv_pure 0

run
nexus024
Posts: 148
Joined: Fri Oct 06, 2006 7:26 pm

Post by nexus024 »

Code: Select all

Program received signal SIGSEGV, Segmentation fault.
0x080a25ed in ?? ()
(gdb) bt
#0  0x080a25ed in ?? ()
#1  0x080b9eac  in ?? ()
#2  0xbfae26ec  in ??  ()
#3  0xbfae2580  in ?? ()
#4  0xbfae253c  in ?? ()
#5  0xb318baa8 in Q_stricmp ()
       from /home/nick/Desktop/quake3/baseq3/qagamei386.so
#6  0x0805daf2  in ?? ()
#7  0xbfae2700  in ?? ()
#8  0x00000002 in ?? ()
#9  0xbfae26c8  in ?? ()
#10  0x011c0fbe  in ?? ()
#11  0xb31969cc  in ?? ()
#12  0xb31a4e80  in memoryPool ()
         from /home/nick/Desktop/quake3/baseq3/qagamei386.so
#13  0xbfae2700  in ?? ()
#14  0xbfae2678  in ?? ()
#15  0x00000000  in ?? ()
nexus024
Posts: 148
Joined: Fri Oct 06, 2006 7:26 pm

Post by nexus024 »

Anyone know what this error is or how I can fix it?
nexus024
Posts: 148
Joined: Fri Oct 06, 2006 7:26 pm

Post by nexus024 »

I have tried running gdb on the ioq3ded.i386 with my custom qagamei386.so file and it doesn't crash it.
^misantropia^
Posts: 4022
Joined: Sat Mar 12, 2005 6:24 pm

Post by ^misantropia^ »

No. The ?? means either the .so or the engine doesn't have debug symbols. I wager it's the engine because memoryPool() resides in game/g_mem.c.

EDIT: oeh, simultaneous post!
nexus024
Posts: 148
Joined: Fri Oct 06, 2006 7:26 pm

Post by nexus024 »

hehe yes i saw that!
nexus024
Posts: 148
Joined: Fri Oct 06, 2006 7:26 pm

Post by nexus024 »

hmmm so what does this mean I must do to get it some debug symbols?
^misantropia^
Posts: 4022
Joined: Sat Mar 12, 2005 6:24 pm

Post by ^misantropia^ »

Well, you could download the vanilla 1.32 source and compile a debug build. It's a bit of a pain to do so, though: it doesn't compile cleanly on Linux IIRC.
nexus024
Posts: 148
Joined: Fri Oct 06, 2006 7:26 pm

Post by nexus024 »

Is this the only way to determine what the problem is with my custom mod?
^misantropia^
Posts: 4022
Joined: Sat Mar 12, 2005 6:24 pm

Post by ^misantropia^ »

That or hiring a psychic, I'm afraid. And unfortunately their success rates tend to vary quite a bit.
Locked