xref: /freebsd/contrib/processor-trace/libipt/src/pt_error.c (revision 4928135658a9d0eaee37003df6137ab363fcb0b4)
1 /*
2  * Copyright (c) 2013-2018, Intel Corporation
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions are met:
6  *
7  *  * Redistributions of source code must retain the above copyright notice,
8  *    this list of conditions and the following disclaimer.
9  *  * Redistributions in binary form must reproduce the above copyright notice,
10  *    this list of conditions and the following disclaimer in the documentation
11  *    and/or other materials provided with the distribution.
12  *  * Neither the name of Intel Corporation nor the names of its contributors
13  *    may be used to endorse or promote products derived from this software
14  *    without specific prior written permission.
15  *
16  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
17  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
20  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26  * POSSIBILITY OF SUCH DAMAGE.
27  */
28 
29 #include "intel-pt.h"
30 
31 
32 const char *pt_errstr(enum pt_error_code errcode)
33 {
34 	switch (errcode) {
35 	case pte_ok:
36 		return "OK";
37 
38 	case pte_internal:
39 		return "internal error";
40 
41 	case pte_invalid:
42 		return "invalid argument";
43 
44 	case pte_nosync:
45 		return "decoder out of sync";
46 
47 	case pte_bad_opc:
48 		return "unknown opcode";
49 
50 	case pte_bad_packet:
51 		return "unknown packet";
52 
53 	case pte_bad_context:
54 		return "unexpected packet context";
55 
56 	case pte_eos:
57 		return "reached end of trace stream";
58 
59 	case pte_bad_query:
60 		return "trace stream does not match query";
61 
62 	case pte_nomem:
63 		return "out of memory";
64 
65 	case pte_bad_config:
66 		return "bad configuration";
67 
68 	case pte_noip:
69 		return "no ip";
70 
71 	case pte_ip_suppressed:
72 		return "ip has been suppressed";
73 
74 	case pte_nomap:
75 		return "no memory mapped at this address";
76 
77 	case pte_bad_insn:
78 		return "unknown instruction";
79 
80 	case pte_no_time:
81 		return "no timing information";
82 
83 	case pte_no_cbr:
84 		return "no core:bus ratio";
85 
86 	case pte_bad_image:
87 		return "bad image";
88 
89 	case pte_bad_lock:
90 		return "locking error";
91 
92 	case pte_not_supported:
93 		return "not supported";
94 
95 	case pte_retstack_empty:
96 		return "compressed return without call";
97 
98 	case pte_bad_retcomp:
99 		return "bad compressed return";
100 
101 	case pte_bad_status_update:
102 		return "bad status update";
103 
104 	case pte_no_enable:
105 		return "expected tracing enabled event";
106 
107 	case pte_event_ignored:
108 		return "event ignored";
109 
110 	case pte_overflow:
111 		return "overflow";
112 
113 	case pte_bad_file:
114 		return "bad file";
115 
116 	case pte_bad_cpu:
117 		return "unknown cpu";
118 	}
119 
120 	/* Should not reach here. */
121 	return "internal error.";
122 }
123