Coverage Report

Created: 2026-11-11 06:34

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/rust/registry/src/index.crates.io-1949cf8c6b5b557f/pdb2-0.10.2/src/symbol/constants.rs
Line
Count
Source
1
// Copyright 2017 pdb Developers
2
//
3
// Licensed under the Apache License, Version 2.0, <LICENSE-APACHE or
4
// http://apache.org/licenses/LICENSE-2.0> or the MIT license <LICENSE-MIT or
5
// http://opensource.org/licenses/MIT>, at your option. This file may not be
6
// copied, modified, or distributed except according to those terms.
7
8
// A list of known symbol kinds.
9
// from:
10
//  https://github.com/Microsoft/microsoft-pdb/blob/082c5290e5aff028ae84e43affa8be717aa7af73/include/cvinfo.h#L2735
11
12
#![allow(unused, non_upper_case_globals, non_camel_case_types)]
13
14
use std::fmt;
15
16
use scroll::{ctx::TryFromCtx, Endian};
17
18
pub const S_COMPILE: u16 = 0x0001; // Compile flags symbol
19
pub const S_REGISTER_16T: u16 = 0x0002; // Register variable
20
pub const S_CONSTANT_16T: u16 = 0x0003; // constant symbol
21
pub const S_UDT_16T: u16 = 0x0004; // User defined type
22
pub const S_SSEARCH: u16 = 0x0005; // Start Search
23
pub const S_END: u16 = 0x0006; // Block procedure "with" or thunk end
24
pub const S_SKIP: u16 = 0x0007; // Reserve symbol space in $$Symbols table
25
pub const S_CVRESERVE: u16 = 0x0008; // Reserved symbol for CV internal use
26
pub const S_OBJNAME_ST: u16 = 0x0009; // path to object file name
27
pub const S_ENDARG: u16 = 0x000a; // end of argument/return list
28
pub const S_COBOLUDT_16T: u16 = 0x000b; // special UDT for cobol that does not symbol pack
29
pub const S_MANYREG_16T: u16 = 0x000c; // multiple register variable
30
pub const S_RETURN: u16 = 0x000d; // return description symbol
31
pub const S_ENTRYTHIS: u16 = 0x000e; // description of this pointer on entry
32
33
pub const S_BPREL16: u16 = 0x0100; // BP-relative
34
pub const S_LDATA16: u16 = 0x0101; // Module-local symbol
35
pub const S_GDATA16: u16 = 0x0102; // Global data symbol
36
pub const S_PUB16: u16 = 0x0103; // a public symbol
37
pub const S_LPROC16: u16 = 0x0104; // Local procedure start
38
pub const S_GPROC16: u16 = 0x0105; // Global procedure start
39
pub const S_THUNK16: u16 = 0x0106; // Thunk Start
40
pub const S_BLOCK16: u16 = 0x0107; // block start
41
pub const S_WITH16: u16 = 0x0108; // with start
42
pub const S_LABEL16: u16 = 0x0109; // code label
43
pub const S_CEXMODEL16: u16 = 0x010a; // change execution model
44
pub const S_VFTABLE16: u16 = 0x010b; // address of virtual function table
45
pub const S_REGREL16: u16 = 0x010c; // register relative address
46
47
pub const S_BPREL32_16T: u16 = 0x0200; // BP-relative
48
pub const S_LDATA32_16T: u16 = 0x0201; // Module-local symbol
49
pub const S_GDATA32_16T: u16 = 0x0202; // Global data symbol
50
pub const S_PUB32_16T: u16 = 0x0203; // a public symbol (CV internal reserved)
51
pub const S_LPROC32_16T: u16 = 0x0204; // Local procedure start
52
pub const S_GPROC32_16T: u16 = 0x0205; // Global procedure start
53
pub const S_THUNK32_ST: u16 = 0x0206; // Thunk Start
54
pub const S_BLOCK32_ST: u16 = 0x0207; // block start
55
pub const S_WITH32_ST: u16 = 0x0208; // with start
56
pub const S_LABEL32_ST: u16 = 0x0209; // code label
57
pub const S_CEXMODEL32: u16 = 0x020a; // change execution model
58
pub const S_VFTABLE32_16T: u16 = 0x020b; // address of virtual function table
59
pub const S_REGREL32_16T: u16 = 0x020c; // register relative address
60
pub const S_LTHREAD32_16T: u16 = 0x020d; // local thread storage
61
pub const S_GTHREAD32_16T: u16 = 0x020e; // global thread storage
62
pub const S_SLINK32: u16 = 0x020f; // static link for MIPS EH implementation
63
64
pub const S_LPROCMIPS_16T: u16 = 0x0300; // Local procedure start
65
pub const S_GPROCMIPS_16T: u16 = 0x0301; // Global procedure start
66
67
// if these ref symbols have names following then the names are in ST format
68
pub const S_PROCREF_ST: u16 = 0x0400; // Reference to a procedure
69
pub const S_DATAREF_ST: u16 = 0x0401; // Reference to data
70
pub const S_ALIGN: u16 = 0x0402; // Used for page alignment of symbols
71
72
pub const S_LPROCREF_ST: u16 = 0x0403; // Local Reference to a procedure
73
pub const S_OEM: u16 = 0x0404; // OEM defined symbol
74
75
// sym records with 32-bit types embedded instead of 16-bit
76
// all have 0x1000 bit set for easy identification
77
// only do the 32-bit target versions since we don't really
78
// care about 16-bit ones anymore.
79
pub const S_TI16_MAX: u16 = 0x1000;
80
81
pub const S_REGISTER_ST: u16 = 0x1001; // Register variable
82
pub const S_CONSTANT_ST: u16 = 0x1002; // constant symbol
83
pub const S_UDT_ST: u16 = 0x1003; // User defined type
84
pub const S_COBOLUDT_ST: u16 = 0x1004; // special UDT for cobol that does not symbol pack
85
pub const S_MANYREG_ST: u16 = 0x1005; // multiple register variable
86
pub const S_BPREL32_ST: u16 = 0x1006; // BP-relative
87
pub const S_LDATA32_ST: u16 = 0x1007; // Module-local symbol
88
pub const S_GDATA32_ST: u16 = 0x1008; // Global data symbol
89
pub const S_PUB32_ST: u16 = 0x1009; // a public symbol (CV internal reserved)
90
pub const S_LPROC32_ST: u16 = 0x100a; // Local procedure start
91
pub const S_GPROC32_ST: u16 = 0x100b; // Global procedure start
92
pub const S_VFTABLE32: u16 = 0x100c; // address of virtual function table
93
pub const S_REGREL32_ST: u16 = 0x100d; // register relative address
94
pub const S_LTHREAD32_ST: u16 = 0x100e; // local thread storage
95
pub const S_GTHREAD32_ST: u16 = 0x100f; // global thread storage
96
97
pub const S_LPROCMIPS_ST: u16 = 0x1010; // Local procedure start
98
pub const S_GPROCMIPS_ST: u16 = 0x1011; // Global procedure start
99
100
pub const S_FRAMEPROC: u16 = 0x1012; // extra frame and proc information
101
pub const S_COMPILE2_ST: u16 = 0x1013; // extended compile flags and info
102
103
// new symbols necessary for 16-bit enumerates of IA64 registers
104
// and IA64 specific symbols
105
106
pub const S_MANYREG2_ST: u16 = 0x1014; // multiple register variable
107
pub const S_LPROCIA64_ST: u16 = 0x1015; // Local procedure start (IA64)
108
pub const S_GPROCIA64_ST: u16 = 0x1016; // Global procedure start (IA64)
109
110
// Local symbols for IL
111
pub const S_LOCALSLOT_ST: u16 = 0x1017; // local IL sym with field for local slot index
112
pub const S_PARAMSLOT_ST: u16 = 0x1018; // local IL sym with field for parameter slot index
113
114
pub const S_ANNOTATION: u16 = 0x1019; // Annotation string literals
115
116
// symbols to support managed code debugging
117
pub const S_GMANPROC_ST: u16 = 0x101a; // Global proc
118
pub const S_LMANPROC_ST: u16 = 0x101b; // Local proc
119
pub const S_RESERVED1: u16 = 0x101c; // reserved
120
pub const S_RESERVED2: u16 = 0x101d; // reserved
121
pub const S_RESERVED3: u16 = 0x101e; // reserved
122
pub const S_RESERVED4: u16 = 0x101f; // reserved
123
pub const S_LMANDATA_ST: u16 = 0x1020;
124
pub const S_GMANDATA_ST: u16 = 0x1021;
125
pub const S_MANFRAMEREL_ST: u16 = 0x1022;
126
pub const S_MANREGISTER_ST: u16 = 0x1023;
127
pub const S_MANSLOT_ST: u16 = 0x1024;
128
pub const S_MANMANYREG_ST: u16 = 0x1025;
129
pub const S_MANREGREL_ST: u16 = 0x1026;
130
pub const S_MANMANYREG2_ST: u16 = 0x1027;
131
pub const S_MANTYPREF: u16 = 0x1028; // Index for type referenced by name from metadata
132
pub const S_UNAMESPACE_ST: u16 = 0x1029; // Using namespace
133
134
// Symbols w/ SZ name fields. All name fields contain utf8 encoded strings.
135
pub const S_ST_MAX: u16 = 0x1100; // starting point for SZ name symbols
136
137
pub const S_OBJNAME: u16 = 0x1101; // path to object file name
138
pub const S_THUNK32: u16 = 0x1102; // Thunk Start
139
pub const S_BLOCK32: u16 = 0x1103; // block start
140
pub const S_WITH32: u16 = 0x1104; // with start
141
pub const S_LABEL32: u16 = 0x1105; // code label
142
pub const S_REGISTER: u16 = 0x1106; // Register variable
143
pub const S_CONSTANT: u16 = 0x1107; // constant symbol
144
pub const S_UDT: u16 = 0x1108; // User defined type
145
pub const S_COBOLUDT: u16 = 0x1109; // special UDT for cobol that does not symbol pack
146
pub const S_MANYREG: u16 = 0x110a; // multiple register variable
147
pub const S_BPREL32: u16 = 0x110b; // BP-relative
148
pub const S_LDATA32: u16 = 0x110c; // Module-local symbol
149
pub const S_GDATA32: u16 = 0x110d; // Global data symbol
150
pub const S_PUB32: u16 = 0x110e; // a public symbol (CV internal reserved)
151
pub const S_LPROC32: u16 = 0x110f; // Local procedure start
152
pub const S_GPROC32: u16 = 0x1110; // Global procedure start
153
pub const S_REGREL32: u16 = 0x1111; // register relative address
154
pub const S_LTHREAD32: u16 = 0x1112; // local thread storage
155
pub const S_GTHREAD32: u16 = 0x1113; // global thread storage
156
157
pub const S_LPROCMIPS: u16 = 0x1114; // Local procedure start
158
pub const S_GPROCMIPS: u16 = 0x1115; // Global procedure start
159
pub const S_COMPILE2: u16 = 0x1116; // extended compile flags and info
160
pub const S_MANYREG2: u16 = 0x1117; // multiple register variable
161
pub const S_LPROCIA64: u16 = 0x1118; // Local procedure start (IA64)
162
pub const S_GPROCIA64: u16 = 0x1119; // Global procedure start (IA64)
163
pub const S_LOCALSLOT: u16 = 0x111a; // local IL sym with field for local slot index
164
pub const S_PARAMSLOT: u16 = 0x111b; // local IL sym with field for parameter slot index
165
166
// symbols to support managed code debugging
167
pub const S_LMANDATA: u16 = 0x111c;
168
pub const S_GMANDATA: u16 = 0x111d;
169
pub const S_MANFRAMEREL: u16 = 0x111e;
170
pub const S_MANREGISTER: u16 = 0x111f;
171
pub const S_MANSLOT: u16 = 0x1120;
172
pub const S_MANMANYREG: u16 = 0x1121;
173
pub const S_MANREGREL: u16 = 0x1122;
174
pub const S_MANMANYREG2: u16 = 0x1123;
175
pub const S_UNAMESPACE: u16 = 0x1124; // Using namespace
176
177
// ref symbols with name fields
178
pub const S_PROCREF: u16 = 0x1125; // Reference to a procedure
179
pub const S_DATAREF: u16 = 0x1126; // Reference to data
180
pub const S_LPROCREF: u16 = 0x1127; // Local Reference to a procedure
181
pub const S_ANNOTATIONREF: u16 = 0x1128; // Reference to an S_ANNOTATION symbol
182
pub const S_TOKENREF: u16 = 0x1129; // Reference to one of the many MANPROCSYM's
183
184
// continuation of managed symbols
185
pub const S_GMANPROC: u16 = 0x112a; // Global proc
186
pub const S_LMANPROC: u16 = 0x112b; // Local proc
187
188
// short light-weight thunks
189
pub const S_TRAMPOLINE: u16 = 0x112c; // trampoline thunks
190
pub const S_MANCONSTANT: u16 = 0x112d; // constants with metadata type info
191
192
// native attributed local/parms
193
pub const S_ATTR_FRAMEREL: u16 = 0x112e; // relative to virtual frame ptr
194
pub const S_ATTR_REGISTER: u16 = 0x112f; // stored in a register
195
pub const S_ATTR_REGREL: u16 = 0x1130; // relative to register (alternate frame ptr)
196
pub const S_ATTR_MANYREG: u16 = 0x1131; // stored in >1 register
197
198
// Separated code (from the compiler) support
199
pub const S_SEPCODE: u16 = 0x1132;
200
201
pub const S_LOCAL_2005: u16 = 0x1133; // defines a local symbol in optimized code
202
pub const S_DEFRANGE_2005: u16 = 0x1134; // defines a single range of addresses in which symbol can be evaluated
203
pub const S_DEFRANGE2_2005: u16 = 0x1135; // defines ranges of addresses in which symbol can be evaluated
204
205
pub const S_SECTION: u16 = 0x1136; // A COFF section in a PE executable
206
pub const S_COFFGROUP: u16 = 0x1137; // A COFF group
207
pub const S_EXPORT: u16 = 0x1138; // A export
208
209
pub const S_CALLSITEINFO: u16 = 0x1139; // Indirect call site information
210
pub const S_FRAMECOOKIE: u16 = 0x113a; // Security cookie information
211
212
pub const S_DISCARDED: u16 = 0x113b; // Discarded by LINK /OPT:REF (experimental see richards)
213
214
pub const S_COMPILE3: u16 = 0x113c; // Replacement for S_COMPILE2
215
pub const S_ENVBLOCK: u16 = 0x113d; // Environment block split off from S_COMPILE2
216
217
pub const S_LOCAL: u16 = 0x113e; // defines a local symbol in optimized code
218
pub const S_DEFRANGE: u16 = 0x113f; // defines a single range of addresses in which symbol can be evaluated
219
pub const S_DEFRANGE_SUBFIELD: u16 = 0x1140; // ranges for a subfield
220
221
pub const S_DEFRANGE_REGISTER: u16 = 0x1141; // ranges for en-registered symbol
222
pub const S_DEFRANGE_FRAMEPOINTER_REL: u16 = 0x1142; // range for stack symbol.
223
pub const S_DEFRANGE_SUBFIELD_REGISTER: u16 = 0x1143; // ranges for en-registered field of symbol
224
pub const S_DEFRANGE_FRAMEPOINTER_REL_FULL_SCOPE: u16 = 0x1144; // range for stack symbol span valid full scope of function body gap might apply.
225
pub const S_DEFRANGE_REGISTER_REL: u16 = 0x1145; // range for symbol address as register + offset.
226
227
// S_PROC symbols that reference ID instead of type
228
pub const S_LPROC32_ID: u16 = 0x1146;
229
pub const S_GPROC32_ID: u16 = 0x1147;
230
pub const S_LPROCMIPS_ID: u16 = 0x1148;
231
pub const S_GPROCMIPS_ID: u16 = 0x1149;
232
pub const S_LPROCIA64_ID: u16 = 0x114a;
233
pub const S_GPROCIA64_ID: u16 = 0x114b;
234
235
pub const S_BUILDINFO: u16 = 0x114c; // build information.
236
pub const S_INLINESITE: u16 = 0x114d; // inlined function callsite.
237
pub const S_INLINESITE_END: u16 = 0x114e;
238
pub const S_PROC_ID_END: u16 = 0x114f;
239
240
pub const S_DEFRANGE_HLSL: u16 = 0x1150;
241
pub const S_GDATA_HLSL: u16 = 0x1151;
242
pub const S_LDATA_HLSL: u16 = 0x1152;
243
244
pub const S_FILESTATIC: u16 = 0x1153;
245
246
pub const S_LOCAL_DPC_GROUPSHARED: u16 = 0x1154; // DPC groupshared variable
247
pub const S_LPROC32_DPC: u16 = 0x1155; // DPC local procedure start
248
pub const S_LPROC32_DPC_ID: u16 = 0x1156;
249
pub const S_DEFRANGE_DPC_PTR_TAG: u16 = 0x1157; // DPC pointer tag definition range
250
pub const S_DPC_SYM_TAG_MAP: u16 = 0x1158; // DPC pointer tag value to symbol record map
251
252
pub const S_ARMSWITCHTABLE: u16 = 0x1159;
253
pub const S_CALLEES: u16 = 0x115a;
254
pub const S_CALLERS: u16 = 0x115b;
255
pub const S_POGODATA: u16 = 0x115c;
256
pub const S_INLINESITE2: u16 = 0x115d; // extended inline site information
257
258
pub const S_HEAPALLOCSITE: u16 = 0x115e; // heap allocation site
259
260
pub const S_MOD_TYPEREF: u16 = 0x115f; // only generated at link time
261
262
pub const S_REF_MINIPDB: u16 = 0x1160; // only generated at link time for mini PDB
263
pub const S_PDBMAP: u16 = 0x1161; // only generated at link time for mini PDB
264
265
pub const S_GDATA_HLSL32: u16 = 0x1162;
266
pub const S_LDATA_HLSL32: u16 = 0x1163;
267
268
pub const S_GDATA_HLSL32_EX: u16 = 0x1164;
269
pub const S_LDATA_HLSL32_EX: u16 = 0x1165;
270
271
pub const S_FASTLINK: u16 = 0x1167; // generated at link time for /DEBUG:FASTLINK
272
pub const S_INLINEES: u16 = 0x1168;
273
274
pub const S_HOTPATCHFUNC: u16 = 0x1169;
275
276
pub const S_BPREL32_INDIR: u16 = 0x1170;
277
pub const S_REGREL32_INDIR: u16 = 0x1171;
278
279
pub const S_GPROC32EX: u16 = 0x1172;
280
pub const S_LPROC32EX: u16 = 0x1173;
281
pub const S_GPROC32EX_ID: u16 = 0x1174;
282
pub const S_LPROC32EX_ID: u16 = 0x1175;
283
284
pub const S_STATICLOCAL: u16 = 0x1176;
285
286
pub const S_DEFRANGE_REGISTER_REL_INDIR: u16 = 0x1177;
287
288
pub const S_RECTYPE_MAX: u16 = 0x1178;
289
pub const S_RECTYPE_PAD: u16 = 0x1278;
290
291
/// These values correspond to the `CV_CPU_TYPE_e` enumeration, and are documented
292
/// [on MSDN](https://msdn.microsoft.com/en-us/library/b2fc64ek.aspx).
293
#[non_exhaustive]
294
#[allow(missing_docs)]
295
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
296
pub enum CPUType {
297
    Intel8080 = 0x0,
298
    Intel8086 = 0x1,
299
    Intel80286 = 0x2,
300
    Intel80386 = 0x3,
301
    Intel80486 = 0x4,
302
    Pentium = 0x5,
303
    PentiumPro = 0x6,
304
    Pentium3 = 0x7,
305
    MIPS = 0x10,
306
    MIPS16 = 0x11,
307
    MIPS32 = 0x12,
308
    MIPS64 = 0x13,
309
    MIPSI = 0x14,
310
    MIPSII = 0x15,
311
    MIPSIII = 0x16,
312
    MIPSIV = 0x17,
313
    MIPSV = 0x18,
314
    M68000 = 0x20,
315
    M68010 = 0x21,
316
    M68020 = 0x22,
317
    M68030 = 0x23,
318
    M68040 = 0x24,
319
    Alpha = 0x30,
320
    Alpha21164 = 0x31,
321
    Alpha21164A = 0x32,
322
    Alpha21264 = 0x33,
323
    Alpha21364 = 0x34,
324
    PPC601 = 0x40,
325
    PPC603 = 0x41,
326
    PPC604 = 0x42,
327
    PPC620 = 0x43,
328
    PPCFP = 0x44,
329
    PPCBE = 0x45,
330
    SH3 = 0x50,
331
    SH3E = 0x51,
332
    SH3DSP = 0x52,
333
    SH4 = 0x53,
334
    SHMedia = 0x54,
335
    ARM3 = 0x60,
336
    ARM4 = 0x61,
337
    ARM4T = 0x62,
338
    ARM5 = 0x63,
339
    ARM5T = 0x64,
340
    ARM6 = 0x65,
341
    ARM_XMAC = 0x66,
342
    ARM_WMMX = 0x67,
343
    ARM7 = 0x68,
344
    ARM64 = 0x69,
345
    Omni = 0x70,
346
    Ia64 = 0x80,
347
    Ia64_2 = 0x81,
348
    CEE = 0x90,
349
    AM33 = 0xa0,
350
    M32R = 0xb0,
351
    TriCore = 0xc0,
352
    X64 = 0xd0,
353
    EBC = 0xe0,
354
    Thumb = 0xf0,
355
    ARMNT = 0xf4,
356
    D3D11_Shader = 0x100,
357
}
358
359
impl fmt::Display for CPUType {
360
0
    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
361
0
        match self {
362
0
            Self::Intel8080 => write!(f, "Intel8080"),
363
0
            Self::Intel8086 => write!(f, "Intel8086"),
364
0
            Self::Intel80286 => write!(f, "Intel80286"),
365
0
            Self::Intel80386 => write!(f, "Intel80386"),
366
0
            Self::Intel80486 => write!(f, "Intel80486"),
367
0
            Self::Pentium => write!(f, "Pentium"),
368
0
            Self::PentiumPro => write!(f, "PentiumPro"),
369
0
            Self::Pentium3 => write!(f, "Pentium3"),
370
0
            Self::MIPS => write!(f, "MIPS"),
371
0
            Self::MIPS16 => write!(f, "MIPS16"),
372
0
            Self::MIPS32 => write!(f, "MIPS32"),
373
0
            Self::MIPS64 => write!(f, "MIPS64"),
374
0
            Self::MIPSI => write!(f, "MIPSI"),
375
0
            Self::MIPSII => write!(f, "MIPSII"),
376
0
            Self::MIPSIII => write!(f, "MIPSIII"),
377
0
            Self::MIPSIV => write!(f, "MIPSIV"),
378
0
            Self::MIPSV => write!(f, "MIPSV"),
379
0
            Self::M68000 => write!(f, "M68000"),
380
0
            Self::M68010 => write!(f, "M68010"),
381
0
            Self::M68020 => write!(f, "M68020"),
382
0
            Self::M68030 => write!(f, "M68030"),
383
0
            Self::M68040 => write!(f, "M68040"),
384
0
            Self::Alpha => write!(f, "Alpha"),
385
0
            Self::Alpha21164 => write!(f, "Alpha21164"),
386
0
            Self::Alpha21164A => write!(f, "Alpha21164A"),
387
0
            Self::Alpha21264 => write!(f, "Alpha21264"),
388
0
            Self::Alpha21364 => write!(f, "Alpha21364"),
389
0
            Self::PPC601 => write!(f, "PPC601"),
390
0
            Self::PPC603 => write!(f, "PPC603"),
391
0
            Self::PPC604 => write!(f, "PPC604"),
392
0
            Self::PPC620 => write!(f, "PPC620"),
393
0
            Self::PPCFP => write!(f, "PPCFP"),
394
0
            Self::PPCBE => write!(f, "PPCBE"),
395
0
            Self::SH3 => write!(f, "SH3"),
396
0
            Self::SH3E => write!(f, "SH3E"),
397
0
            Self::SH3DSP => write!(f, "SH3DSP"),
398
0
            Self::SH4 => write!(f, "SH4"),
399
0
            Self::SHMedia => write!(f, "SHMedia"),
400
0
            Self::ARM3 => write!(f, "ARM3"),
401
0
            Self::ARM4 => write!(f, "ARM4"),
402
0
            Self::ARM4T => write!(f, "ARM4T"),
403
0
            Self::ARM5 => write!(f, "ARM5"),
404
0
            Self::ARM5T => write!(f, "ARM5T"),
405
0
            Self::ARM6 => write!(f, "ARM6"),
406
0
            Self::ARM_XMAC => write!(f, "ARM_XMAC"),
407
0
            Self::ARM_WMMX => write!(f, "ARM_WMMX"),
408
0
            Self::ARM7 => write!(f, "ARM7"),
409
0
            Self::ARM64 => write!(f, "ARM64"),
410
0
            Self::Omni => write!(f, "Omni"),
411
0
            Self::Ia64 => write!(f, "Ia64"),
412
0
            Self::Ia64_2 => write!(f, "Ia64_2"),
413
0
            Self::CEE => write!(f, "CEE"),
414
0
            Self::AM33 => write!(f, "AM33"),
415
0
            Self::M32R => write!(f, "M32R"),
416
0
            Self::TriCore => write!(f, "TriCore"),
417
0
            Self::X64 => write!(f, "X64"),
418
0
            Self::EBC => write!(f, "EBC"),
419
0
            Self::Thumb => write!(f, "Thumb"),
420
0
            Self::ARMNT => write!(f, "ARMNT"),
421
0
            Self::D3D11_Shader => write!(f, "D3D11_Shader"),
422
        }
423
0
    }
