summaryrefslogtreecommitdiff
path: root/src/read-minidump.c
blob: f9a96ac4b840f26b5d935e1d459b9de389448e08 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/

/***
  This file is part of libminidump.

  Copyright 2012 Lennart Poettering

  libminidump is free software; you can redistribute it and/or modify
  it under the terms of the GNU Lesser General Public License as
  published by the Free Software Foundation; either version 2.1 of the
  License, or (at your option) any later version.

  libminidump is distributed in the hope that it will be useful, but
  WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  Lesser General Public License for more details.

  You should have received a copy of the GNU Lesser General Public
  License along with libminidump; If not, see
  <http://www.gnu.org/licenses/>.
***/

#include <assert.h>
#include <errno.h>
#include <unistd.h>

#include "context.h"
#include "read-minidump.h"

int minidump_read_memory(struct context *c, unsigned long source, void *destination, size_t length) {
        assert(c);
        assert(destination);
        assert(length > 0);
        assert(CONTEXT_HAVE_MINIDUMP(c));

        /* FIXME */

        return -ENOTSUP;
}

int minidump_read_header(struct context *c) {
        ssize_t l;

        assert(c);
        assert(CONTEXT_HAVE_MINIDUMP(c));

        l = pread(c->minidump_fd, &c->minidump_header, sizeof(c->minidump_header), 0);
        if (l < 0)
                return -errno;
        if (l != sizeof(c->minidump_header))
                return -EIO;

        if (c->minidump_header.signature != htole32(0x504d444d))
                return -EINVAL;

        c->have_minidump_header = true;

        return 0;
}

int minidump_read_threads(struct context *c) {
        assert(c);
        assert(CONTEXT_HAVE_MINIDUMP(c));

        /* FIXME */

        return -ENOTSUP;
}

int minidump_read_maps(struct context *c) {
        assert(c);
        assert(CONTEXT_HAVE_MINIDUMP(c));

        /* FIXME */

        return -ENOTSUP;
}