DebugServer2
Loading...
Searching...
No Matches
ErrorCodes.h
1//
2// Copyright (c) 2014-present, Facebook, Inc.
3// All rights reserved.
4//
5// This source code is licensed under the University of Illinois/NCSA Open
6// Source License found in the LICENSE file in the root directory of this
7// source tree. An additional grant of patent rights can be found in the
8// PATENTS file in the same directory.
9//
10
11#pragma once
12
13#include <type_traits>
14
15namespace ds2 {
16
17// Error Codes as defined by GDB remoting documentation,
18// plus some others.
19enum ErrorCode {
20 kSuccess,
21 kErrorNoPermission = 1,
22 kErrorNotFound = 2,
23 kErrorProcessNotFound = 3,
24 kErrorInterrupted = 4,
25 kErrorInvalidHandle = 9,
26 kErrorNoMemory = 12,
27 kErrorAccessDenied = 13,
28 kErrorInvalidAddress = 14,
29 kErrorBusy = 16,
30 kErrorAlreadyExist = 17,
31 kErrorNoDevice = 19,
32 kErrorNotDirectory = 20,
33 kErrorIsDirectory = 21,
34 kErrorInvalidArgument = 22,
35 kErrorTooManySystemFiles = 23,
36 kErrorTooManyFiles = 24,
37 kErrorFileTooBig = 27,
38 kErrorNoSpace = 28,
39 kErrorInvalidSeek = 29,
40 kErrorNotWriteable = 30,
41 kErrorNameTooLong = 91,
42 kErrorUnknown = 9999,
43 kErrorUnsupported = 10000
44};
45
46char const *GetErrorCodeString(ErrorCode err);
47
48#define CHK_ACTION(C, A) \
49 do { \
50 auto __CHK_expr_lambda = [&]() { return C; }; \
51 static_assert( \
52 std::is_same<decltype(__CHK_expr_lambda()), ErrorCode>::value, \
53 #C " is not an expression of type ErrorCode"); \
54 ErrorCode CHK_error = (C); \
55 if (CHK_error != kSuccess) { \
56 A; \
57 } \
58 } while (0)
59} // namespace ds2
60
61#define CHK(C) CHK_ACTION(C, return CHK_error)
62#define CHKV(C) CHK_ACTION(C, return )