424
}
425
426
impl From<u16> for CPUType {
427
49.0k
    fn from(value: u16) -> Self {
428
49.0k
        match value {
429
0
            0x0 => Self::Intel8080,
430
0
            0x1 => Self::Intel8086,
431
0
            0x2 => Self::Intel80286,
432
33.0k
            0x3 => Self::Intel80386,
433
0
            0x4 => Self::Intel80486,
434
0
            0x5 => Self::Pentium,
435
236
            0x6 => Self::PentiumPro,
436
14.9k
            0x7 => Self::Pentium3,
437
0
            0x10 => Self::MIPS,
438
0
            0x11 => Self::MIPS16,
439
0
            0x12 => Self::MIPS32,
440
0
            0x13 => Self::MIPS64,
441
0
            0x14 => Self::MIPSI,
442
0
            0x15 => Self::MIPSII,
443
0
            0x16 => Self::MIPSIII,
444
0
            0x17 => Self::MIPSIV,
445
0
            0x18 => Self::MIPSV,
446
0
            0x20 => Self::M68000,
447
0
            0x21 => Self::M68010,
448
0
            0x22 => Self::M68020,
449
0
            0x23 => Self::M68030,
450
0
            0x24 => Self::M68040,
451
0
            0x30 => Self::Alpha,
452
0
            0x31 => Self::Alpha21164,
453
0
            0x32 => Self::Alpha21164A,
454
0
            0x33 => Self::Alpha21264,
455
0
            0x34 => Self::Alpha21364,
456
0
            0x40 => Self::PPC601,
457
0
            0x41 => Self::PPC603,
458
0
            0x42 => Self::PPC604,
459
0
            0x43 => Self::PPC620,
460
0
            0x44 => Self::PPCFP,
461
0
            0x45 => Self::PPCBE,
462
0
            0x50 => Self::SH3,
463
0
            0x51 => Self::SH3E,
464
0
            0x52 => Self::SH3DSP,
465
0
            0x53 => Self::SH4,
466
0
            0x54 => Self::SHMedia,
467
0
            0x60 => Self::ARM3,
468
0
            0x61 => Self::ARM4,
469
0
            0x62 => Self::ARM4T,
470
0
            0x63 => Self::ARM5,
471
0
            0x64 => Self::ARM5T,
472
0
            0x65 => Self::ARM6,
473
0
            0x66 => Self::ARM_XMAC,
474
0
            0x67 => Self::ARM_WMMX,
475
0
            0x68 => Self::ARM7,
476
0
            0x69 => Self::ARM64,
477
0
            0x70 => Self::Omni,
478
0
            0x80 => Self::Ia64,
479
0
            0x81 => Self::Ia64_2,
480
0
            0x90 => Self::CEE,
481
0
            0xa0 => Self::AM33,
482
0
            0xb0 => Self::M32R,
483
0
            0xc0 => Self::TriCore,
484
763
            0xd0 => Self::X64,
485
0
            0xe0 => Self::EBC,
486
0
            0xf0 => Self::Thumb,
487
0
            0xf4 => Self::ARMNT,
488
0
            0x100 => Self::D3D11_Shader,
489
0
            _ => Self::Intel8080, // This enum doesn't have an unknown value, so we just force it to Intel8080 since it's 0x0.
490
        }
491
49.0k
    }
492
}
493
494
impl<'a> TryFromCtx<'a, Endian> for CPUType {
495
    type Error = scroll::Error;
496
497
49.0k
    fn try_from_ctx(this: &'a [u8], le: Endian) -> scroll::Result<(Self, usize)> {
498
49.0k
        u16::try_from_ctx(this, le).map(|(v, l)| (v.into(), l))
499
49.0k
    }
500
}
501
502
/// These values correspond to the `CV_CFL_LANG` enumeration, and are documented
503
/// [on MSDN](https://learn.microsoft.com/en-us/visualstudio/debugger/debug-interface-access/cv-cfl-lang?view=vs-2022).
504
#[non_exhaustive]
505
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
506
pub enum SourceLanguage {
507
    /// Application language is C.
508
    C = 0x00,
509
    /// Application language is C++.
510
    Cpp = 0x01,
511
    /// Application language is FORTRAN.
512
    Fortran = 0x02,
513
    /// Application language is Microsoft Macro Assembler.
514
    Masm = 0x03,
515
    /// Application language is Pascal.
516
    Pascal = 0x04,
517
    /// Application language is BASIC.
518
    Basic = 0x05,
519
    /// Application language is COBOL.
520
    Cobol = 0x06,
521
    /// Application is a linker-generated module.
522
    Link = 0x07,
523
    /// Application is a resource module converted with CVTRES tool.
524
    Cvtres = 0x08,
525
    /// Application is a POGO optimized module generated with CVTPGD tool.
526
    Cvtpgd = 0x09,
527
    /// Application language is C#.
528
    CSharp = 0x0a,
529
    /// Application language is Visual Basic.
530
    VB = 0x0b,
531
    /// Application language is intermediate language assembly (that is, Common Language Runtime
532
    /// (CLR) assembly).
533
    ILAsm = 0x0c,
534
    /// Application language is Java.
535
    Java = 0x0d,
536
    /// Application language is Jscript.
537
    JScript = 0x0e,
538
    /// Application language is an unknown Microsoft Intermediate Language (MSIL), possibly a result
539
    /// of using the [/LTCG (Link-time Code
540
    /// Generation)](https://docs.microsoft.com/en-us/cpp/build/reference/ltcg-link-time-code-generation)
541
    /// switch.
542
    MSIL = 0x0f,
543
    /// Application language is High Level Shader Language.
544
    HLSL = 0x10,
545
    /// Application language is Objective-C.
546
    ObjC = 0x11,
547
    /// Application language is Objective-C++.
548
    ObjCXX = 0x12,
549
    /// Application language is Swift.
550
    Swift = 0x13,
551
    /// Application is a module generated by the aliasobj tool.
552
    AliasObj = 0x14,
553
    /// Application language is Rust.
554
    Rust = 0x15,
555
    /// Application language is Go.
556
    Go = 0x16,
557
    /// The DMD compiler emits 'D' for the CV source language. Microsoft doesn't
558
    /// have an enumerator for it yet.
559
    D = 0x44,
560
}
561
562
impl fmt::Display for SourceLanguage {
563
0
    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
564
0
        let str_repr = match self {
565
0
            Self::C => "C",
566
0
            Self::Cpp => "Cpp",
567
0
            Self::Fortran => "Fortran",
568
0
            Self::Masm => "Masm",
569
0
            Self::Pascal => "Pascal",
570
0
            Self::Basic => "Basic",
571
0
            Self::Cobol => "Cobol",
572
0
            Self::Link => "Link",
573
0
            Self::Cvtres => "Cvtres",
574
0
            Self::Cvtpgd => "Cvtpgd",
575
0
            Self::CSharp => "CSharp",
576
0
            Self::VB => "VB",
577
0
            Self::ILAsm => "ILAsm",
578
0
            Self::Java => "Java",
579
0
            Self::JScript => "JScript",
580
0
            Self::MSIL => "MSIL",
581
0
            Self::HLSL => "HLSL",
582
0
            Self::ObjC => "ObjC",
583
0
            Self::ObjCXX => "ObjCXX",
584
0
            Self::Swift => "Swift",
585
0
            Self::AliasObj => "AliasObj",
586
0
            Self::Rust => "Rust",
587
0
            Self::Go => "Go",
588
0
            Self::D => "D",
589
        };
590
591
0
        write!(f, "{str_repr}")
592
0
    }
