File: error_common.h

package info (click to toggle)
libpulp 0.3.16-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,976 kB
  • sloc: ansic: 11,792; python: 1,216; sh: 881; makefile: 871; cpp: 582; asm: 387
file content (118 lines) | stat: -rw-r--r-- 4,569 bytes parent folder | download
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
/*
 *  libpulp - User-space Livepatching Library
 *
 *  Copyright (C) 2021 SUSE Software Solutions GmbH
 *
 *  This file is part of libpulp.
 *
 *  libpulp 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.
 *
 *  libpulp 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 General Public License
 *  along with libpulp.  If not, see <http://www.gnu.org/licenses/>.
 */

#ifndef ERROR_COMMON_H
#define ERROR_COMMON_H

#include <errno.h>
#include <stdbool.h>

typedef int ulp_error_t;

/** Use errno-like definitions for errors.  This way we can use system-like
 *  errors as well.
 *
 *  We reserve [0, 255] for system errors, everything else is reserved for
 *  libpulp.
 **/

/* clang-format off */
#define ENONE           0 /** No error (success).  */
#define EUNKNOWN      256 /** Unknown error.  */
#define EBUILDID      257 /** Build Id Mismatch.  */
#define ETARGETHOOK   258 /** Error attaching to process.  */
#define ENODEBUGTAG   259 /** Process without DT_DEBUG tag.  */
#define ENOLINKMAP    260 /** No link map in object.  */
#define ENOPHDR       261 /** Invalid program header.  */
#define ENOPENTRY     262 /** Unable to find process entry address.  */
#define ENOLIBPULP    263 /** Libpulp not found.  */
#define ETHRDATTACH   264 /** Thread attach failure.  */
#define ETHRDDETTACH  265 /** Thread dettach failure.  */
#define EINVALIDULP   266 /** Invalid ULP file.  */
#define ENOOLDFUNC    267 /** To be patched function not found.  */
#define ENONEWFUNC    268 /** New function not found.  */
#define ENOMETA       269 /** No metadata in .so.  */
#define ESTATE        270 /** State update failure.  */
#define ENOSTATE      271 /** Unable to retrieve ulp state.  */
#define ENOTAPPLIED   272 /** Patch not applied. */
#define EDEPEND       273 /** Dependency failure.  */
#define ENOADDRESS    274 /** Address Error.  */
#define EAPPLIED      275 /** Patch applied.  */
#define ENOTARGETLIB  276 /** Target library not loaded.  */
#define EHOOKNOTRUN   277 /** libpulp.so hook routine not run.  */
#define ENOPATCHABLE  278 /** Function is not livepatchable.  */
#define EWILDNOMATCH  279 /** No file matched wildcard.  */
#define EUSRBLOCKED   280 /** Livepatch blocked by user request.  */
#define EOLDLIBPULP   281 /** Libpulp version too old.  */
#define EINITFAIL     282 /** Libpulp initialization failure.  */
#define MPROTFAIL     283 /** Page permission error.  */
#define ENOPATCH      284 /** No patches installed.  */
#define EINSNQ        285 /** Instruction queue in inconsistent state.  */
#define EOLDULP       286 /** ULP tool is too old.  */
#define EDLOPEN       287 /** Failure in dlopen.  */
#define ENOLIBDL      288 /** Libdl not found.  */
#define ENOLIBC       289 /** Libc not found.  */

/** Table used to map error code to message.  Define it here so that it is
 *  easier for it being maintained.
 */
#define __ULP_ERRLIST \
  { \
    "Unknown error", \
    "Build ID mismatch", \
    "Error attaching to process", \
    "Process without debug tag", \
    "No link map in object", \
    "Invalid program header", \
    "Unable to find process entry address", \
    "Libpulp not found in target process", \
    "Thread attach failure", \
    "Thread dettach failure", \
    "Invalid .ulp file", \
    "To be patched function not found", \
    "New function not found", \
    "No metadata in .so", \
    "State update failure", \
    "Unable to retrieve ulp state", \
    "Patch not applied", \
    "Dependency failure", \
    "Address read error", \
    "Patch already applied", \
    "Target library not loaded", \
    "libpulp.so hook routine not run", \
    "Function is not livepatchable", \
    "No file matched wildcard", \
    "Livepatching blocked by user request", \
    "Libpulp version is too old", \
    "Libpulp initialization failure", \
    "Page permission error", \
    "No patches installed", \
    "Instruction queue in inconsistent state", \
    "ULP tool is too old", \
    "Failure in dlopen", \
    "Libdl not found." \
    "Libc not found or unsupported." \
  }
/* clang-format on */

const char *libpulp_strerror(ulp_error_t);

#endif /* ERROR_COMMON_H  */