Commit Graph

102 Commits

Author SHA1 Message Date
Andrew Kelley
abf959a0c9
fix debug builds of WASI 2019-05-27 02:16:05 -04:00
Andrew Kelley
6be79d79aa
fixes for Windows and WASI 2019-05-27 00:48:56 -04:00
Andrew Kelley
2b42e910bf
behavior tests passing on Linux 2019-05-26 19:56:37 -04:00
Andrew Kelley
2f040a23c8
clean up references to os 2019-05-26 18:32:44 -04:00
Andrew Kelley
7cb6279ac0
clean up references to posix 2019-05-26 18:32:44 -04:00
Andrew Kelley
ca6debcaf4
starting to fix the regressions 2019-05-26 18:32:44 -04:00
Andrew Kelley
17b0166e00
do Jay's suggestion with posix/os API naming & layout 2019-05-26 18:32:44 -04:00
emekoi
1c73c08298 ran zig fmt on stdlib 2019-05-19 16:33:31 -04:00
LemonBoy
232bc1bdee Remove more 64bit-centric assumptions from stdlib 2019-05-18 11:08:04 +02:00
Marc Tiehuis
c4d1597f50 Mmap debug info on linux
Closes #907.
2019-05-13 20:04:25 +12:00
LemonBoy
8cc4eaea9f Use matching types when parsing fields 2019-05-10 00:44:24 +02:00
LemonBoy
4d8f96dd88 Fix minor bug in LEB128 parsing 2019-05-10 00:41:05 +02:00
Andrew Kelley
9c12237d2d
std.debug: fix stack trace iteration code
Previously, the stack trace iteration code was using the number of
frames collected as the number of frames to print, not recognizing the
fixed size of the buffer. So it would redundantly print items, matching
the total number of frames ever collected.

Now the iteration code is limited to the actual stack trace frame count,
and will not print duplicate frames.

