bin_PROGRAMS = navit
-navit_SOURCES = block.c command.c compass.c coord.c country.c cursor.c data_window.c destination.c \
+navit_SOURCES = block.c command.c compass.c coord.c country.c cursor.c data_window.c debug.c destination.c \
display.c file.c graphics.c log.c main.c map-common.c map-skelimpl.c map-skels.c map-srv.c \
map-stubs.c map_data.c menu.c navigation.c param.c phrase.c plugin.c poly.c popup.c \
profile.c route.c search.c speech.c street.c street_name.c town.c transform.c tree.c track.c \
util.c vehicle.c block.h command.h compass.h config.h container.h coord.h country.h \
- cursor.h data.h data_window.h data_window_int.h destination.h display.h draw_info.h \
+ cursor.h data.h data_window.h data_window_int.h debug.h destination.h display.h draw_info.h \
file.h graphics.h gtkext.h log.h main.h map-share.h map.h map_data.h menu.h navigation.h \
param.h phrase.h plugin.h point.h poly.h popup.h route.h search.h speech.h statusbar.h \
street.h street_data.h street_name.h toolbar.h town.h transform.h tree.h track.h util.h vehicle.h
--- /dev/null
+#include <signal.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <time.h>
+#include "file.h"
+#include "debug.h"
+
+
+
+static int sigsegv(void)
+{
+ FILE *f;
+ time_t t;
+ printf("segmentation fault received\n");
+ f=fopen("crash.txt","a");
+ setvbuf(f, NULL, _IONBF, 0);
+ fprintf(f,"segmentation fault received\n");
+ t=time(NULL);
+ fprintf(f,"Time: %s", ctime(&t));
+ file_remap_readonly_all();
+ fprintf(f,"dumping core\n");
+ fclose(f);
+ abort();
+}
+
+void
+debug_init(void)
+{
+ signal(SIGSEGV, sigsegv);
+}
--- /dev/null
+void debug_init(void);
#include <glib.h>
#include "file.h"
+static struct file *file_list;
+
struct file *
file_create(char *name)
{
- int fd;
struct stat stat;
struct file *file=malloc(sizeof(*file)+strlen(name)+1);
if (! file)
return file;
- fd=open(name, O_RDONLY);
- if (fd < 0) {
+ file->fd=open(name, O_RDONLY);
+ if (file->fd < 0) {
free(file);
return NULL;
}
- fstat(fd, &stat);
+ fstat(file->fd, &stat);
file->size=stat.st_size;
file->name=(char *)file+sizeof(*file);
strcpy(file->name, name);
- file->begin=mmap(NULL, file->size, PROT_READ|PROT_WRITE, MAP_PRIVATE, fd, 0);
+ file->begin=mmap(NULL, file->size, PROT_READ|PROT_WRITE, MAP_PRIVATE, file->fd, 0);
g_assert(file->begin != NULL);
if (file->begin == (void *)0xffffffff) {
perror("mmap");
g_assert(file->begin != (void *)0xffffffff);
file->end=file->begin+file->size;
file->private=NULL;
- close(fd);
g_assert(file != NULL);
+ file->next=file_list;
+ file_list=file;
return file;
}
void
-file_set_readonly(struct file *file)
+file_remap_readonly(struct file *f)
+{
+ void *begin;
+ munmap(f->begin, f->size);
+ begin=mmap(f->begin, f->size, PROT_READ, MAP_PRIVATE, f->fd, 0);
+ if (f->begin != begin)
+ printf("remap failed\n");
+}
+
+void
+file_remap_readonly_all(void)
{
- mprotect(file->begin, file->end-file->begin, PROT_READ);
+ struct file *f=file_list;
+
+ while (f) {
+ file_remap_readonly(f);
+ f=f->next;
+ }
}
void *
void
file_destroy(struct file *f)
{
+ close(f->fd);
munmap(f->begin, f->size);
free(f);
}
unsigned long size;
char *name;
void *private;
+ int fd;
+ struct file *next;
};
struct file *file_create(char *name);
-void file_set_readonly(struct file *file);
+void file_remap_readonly(struct file *file);
+void file_remap_readonly_all(void);
struct file *file_create_caseinsensitive(char *name);
int file_get_param(struct file *file, struct param_list *param, int count);
void file_destroy(struct file *f);
#include "compass.h"
#include "track.h"
#include "container.h"
-
+#include "debug.h"
void *speech_handle;
setlocale(LC_NUMERIC,"C");
gtk_set_locale();
setlocale(LC_NUMERIC,"C");
+ debug_init();
gtk_init(&argc, &argv);
gdk_rgb_init();