593
}
594
595
impl From<u8> for SourceLanguage {
596
49.0k
    fn from(value: u8) -> Self {
597
49.0k
        match value {
598
3.25k
            0x00 => Self::C,
599
8.17k
            0x01 => Self::Cpp,
600
0
            0x02 => Self::Fortran,
601
248
            0x03 => Self::Masm,
602
0
            0x04 => Self::Pascal,
603
0
            0x05 => Self::Basic,
604
0
            0x06 => Self::Cobol,
605
37.0k
            0x07 => Self::Link,
606
275
            0x08 => Self::Cvtres,
607
0
            0x09 => Self::Cvtpgd,
608
0
            0x0a => Self::CSharp,
609
0
            0x0b => Self::VB,
610
0
            0x0c => Self::ILAsm,
611
0
            0x0d => Self::Java,
612
0
            0x0e => Self::JScript,
613
0
            0x0f => Self::MSIL,
614
0
            0x10 => Self::HLSL,
615
0
            0x11 => Self::ObjC,
616
0
            0x12 => Self::ObjCXX,
617
0
            0x13 => Self::Swift,
618
0
            0x14 => Self::AliasObj,
619
0
            0x15 => Self::Rust,
620
0
            0x16 => Self::Go,
621
0
            0x44 => Self::D,
622
0
            _ => Self::Masm, // There is no unknown, so we just force to Masm as the default.
623
        }
624
49.0k
    }
625
}
626
627
impl<'a> TryFromCtx<'a, Endian> for SourceLanguage {
628
    type Error = scroll::Error;
629
630
49.0k
    fn try_from_ctx(this: &'a [u8], le: Endian) -> scroll::Result<(Self, usize)> {
631
49.0k
        u8::try_from_ctx(this, le).map(|(v, l)| (v.into(), l))
632
49.0k
    }
633
}