Closes #2447
Closes #2151
2019-05-08 19:11:01 -04:00
LemonBoy
374d16793f Go one instruction before the return address
The return address may not point to an area covered by the debug infos
so we hope for the best and decrement the address so that it points to
the caller instruction.
2019-04-23 10:05:46 +02:00
LemonBoy
b095e33667 Fix silly typo 2019-04-23 09:57:57 +02:00
LemonBoy
57ec183c09 Fix reading of signed leb128 values 2019-04-23 09:57:22 +02:00
Andrew Kelley
9b83fe6b4c
fixup and zig fmt 2019-04-20 13:48:38 -04:00
LemonBoy
c2542bb7b7 Recover symbol infos from DWARF sections 2019-04-20 10:35:39 +02:00
LemonBoy
0286be127e Fix parseFormValueConstant
Signed/unsigned confusion made the code fail an assertion sometimes.
2019-04-19 19:59:14 +02:00
Andrew Kelley
3ce024dd85
A bunch of fixes for the DWARF parser (#2254)
* Correct parsing of DWARF line_info section

* Fix reading of udata/sdata encoded attributes

* Add definition for DW_AT_alignment

Even though it's been standardized in DWARF5 some compilers produce it
anyway for DWARF4 infos too.

* Fix reading of reference attributes

* Distinguish between absolute/relative addresses
2019-04-11 14:34:13 -04:00
Matthew Iannucci
27cd830ec8 Add initial support for iOS targets (#2237)
* Add iOS C int sizes... try to hack in iOS DebugInfo

* Get rid of ios link check for now

* Remove macos linkversion check
2019-04-11 13:15:17 -04:00
LemonBoy
51eb4ebec1 Distinguish between absolute/relative addresses 2019-04-11 15:41:42 +02:00
LemonBoy
38492b2ea4 Fix reading of reference attributes 2019-04-11 10:36:15 +02:00
LemonBoy
795b3e9b68 Fix reading of udata/sdata encoded attributes 2019-04-11 10:36:15 +02:00
LemonBoy
60e2a04322 Correct parsing of DWARF line_info section 2019-04-10 23:30:41 +02:00
Sahnvour
ae9b90cf6e print a message instead of returning an error when debug info comes from a source file not found (for example compiled on another computer) 2019-03-16 15:34:14 +01:00
Sahnvour
704dfaaabf avoid reading LineBlockFragmentHeader at all if the address is not in range, thus simplifying code and improving speed of execution 2019-03-16 15:34:14 +01:00
Sahnvour
094d40fb1a allow pdb modules to have no C13 data, this happens if the module is stripped 2019-03-16 15:34:14 +01:00
Sahnvour
0d4a5c40bc correct padding handling between std.pdb.ModInfo entries in DbiStream 2019-03-16 15:34:14 +01:00
Andrew Kelley
9c13e9b7ed
breaking changes to std.mem.Allocator interface API
Before, allocator implementations had to provide `allocFn`,
`reallocFn`, and `freeFn`.

Now, they must provide only `reallocFn` and `shrinkFn`.
Reallocating from a zero length slice is allocation, and
shrinking to a zero length slice is freeing.

When the new memory size is less than or equal to the
previous allocation size, `reallocFn` now has the option
to return `error.OutOfMemory` to indicate that the allocator
would not be able to take advantage of the new size.

For more details see #1306. This commit closes #1306.

This commit paves the way to solving #2009.

This commit also introduces a memory leak to all coroutines.
There is an issue where a coroutine calls the function and it
frees its own stack frame, but then the return value of `shrinkFn`
is a slice, which is implemented as an sret struct. Writing to
the return pointer causes invalid memory write. We could work
around it by having a global helper function which has a void
return type and calling that instead. But instead this hack will
suffice until I rework coroutines to be non-allocating. Basically
coroutines are not supported right now until they are reworked as
in #1194.
2019-03-15 17:57:21 -04:00
Andrew Kelley
e402455704
rename std lib files to new convention 2019-03-02 16:46:04 -05:00
Andrew Kelley
4183c6f1a5 move std/debug.zig to a subdirectory
self hosted compiler parser tests do some fuzz testing
2017-12-23 22:15:48 -05:00
Andrew Kelley
d917815d81 explicitly return from blocks
instead of last statement being expression value

closes #629
2017-12-22 00:50:30 -05:00
Andrew Kelley
1fdebc1dc4 wip export rewrite 2017-12-18 09:59:57 -05:00
Andrew Kelley
caa6433b56 stack traces: support DW_AT_ranges
This makes some cases print stack traces where it previously failed.
2017-12-12 12:05:28 -05:00
Andrew Kelley
ed4d94a5d5 self-hosted: test all out of memory conditions 2017-12-11 21:12:47 -05:00
Andrew Kelley
c4e7d05ce3 refactor debug.global_allocator into mem.FixedBufferAllocator 2017-12-11 17:27:31 -05:00
Andrew Kelley
f210f17d30 add self-hosted parsing and rendering to main tests 2017-12-10 21:26:52 -05:00
Andrew Kelley
62c25af802 add higher level arg-parsing API + misc. changes
* add @noInlineCall - see #640
   This fixes a crash in --release-safe and --release-fast modes
   where the optimizer inlines everything into _start and
   clobbers the command line argument data.
   If we were able to verify that the user's code never reads
   command line args, we could leave off this "no inline"
   attribute.
 * add i29 and u29 primitive types. u29 is the type of alignment,
   so it makes sense to be a primitive.
   probably in the future we'll make any `i` or `u` followed by
   digits into a primitive.
 * add `aligned` functions to Allocator interface
 * add `os.argsAlloc` and `os.argsFree` so that you can get
   a `[]const []u8`, do whatever arg parsing you want, and then free
   it. For now this uses the other API under the hood, but it could
   be reimplemented to do a single allocation.
 * add tests to make sure command line argument parsing works.
2017-12-06 18:12:05 -05:00
Andrew Kelley
a966275e50 rename builtin.is_big_endian to builtin.endian
See #307
2017-12-04 10:36:31 -05:00
Andrew Kelley
0ad1239522 rework enums and unions and their relationship to each other
* @enumTagName renamed to @tagName and it works on enums and
   union-enums
 * Remove the EnumTag type. Now there is only enum and union,
   and the tag type of a union is always an enum.
 * unions support specifying the tag enum type, and they support
   inferring an enum tag type.
 * Enums no longer support field types but they do support
   setting the tag values. Likewise union-enums when inferring
   an enum tag type support setting the tag values.
 * It is now an error for enums and unions to have 0 fields.
 * switch statements support union-enums

closes #618
2017-12-03 20:43:56 -05:00
Andrew Kelley
1ac46fac15 add a std lib test for reading and writing files
* fix fstat wrong on darwin
 * move std.debug.global_allocator to std.debug.global_allocator_state and make it private
 * add std.debug.global_allocator as a pointer (to upgrade your zig code remove
   the '&')
2017-11-10 14:17:23 -05:00
Andrew Kelley
4543413491 std.io: introduce buffered I/O and change API
I started working on #465 and made some corresponding std.io
API changes.

New structs:
 * std.io.FileInStream
 * std.io.FileOutStream
 * std.io.BufferedOutStream
 * std.io.BufferedInStream

Removed:
 * std.io.File.in_stream
 * std.io.File.out_stream

Now instead of &file.out_stream or &file.in_stream to get access to
the stream API for a file, you get it like this:

var file_in_stream = io.FileInStream.init(&file);
const in_stream = &file_in_stream.stream;

var file_out_stream = io.FileOutStream.init(&file);
const out_stream = &file_out_stream.stream;

This is evidence that we might not need any OOP features -
See #130.
2017-11-07 03:22:27 -05:00
Andrew Kelley
9e234d4208 breaking change to std.io API
* Merge io.InStream and io.OutStream into io.File
 * Introduce io.OutStream and io.InStream interfaces
   - io.File implements both of these
 * Move mem.IncrementingAllocator to heap.IncrementingAllocator

Instead of:

```
%return std.io.stderr.printf("hello\n");
```

now do:

```
std.debug.warn("hello\n");
```

To print to stdout, see `io.getStdOut()`.

 * Rename std.ArrayList.resizeDown to std.ArrayList.shrink.
2017-10-31 04:47:55 -04:00
Andrew Kelley
fcef7c4bb2 fix std.io.InStream for windows
now we handle PIPE_BROKEN as an EOF

also set up framework for debugging unexpected posix/windows errors
2017-10-15 16:45:43 -04:00
Andrew Kelley
c4262da8de implement os.path.real for windows and update allocator interface 2017-10-09 14:21:35 -04:00
Marc Tiehuis
c4a54377e3 Stop debug allocator ever panicking (#492) 2017-09-19 09:47:41 -04:00
Andrew Kelley
898d65baa9 more alignment improvements
* add alignment capability for fn protos
 * add @alignCast
 * fix some ast rendering code
 * fix some ir rendering code
 * add error for pointer cast increasing alignment
 * update allocators in std to correctly align

See #37
2017-08-29 23:33:25 -04:00
Andrew Kelley
b59aa7b906 fixups to linux build 2017-08-27 00:28:17 -04:00
Andrew Kelley
2bd6c60752 update for llvm 5.0.0rc1 2017-08-26 00:34:40 -04:00