It's possible to get backtraces from within the game if you're using
glibc and link the game with -rdynamic. I don't know how best to
leverage it to find your problem. But this and gdb are the only way I
know of to get at the calling stack.
Here's what I do to log a backtrace:
#include <execinfo.h>
void log_backtrace()
{
void *bt[10];
char **bt_strings;
int count = backtrace(bt, 10), i;
bt_strings = backtrace_symbols(bt, count);
bug("Backtrace:", 0);
for (i = 0; i < count; i++)
bug(bt_strings[i], 0);
free(bt_strings);
}
On 3/16/06, Valnir <[EMAIL PROTECTED]> wrote:
> Yeah, I'm almost wondering if it'll be less intrusive to just grep for
> get_char_offline and double check all the functions that call it to make
> sure it's also calling unload_char before any return.
>
> Oh well, so much for a quick fix. Thanks for the info though.
>
> - Valnir
>
> ----- Original Message -----
> From: "Richard Lindsey" <[EMAIL PROTECTED]>
> To: "Valnir" <[EMAIL PROTECTED]>; <[email protected]>
> Sent: Thursday, March 16, 2006 10:31 AM
> Subject: RE: Rogue Buffers.
>
>
> Ahhhh I gotcha, so you need to know the origin of that function call
> then... well, I guess same rules apply, set a breakpoint on
> get_char_offline and then put the code through its paces to see at which
> point the open buffers continue to grow in number... you can either set
> the breakpoint at the first line of get_char_offline to catch all of the
> calls at once, and then check the stack to see the calling function, or
> you can set breakpoints at each individual call to it and just see which
> function it breaks in when you start doing your tests...
>
> Richard.
>
> -----Original Message-----
> From: Valnir [mailto:[EMAIL PROTECTED]
> Sent: Thursday, March 16, 2006 9:33 AM
> To: [email protected]
> Subject: Re: Rogue Buffers.
>
> Yeah, I know the problem is that there is a call to get_char_offline and
>
> then unload_char isn't being called to free it, but I'm just not sure
> what
> function is actuall making the call, that's the issue I guess.
>
> - Valnir
>
> ----- Original Message -----
> From: "Richard Lindsey" <[EMAIL PROTECTED]>
> To: "Valnir" <[EMAIL PROTECTED]>; <[email protected]>
> Sent: Thursday, March 16, 2006 10:18 AM
> Subject: RE: Rogue Buffers.
>
>
> Hmmm, the only way I can think off the top of my head to track the
> calling function would be to put a break on the function in gdb and
> check the stack, only this could take a while, depending on how many
> players are loading, how many offline players are being loaded, etc...
> probably a better way is going to be to evaluate what the need for
> knowing the calling function is... you can probably grep for new_pcdata
> and come across only a few instances in your entire codebase... I mean,
> if I even remember correctly (and it's been a whiiiiiiile since I did
> any actual ROM coding :D), new_pcdata is really only called from a
> couple places... nanny, I believe, and probably fread_char... and if
> you've got a function to load offline characters, like pload, or finger,
> or something like that, then those would be the additional functions
> that might utilize new_pcdata... but free_char should automatically
> free_pcdata within it, so as long as you're freeing the CHAR_DATA *
> variable, the pcdata should be freed along with it... but if you
> absolutely need to know the calling function at specific points of
> gameplay, the only thing I can come up w/ right now is using gdb and
> breakpoints, but I'm far from the best coder, so we'll see if anyone
> else throws in some additional ideas :)
>
> Richard Lindsey.
>
> -----Original Message-----
> From: Valnir [mailto:[EMAIL PROTECTED]
> Sent: Thursday, March 16, 2006 8:40 AM
> To: [email protected]
> Subject: Rogue Buffers.
>
> Hey guys, I've got a little issue. I d/l and installed a snippet from
> Mud
> Magic that will track the number of open buffers and tell me from what
> function they where called. It's working great, and has been really
> helpful
> for tracking down stuff that doesn't get freed properly.
>
> The issues is as follows. The only open buffers I have that seem to be
> not
> getting freed are a few that are called from new_pcdata, and yes, I know
>
> that every character that is logged in SHOULD have an open one from
> there. I
> have a few more than there are people connected. Does anyone know a way
> to
> track back what function CALLED new_pcata? I guess I should say what
> function called the load_char function, or called the get_char_offline
> which
> called the load_char.... You can see why I'm having a problem finding
> these
> on my own.
>
> Any help is appreciated, thanks!
>
> - Valnir
>
> --
> ROM mailing list
> [email protected]
> Unsubscribe here ->>> http://www.rom.org/cgi-bin/mailman/listinfo/rom
>
> --
> ROM mailing list
> [email protected]
> Unsubscribe here ->>> http://www.rom.org/cgi-bin/mailman/listinfo/rom
>
> --
> ROM mailing list
> [email protected]
> Unsubscribe here ->>> http://www.rom.org/cgi-bin/mailman/listinfo/rom
>
--
ROM mailing list
[email protected]
Unsubscribe here ->>> http://www.rom.org/cgi-bin/mailman/listinfo/rom