authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2018-09-12 14:26:21-04:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2018-09-12 14:26:21-04:00
loga75753338657b85588fe6c54a40fecac0584b336
tree9d0e1f367a172d04284b808c629394b4e45d7a98
parent178d69191ba008dffd70d2854df09cec556b59dd

fix zig fmt on windows

closes #1069

10 files changed, 161 insertions(+), 120 deletions(-)

std/coff.zig+23-29
......@@ -8,9 +8,9 @@ const ArrayList = std.ArrayList;
88
99// CoffHeader.machine values
1010// see https://msdn.microsoft.com/en-us/library/windows/desktop/ms680313(v=vs.85).aspx
11const IMAGE_FILE_MACHINE_I386 = 0x014c;
12const IMAGE_FILE_MACHINE_IA64 = 0x0200;
13const IMAGE_FILE_MACHINE_AMD64 = 0x8664;
11const IMAGE_FILE_MACHINE_I386 = 0x014c;
12const IMAGE_FILE_MACHINE_IA64 = 0x0200;
13const IMAGE_FILE_MACHINE_AMD64 = 0x8664;
1414
1515// OptionalHeader.magic values
1616// see https://msdn.microsoft.com/en-us/library/windows/desktop/ms680339(v=vs.85).aspx
......@@ -20,7 +20,7 @@ const IMAGE_NT_OPTIONAL_HDR64_MAGIC = 0x20b;
2020const IMAGE_NUMBEROF_DIRECTORY_ENTRIES = 16;
2121const DEBUG_DIRECTORY = 6;
2222
23pub const CoffError = error {
23pub const CoffError = error{
2424 InvalidPEMagic,
2525 InvalidPEHeader,
2626 InvalidMachine,
......@@ -56,24 +56,21 @@ pub const Coff = struct {
5656
5757 var pe_header_magic: [4]u8 = undefined;
5858 try in.readNoEof(pe_header_magic[0..]);
59 if (!mem.eql(u8, pe_header_magic, []u8{'P', 'E', 0, 0}))
59 if (!mem.eql(u8, pe_header_magic, []u8{ 'P', 'E', 0, 0 }))
6060 return error.InvalidPEHeader;
6161
62 self.coff_header = CoffHeader {
62 self.coff_header = CoffHeader{
6363 .machine = try in.readIntLe(u16),
64 .number_of_sections = try in.readIntLe(u16),
65 .timedate_stamp = try in.readIntLe(u32),
66 .pointer_to_symbol_table = try in.readIntLe(u32),
67 .number_of_symbols = try in.readIntLe(u32),
68 .size_of_optional_header = try in.readIntLe(u16),
69 .characteristics = try in.readIntLe(u16),
64 .number_of_sections = try in.readIntLe(u16),
65 .timedate_stamp = try in.readIntLe(u32),
66 .pointer_to_symbol_table = try in.readIntLe(u32),
67 .number_of_symbols = try in.readIntLe(u32),
68 .size_of_optional_header = try in.readIntLe(u16),
69 .characteristics = try in.readIntLe(u16),
7070 };
7171
7272 switch (self.coff_header.machine) {
73 IMAGE_FILE_MACHINE_I386,
74 IMAGE_FILE_MACHINE_AMD64,
75 IMAGE_FILE_MACHINE_IA64
76 => {},
73 IMAGE_FILE_MACHINE_I386, IMAGE_FILE_MACHINE_AMD64, IMAGE_FILE_MACHINE_IA64 => {},
7774 else => return error.InvalidMachine,
7875 }
7976
......@@ -89,11 +86,9 @@ pub const Coff = struct {
8986 var skip_size: u16 = undefined;
9087 if (self.pe_header.magic == IMAGE_NT_OPTIONAL_HDR32_MAGIC) {
9188 skip_size = 2 * @sizeOf(u8) + 8 * @sizeOf(u16) + 18 * @sizeOf(u32);
92 }
93 else if (self.pe_header.magic == IMAGE_NT_OPTIONAL_HDR64_MAGIC) {
89 } else if (self.pe_header.magic == IMAGE_NT_OPTIONAL_HDR64_MAGIC) {
9490 skip_size = 2 * @sizeOf(u8) + 8 * @sizeOf(u16) + 12 * @sizeOf(u32) + 5 * @sizeOf(u64);
95 }
96 else
91 } else
9792 return error.InvalidPEMagic;
9893
9994 try self.in_file.seekForward(skip_size);
......@@ -103,7 +98,7 @@ pub const Coff = struct {
10398 return error.InvalidPEHeader;
10499
105100 for (self.pe_header.data_directory) |*data_dir| {
106 data_dir.* = OptionalHeader.DataDirectory {
101 data_dir.* = OptionalHeader.DataDirectory{
107102 .virtual_address = try in.readIntLe(u32),
108103 .size = try in.readIntLe(u32),
109104 };
......@@ -114,7 +109,7 @@ pub const Coff = struct {
114109 try self.loadSections();
115110 const header = (self.getSection(".rdata") orelse return error.MissingCoffSection).header;
116111
117 // The linker puts a chunk that contains the .pdb path right after the
112 // The linker puts a chunk that contains the .pdb path right after the
118113 // debug_directory.
119114 const debug_dir = &self.pe_header.data_directory[DEBUG_DIRECTORY];
120115 const file_offset = debug_dir.virtual_address - header.virtual_address + header.pointer_to_raw_data;
......@@ -159,10 +154,10 @@ pub const Coff = struct {
159154 var i: u16 = 0;
160155 while (i < self.coff_header.number_of_sections) : (i += 1) {
161156 try in.readNoEof(name[0..]);
162 try self.sections.append(Section {
163 .header = SectionHeader {
157 try self.sections.append(Section{
158 .header = SectionHeader{
164159 .name = name,
165 .misc = SectionHeader.Misc { .physical_address = try in.readIntLe(u32) },
160 .misc = SectionHeader.Misc{ .physical_address = try in.readIntLe(u32) },
166161 .virtual_address = try in.readIntLe(u32),
167162 .size_of_raw_data = try in.readIntLe(u32),
168163 .pointer_to_raw_data = try in.readIntLe(u32),
......@@ -184,7 +179,6 @@ pub const Coff = struct {
184179 }
185180 return null;
186181 }
187
188182};
189183
190184const CoffHeader = struct {
......@@ -194,13 +188,13 @@ const CoffHeader = struct {
194188 pointer_to_symbol_table: u32,
195189 number_of_symbols: u32,
196190 size_of_optional_header: u16,
197 characteristics: u16
191 characteristics: u16,
198192};
199193
200194const OptionalHeader = struct {
201195 const DataDirectory = struct {
202196 virtual_address: u32,
203 size: u32
197 size: u32,
204198 };
205199
206200 magic: u16,
......@@ -214,7 +208,7 @@ pub const Section = struct {
214208const SectionHeader = struct {
215209 const Misc = union {
216210 physical_address: u32,
217 virtual_size: u32
211 virtual_size: u32,
218212 };
219213
220214 name: [8]u8,
std/crypto/x25519.zig+1-1
......@@ -115,7 +115,7 @@ pub const X25519 = struct {
115115 return !zerocmp(u8, out);
116116 }
117117
118 pub fn createPublicKey(public_key: [] u8, private_key: []const u8) bool {
118 pub fn createPublicKey(public_key: []u8, private_key: []const u8) bool {
119119 var base_point = []u8{9} ++ []u8{0} ** 31;
120120 return create(public_key, private_key, base_point);
121121 }
std/debug/index.zig+12-11
......@@ -242,9 +242,12 @@ pub fn writeCurrentStackTrace(out_stream: var, debug_info: *DebugInfo, tty_color
242242 }
243243}
244244
245pub fn writeCurrentStackTraceWindows(out_stream: var, debug_info: *DebugInfo,
246 tty_color: bool, start_addr: ?usize) !void
247{
245pub fn writeCurrentStackTraceWindows(
246 out_stream: var,
247 debug_info: *DebugInfo,
248 tty_color: bool,
249 start_addr: ?usize,
250) !void {
248251 var addr_buf: [1024]usize = undefined;
249252 const casted_len = @intCast(u32, addr_buf.len); // TODO shouldn't need this cast
250253 const n = windows.RtlCaptureStackBackTrace(0, casted_len, @ptrCast(**c_void, &addr_buf), null);
......@@ -391,7 +394,7 @@ fn printSourceAtAddressWindows(di: *DebugInfo, out_stream: var, relocated_addres
391394 break :subsections null;
392395 }
393396 };
394
397
395398 if (tty_color) {
396399 setTtyColor(TtyColor.White);
397400 if (opt_line_info) |li| {
......@@ -438,7 +441,7 @@ fn printSourceAtAddressWindows(di: *DebugInfo, out_stream: var, relocated_addres
438441 }
439442}
440443
441const TtyColor = enum{
444const TtyColor = enum {
442445 Red,
443446 Green,
444447 Cyan,
......@@ -465,18 +468,16 @@ fn setTtyColor(tty_color: TtyColor) void {
465468 // TODO handle errors
466469 switch (tty_color) {
467470 TtyColor.Red => {
468 _ = windows.SetConsoleTextAttribute(stderr_file.handle, windows.FOREGROUND_RED|windows.FOREGROUND_INTENSITY);
471 _ = windows.SetConsoleTextAttribute(stderr_file.handle, windows.FOREGROUND_RED | windows.FOREGROUND_INTENSITY);
469472 },
470473 TtyColor.Green => {
471 _ = windows.SetConsoleTextAttribute(stderr_file.handle, windows.FOREGROUND_GREEN|windows.FOREGROUND_INTENSITY);
474 _ = windows.SetConsoleTextAttribute(stderr_file.handle, windows.FOREGROUND_GREEN | windows.FOREGROUND_INTENSITY);
472475 },
473476 TtyColor.Cyan => {
474 _ = windows.SetConsoleTextAttribute(stderr_file.handle,
475 windows.FOREGROUND_GREEN|windows.FOREGROUND_BLUE|windows.FOREGROUND_INTENSITY);
477 _ = windows.SetConsoleTextAttribute(stderr_file.handle, windows.FOREGROUND_GREEN | windows.FOREGROUND_BLUE | windows.FOREGROUND_INTENSITY);
476478 },
477479 TtyColor.White, TtyColor.Bold => {
478 _ = windows.SetConsoleTextAttribute(stderr_file.handle,
479 windows.FOREGROUND_RED|windows.FOREGROUND_GREEN|windows.FOREGROUND_BLUE|windows.FOREGROUND_INTENSITY);
480 _ = windows.SetConsoleTextAttribute(stderr_file.handle, windows.FOREGROUND_RED | windows.FOREGROUND_GREEN | windows.FOREGROUND_BLUE | windows.FOREGROUND_INTENSITY);
480481 },
481482 TtyColor.Dim => {
482483 _ = windows.SetConsoleTextAttribute(stderr_file.handle, windows.FOREGROUND_INTENSITY);
std/event/fs.zig+8-7
......@@ -119,7 +119,7 @@ pub async fn pwriteWindows(loop: *Loop, fd: os.FileHandle, data: []const u8, off
119119 },
120120 };
121121 // TODO only call create io completion port once per fd
122 _ = try os.windowsCreateIoCompletionPort(fd, loop.os_data.io_port, undefined, undefined);
122 _ = windows.CreateIoCompletionPort(fd, loop.os_data.io_port, undefined, undefined);
123123 loop.beginOneEvent();
124124 errdefer loop.finishOneEvent();
125125
......@@ -251,7 +251,7 @@ pub async fn preadWindows(loop: *Loop, fd: os.FileHandle, data: []u8, offset: u6
251251 },
252252 };
253253 // TODO only call create io completion port once per fd
254 _ = try os.windowsCreateIoCompletionPort(fd, loop.os_data.io_port, undefined, undefined);
254 _ = windows.CreateIoCompletionPort(fd, loop.os_data.io_port, undefined, undefined);
255255 loop.beginOneEvent();
256256 errdefer loop.finishOneEvent();
257257
......@@ -264,12 +264,13 @@ pub async fn preadWindows(loop: *Loop, fd: os.FileHandle, data: []u8, offset: u6
264264 var bytes_transferred: windows.DWORD = undefined;
265265 if (windows.GetOverlappedResult(fd, &resume_node.base.overlapped, &bytes_transferred, windows.FALSE) == 0) {
266266 const err = windows.GetLastError();
267 return switch (err) {
267 switch (err) {
268268 windows.ERROR.IO_PENDING => unreachable,
269 windows.ERROR.OPERATION_ABORTED => error.OperationAborted,
270 windows.ERROR.BROKEN_PIPE => error.BrokenPipe,
271 else => os.unexpectedErrorWindows(err),
272 };
269 windows.ERROR.OPERATION_ABORTED => return error.OperationAborted,
270 windows.ERROR.BROKEN_PIPE => return error.BrokenPipe,
271 windows.ERROR.HANDLE_EOF => return usize(bytes_transferred),
272 else => return os.unexpectedErrorWindows(err),
273 }
273274 }
274275 return usize(bytes_transferred);
275276}
std/event/loop.zig+5-5
......@@ -29,7 +29,7 @@ pub const Loop = struct {
2929 handle: promise,
3030 overlapped: Overlapped,
3131
32 const overlapped_init = switch (builtin.os) {
32 pub const overlapped_init = switch (builtin.os) {
3333 builtin.Os.windows => windows.OVERLAPPED{
3434 .Internal = 0,
3535 .InternalHigh = 0,
......@@ -39,7 +39,7 @@ pub const Loop = struct {
3939 },
4040 else => {},
4141 };
42 const Overlapped = @typeOf(overlapped_init);
42 pub const Overlapped = @typeOf(overlapped_init);
4343
4444 pub const Id = enum {
4545 Basic,
......@@ -415,6 +415,7 @@ pub const Loop = struct {
415415 .base = ResumeNode{
416416 .id = ResumeNode.Id.Basic,
417417 .handle = @handle(),
418 .overlapped = ResumeNode.overlapped_init,
418419 },
419420 };
420421 try self.linuxAddFd(fd, &resume_node.base, flags);
......@@ -697,11 +698,10 @@ pub const Loop = struct {
697698 const overlapped = while (true) {
698699 var nbytes: windows.DWORD = undefined;
699700 var overlapped: ?*windows.OVERLAPPED = undefined;
700 switch (os.windowsGetQueuedCompletionStatus(self.os_data.io_port, &nbytes, &completion_key,
701 &overlapped, windows.INFINITE))
702 {
701 switch (os.windowsGetQueuedCompletionStatus(self.os_data.io_port, &nbytes, &completion_key, &overlapped, windows.INFINITE)) {
703702 os.WindowsWaitResult.Aborted => return,
704703 os.WindowsWaitResult.Normal => {},
704 os.WindowsWaitResult.EOF => {},
705705 os.WindowsWaitResult.Cancelled => continue,
706706 }
707707 if (overlapped) |o| break o;
std/event/tcp.zig+1
......@@ -32,6 +32,7 @@ pub const Server = struct {
3232 .listen_resume_node = event.Loop.ResumeNode{
3333 .id = event.Loop.ResumeNode.Id.Basic,
3434 .handle = undefined,
35 .overlapped = event.Loop.ResumeNode.overlapped_init,
3536 },
3637 };
3738 }
std/os/child_process.zig+10-2
......@@ -658,8 +658,16 @@ fn windowsCreateProcess(app_name: [*]u16, cmd_line: [*]u16, envp_ptr: ?[*]u16, c
658658 // environment variables to programs that were not, which seems unlikely.
659659 // More investigation is needed.
660660 if (windows.CreateProcessW(
661 app_name, cmd_line, null, null, windows.TRUE, windows.CREATE_UNICODE_ENVIRONMENT,
662 @ptrCast(?*c_void, envp_ptr), cwd_ptr, lpStartupInfo, lpProcessInformation,
661 app_name,
662 cmd_line,
663 null,
664 null,
665 windows.TRUE,
666 windows.CREATE_UNICODE_ENVIRONMENT,
667 @ptrCast(?*c_void, envp_ptr),
668 cwd_ptr,
669 lpStartupInfo,
670 lpProcessInformation,
663671 ) == 0) {
664672 const err = windows.GetLastError();
665673 switch (err) {
std/os/windows/kernel32.zig-1
......@@ -206,7 +206,6 @@ pub const FILE_NOTIFY_CHANGE_DIR_NAME = 2;
206206pub const FILE_NOTIFY_CHANGE_FILE_NAME = 1;
207207pub const FILE_NOTIFY_CHANGE_ATTRIBUTES = 4;
208208
209
210209pub const CONSOLE_SCREEN_BUFFER_INFO = extern struct {
211210 dwSize: COORD,
212211 dwCursorPosition: COORD,
std/os/windows/util.zig+3-1
......@@ -223,7 +223,7 @@ pub fn windowsFindFirstFile(
223223 dir_path: []const u8,
224224 find_file_data: *windows.WIN32_FIND_DATAW,
225225) !windows.HANDLE {
226 const dir_path_w = try sliceToPrefixedSuffixedFileW(dir_path, []u16{'\\', '*', 0});
226 const dir_path_w = try sliceToPrefixedSuffixedFileW(dir_path, []u16{ '\\', '*', 0 });
227227 const handle = windows.FindFirstFileW(&dir_path_w, find_file_data);
228228
229229 if (handle == windows.INVALID_HANDLE_VALUE) {
......@@ -278,6 +278,7 @@ pub const WindowsWaitResult = enum {
278278 Normal,
279279 Aborted,
280280 Cancelled,
281 EOF,
281282};
282283
283284pub fn windowsGetQueuedCompletionStatus(completion_port: windows.HANDLE, bytes_transferred_count: *windows.DWORD, lpCompletionKey: *usize, lpOverlapped: *?*windows.OVERLAPPED, dwMilliseconds: windows.DWORD) WindowsWaitResult {
......@@ -286,6 +287,7 @@ pub fn windowsGetQueuedCompletionStatus(completion_port: windows.HANDLE, bytes_t
286287 switch (err) {
287288 windows.ERROR.ABANDONED_WAIT_0 => return WindowsWaitResult.Aborted,
288289 windows.ERROR.OPERATION_ABORTED => return WindowsWaitResult.Cancelled,
290 windows.ERROR.HANDLE_EOF => return WindowsWaitResult.EOF,
289291 else => {
290292 if (std.debug.runtime_safety) {
291293 std.debug.panic("unexpected error: {}\n", err);
std/pdb.zig+98-63
......@@ -64,19 +64,35 @@ pub const ModInfo = packed struct {
6464};
6565
6666pub const SectionMapHeader = packed struct {
67 Count: u16, /// Number of segment descriptors
68 LogCount: u16, /// Number of logical segment descriptors
67 /// Number of segment descriptors
68 Count: u16,
69
70 /// Number of logical segment descriptors
71 LogCount: u16,
6972};
7073
7174pub const SectionMapEntry = packed struct {
72 Flags: u16 , /// See the SectionMapEntryFlags enum below.
73 Ovl: u16 , /// Logical overlay number
74 Group: u16 , /// Group index into descriptor array.
75 Frame: u16 ,
76 SectionName: u16 , /// Byte index of segment / group name in string table, or 0xFFFF.
77 ClassName: u16 , /// Byte index of class in string table, or 0xFFFF.
78 Offset: u32 , /// Byte offset of the logical segment within physical segment. If group is set in flags, this is the offset of the group.
79 SectionLength: u32 , /// Byte count of the segment or group.
75 /// See the SectionMapEntryFlags enum below.
76 Flags: u16,
77
78 /// Logical overlay number
79 Ovl: u16,
80
81 /// Group index into descriptor array.
82 Group: u16,
83 Frame: u16,
84
85 /// Byte index of segment / group name in string table, or 0xFFFF.
86 SectionName: u16,
87
88 /// Byte index of class in string table, or 0xFFFF.
89 ClassName: u16,
90
91 /// Byte offset of the logical segment within physical segment. If group is set in flags, this is the offset of the group.
92 Offset: u32,
93
94 /// Byte count of the segment or group.
95 SectionLength: u32,
8096};
8197
8298pub const StreamType = enum(u16) {
......@@ -290,13 +306,13 @@ pub const SymbolKind = packed enum(u16) {
290306pub const TypeIndex = u32;
291307
292308pub const ProcSym = packed struct {
293 Parent: u32 ,
294 End: u32 ,
295 Next: u32 ,
296 CodeSize: u32 ,
297 DbgStart: u32 ,
298 DbgEnd: u32 ,
299 FunctionType: TypeIndex ,
309 Parent: u32,
310 End: u32,
311 Next: u32,
312 CodeSize: u32,
313 DbgStart: u32,
314 DbgEnd: u32,
315 FunctionType: TypeIndex,
300316 CodeOffset: u32,
301317 Segment: u16,
302318 Flags: ProcSymFlags,
......@@ -315,25 +331,34 @@ pub const ProcSymFlags = packed struct {
315331 HasOptimizedDebugInfo: bool,
316332};
317333
318pub const SectionContrSubstreamVersion = enum(u32) {
319 Ver60 = 0xeffe0000 + 19970605,
320 V2 = 0xeffe0000 + 20140516
334pub const SectionContrSubstreamVersion = enum(u32) {
335 Ver60 = 0xeffe0000 + 19970605,
336 V2 = 0xeffe0000 + 20140516,
321337};
322338
323339pub const RecordPrefix = packed struct {
324 RecordLen: u16, /// Record length, starting from &RecordKind.
325 RecordKind: SymbolKind, /// Record kind enum (SymRecordKind or TypeRecordKind)
340 /// Record length, starting from &RecordKind.
341 RecordLen: u16,
342
343 /// Record kind enum (SymRecordKind or TypeRecordKind)
344 RecordKind: SymbolKind,
326345};
327346
328347pub const LineFragmentHeader = packed struct {
329 RelocOffset: u32, /// Code offset of line contribution.
330 RelocSegment: u16, /// Code segment of line contribution.
348 /// Code offset of line contribution.
349 RelocOffset: u32,
350
351 /// Code segment of line contribution.
352 RelocSegment: u16,
331353 Flags: LineFlags,
332 CodeSize: u32, /// Code size of this line contribution.
354
355 /// Code size of this line contribution.
356 CodeSize: u32,
333357};
334358
335359pub const LineFlags = packed struct {
336 LF_HaveColumns: bool, /// CV_LINES_HAVE_COLUMNS
360 /// CV_LINES_HAVE_COLUMNS
361 LF_HaveColumns: bool,
337362 unused: u15,
338363};
339364
......@@ -348,12 +373,14 @@ pub const LineBlockFragmentHeader = packed struct {
348373 /// table of the actual name.
349374 NameIndex: u32,
350375 NumLines: u32,
351 BlockSize: u32, /// code size of block, in bytes
352};
353376
377 /// code size of block, in bytes
378 BlockSize: u32,
379};
354380
355381pub const LineNumberEntry = packed struct {
356 Offset: u32, /// Offset to start of code bytes for line number
382 /// Offset to start of code bytes for line number
383 Offset: u32,
357384 Flags: u32,
358385
359386 /// TODO runtime crash when I make the actual type of Flags this
......@@ -371,42 +398,53 @@ pub const ColumnNumberEntry = packed struct {
371398
372399/// Checksum bytes follow.
373400pub const FileChecksumEntryHeader = packed struct {
374 FileNameOffset: u32, /// Byte offset of filename in global string table.
375 ChecksumSize: u8, /// Number of bytes of checksum.
376 ChecksumKind: u8, /// FileChecksumKind
401 /// Byte offset of filename in global string table.
402 FileNameOffset: u32,
403
404 /// Number of bytes of checksum.
405 ChecksumSize: u8,
406
407 /// FileChecksumKind
408 ChecksumKind: u8,
377409};
378410
379411pub const DebugSubsectionKind = packed enum(u32) {
380 None = 0,
381 Symbols = 0xf1,
382 Lines = 0xf2,
383 StringTable = 0xf3,
384 FileChecksums = 0xf4,
385 FrameData = 0xf5,
386 InlineeLines = 0xf6,
387 CrossScopeImports = 0xf7,
388 CrossScopeExports = 0xf8,
389
390 // These appear to relate to .Net assembly info.
391 ILLines = 0xf9,
392 FuncMDTokenMap = 0xfa,
393 TypeMDTokenMap = 0xfb,
394 MergedAssemblyInput = 0xfc,
395
396 CoffSymbolRVA = 0xfd,
412 None = 0,
413 Symbols = 0xf1,
414 Lines = 0xf2,
415 StringTable = 0xf3,
416 FileChecksums = 0xf4,
417 FrameData = 0xf5,
418 InlineeLines = 0xf6,
419 CrossScopeImports = 0xf7,
420 CrossScopeExports = 0xf8,
421
422 // These appear to relate to .Net assembly info.
423 ILLines = 0xf9,
424 FuncMDTokenMap = 0xfa,
425 TypeMDTokenMap = 0xfb,
426 MergedAssemblyInput = 0xfc,
427
428 CoffSymbolRVA = 0xfd,
397429};
398430
399
400431pub const DebugSubsectionHeader = packed struct {
401 Kind: DebugSubsectionKind, /// codeview::DebugSubsectionKind enum
402 Length: u32, /// number of bytes occupied by this record.
403};
432 /// codeview::DebugSubsectionKind enum
433 Kind: DebugSubsectionKind,
404434
435 /// number of bytes occupied by this record.
436 Length: u32,
437};
405438
406439pub const PDBStringTableHeader = packed struct {
407 Signature: u32, /// PDBStringTableSignature
408 HashVersion: u32, /// 1 or 2
409 ByteSize: u32, /// Number of bytes of names buffer.
440 /// PDBStringTableSignature
441 Signature: u32,
442
443 /// 1 or 2
444 HashVersion: u32,
445
446 /// Number of bytes of names buffer.
447 ByteSize: u32,
410448};
411449
412450pub const Pdb = struct {
......@@ -456,7 +494,7 @@ const Msf = struct {
456494 switch (superblock.BlockSize) {
457495 // llvm only supports 4096 but we can handle any of these values
458496 512, 1024, 2048, 4096 => {},
459 else => return error.InvalidDebugInfo
497 else => return error.InvalidDebugInfo,
460498 }
461499
462500 if (superblock.NumBlocks * superblock.BlockSize != try file.getEndPos())
......@@ -536,7 +574,6 @@ const SuperBlock = packed struct {
536574 /// The number of ulittle32_t’s in this array is given by
537575 /// ceil(NumDirectoryBytes / BlockSize).
538576 BlockMapAddr: u32,
539
540577};
541578
542579const MsfStream = struct {
......@@ -552,14 +589,12 @@ const MsfStream = struct {
552589 pub const Stream = io.InStream(Error);
553590
554591 fn init(block_size: u32, block_count: u32, pos: usize, file: os.File, allocator: *mem.Allocator) !MsfStream {
555 var stream = MsfStream {
592 var stream = MsfStream{
556593 .in_file = file,
557594 .pos = 0,
558595 .blocks = try allocator.alloc(u32, block_count),
559596 .block_size = block_size,
560 .stream = Stream {
561 .readFn = readFn,
562 },
597 .stream = Stream{ .readFn = readFn },
563598 };
564599
565600 var file_stream = io.FileInStream.init(file);
......@@ -597,7 +632,7 @@ const MsfStream = struct {
597632
598633 var size: usize = 0;
599634 for (buffer) |*byte| {
600 byte.* = try in.readByte();
635 byte.* = try in.readByte();
601636
602637 offset += 1;
603638 size += 1;