#include <errno.h>
#include <string.h>
#include <signal.h>
+#ifdef HAVE_SYS_PARAM_H
#include <sys/param.h>
+#endif
#include <sys/stat.h>
#include <mono/metadata/metadata.h>
#include <mono/metadata/tabledefs.h>
#include <mono/metadata/class-internals.h>
#include <fcntl.h>
+#ifdef HAVE_UNISTD_H
#include <unistd.h>
+#endif
#define RANGE_TABLE_CHUNK_SIZE 256
#define CLASS_TABLE_CHUNK_SIZE 256
guint64 magic;
long version;
- ptr = start = symfile->raw_contents;
+ ptr = start = (const char*)symfile->raw_contents;
if (!ptr)
return FALSE;
version = read32(ptr);
ptr += sizeof(guint32);
- if (version != MONO_SYMBOL_FILE_VERSION) {
+ if ((version != MONO_SYMBOL_FILE_VERSION) && (version != MONO_SYMBOL_FILE_COMPATIBILITY_VERSION)) {
if (!in_the_debugger)
g_warning ("Symbol file %s has incorrect version "
"(expected %d, got %ld)", symfile->filename,
return FALSE;
}
+ symfile->version = version;
+
symfile->offset_table = (MonoSymbolFileOffsetTable *) ptr;
symfile->method_hash = g_hash_table_new_full (
symfile = g_new0 (MonoSymbolFile, 1);
if (raw_contents != NULL) {
+ unsigned char *p;
symfile->raw_contents_size = size;
- symfile->raw_contents = g_malloc (size);
- memcpy(symfile->raw_contents, raw_contents, size);
+ symfile->raw_contents = p = g_malloc (size);
+ memcpy (p, raw_contents, size);
symfile->filename = g_strdup_printf ("LoadedFromMemory");
} else {
symfile->filename = g_strdup_printf ("%s.mdb", mono_image_get_filename (handle->image));
- if ((f = fopen (symfile->filename, "rb")) > 0) {
+ if ((f = fopen (symfile->filename, "rb"))) {
struct stat stat_buf;
if (fstat (fileno (f), &stat_buf) < 0) {
MonoSymbolFileLineNumberEntry *lne;
MonoSymbolFile *symfile;
gchar *source_file = NULL;
- const char *ptr;
+ const unsigned char *ptr;
int count, i;
if ((symfile = minfo->handle->symfile) == NULL)
(read32(&(minfo->entry->_source_index)) - 1) * sizeof (MonoSymbolFileSourceEntry);
MonoSymbolFileSourceEntry *se = (MonoSymbolFileSourceEntry *) (symfile->raw_contents + offset);
- source_file = read_string (symfile->raw_contents + read32(&(se->_name_offset)));
+ source_file = read_string ((const char*)symfile->raw_contents + read32(&(se->_name_offset)));
}
ptr = symfile->raw_contents + read32(&(minfo->entry->_line_number_table_offset));
for (i = jit->num_line_numbers - 1; i >= 0; i--) {
MonoDebugLineNumberEntry lne = jit->line_numbers [i];
+ if (lne.il_offset < 0)
+ continue;
if (lne.il_offset <= il_offset)
return lne.native_offset;
}
- return -1;
+ return 0;
}
static int
minfo->num_il_offsets = read32(&(me->_num_line_numbers));
minfo->il_offsets = (MonoSymbolFileLineNumberEntry *)
(symfile->raw_contents + read32(&(me->_line_number_table_offset)));
- minfo->num_lexical_blocks = read32(&(me->_num_lexical_blocks));
- minfo->lexical_blocks = (MonoSymbolFileLexicalBlockEntry *)
- (symfile->raw_contents + read32(&(me->_lexical_block_table_offset)));
+
minfo->entry = me;
g_hash_table_insert (symfile->method_hash, method, minfo);