| [Freeciv-Dev] Re: autobacktrace (was: concerning the use  of assert)[Top] [All Lists][Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
 
 
This is not quite what you asked for, but it might be a useful example
towards getting something a little more robust than a scripted solution
for LOG_DEBUG purposes.
Cheers,
RossW
=====
At 09:01 AM 02/09/16 +0200, Reinier Post wrote:
>BTW if someone can take charge of getting cores and maintaining the
>civserver-core-backtrace on civserver.frreeciv.org I would appreciate it.
>
>(I haven't been using gdb in a while, and there's enough work to do.)
>
>-- 
>Reinier
=====
/*
 * Stacktrace 
 *   demo program to print a stacktrace to stderr from a running program
 *
 * HowTo:
 *   cc -o stacktrace stacktrace.c
 *   ./stacktrace
 */
#include <limits.h>
#include <stdio.h>
char *progname;
void print_stacktrace()
{
  static char *pbuf, buf[PATH_MAX], line[PATH_MAX];
  FILE *pin;
  if (buf[0] == 0) {
    snprintf(buf, sizeof(buf),
      "gdb %s %d <<EOF\n"
      "where\n"
      "quit\n"
      "EOF",
      progname, getpid());
  }
  fflush(stderr);
  if ((pin = popen(buf, "r"))) {
    while( (pbuf = fgets(line, sizeof(line)-1, pin)) )
      fprintf(stderr, pbuf);
    pclose(pin);
  }
}
int main(int argc, char *argv[], char* argp[])
{
  fprintf(stderr, "Starting %s ...\n\n", argv[0]);
  progname = argv[0];
  print_stacktrace();
  fprintf(stderr, "\nDone\n");
  exit(0);
}
=====
 
[Freeciv-Dev] autobacktrace (was: concerning the use of assert), (continued)
[Freeciv-Dev] autobacktrace (was: concerning the use of assert), Reinier Post, 2002/09/10
[Freeciv-Dev] Re: autobacktrace (was: concerning the use of  assert), Ross W. Wetmore, 2002/09/13
[Freeciv-Dev] Re: autobacktrace (was: concerning the use of assert), Reinier Post, 2002/09/13
[Freeciv-Dev] Re: autobacktrace (was: concerning the use of assert), Per I. Mathisen, 2002/09/13
[Freeciv-Dev] Re: autobacktrace (was: concerning the use of assert), Jason Short, 2002/09/13
[Freeciv-Dev] Re: autobacktrace (was: concerning the use of assert), Raimar Falke, 2002/09/13
[Freeciv-Dev] Re: autobacktrace (was: concerning the use of assert), Per I. Mathisen, 2002/09/15
[Freeciv-Dev] Re: autobacktrace (was: concerning the use of assert), Per I. Mathisen, 2002/09/15
[Freeciv-Dev] Re: autobacktrace (was: concerning the use of assert), Reinier Post, 2002/09/16
[Freeciv-Dev] Re: autobacktrace (was: concerning the use of assert), Reinier Post, 2002/09/16
[Freeciv-Dev] Re: autobacktrace (was: concerning the use  of assert),
Ross W. Wetmore <=
 
 |  |