Commit Graph
126 Commits
Author SHA1 Message Date
baldurk 05da25a2d7 Add necessary flushes for stream I/O socket writing tests 2017-11-27 21:20:28 +00:00
baldurk 47bee80522 A couple of android compile fixes that showed up 2017-11-27 20:34:28 +00:00
baldurk 413a06b299 Change stream I/O behaviour around sockets
* Previously each read and write would 1:1 become a send or recv call.
* Now we buffer writes and send in batch (or when a chunk finishes),
  and every time we read we try to non-blocking read more data to fill
  the buffer, to allow batching reads where possible without blocking
  on data that will never come.
2017-11-27 18:54:19 +00:00
baldurk b418a5db6a Flush file after writing header length fixups, to ensure it's written 2017-11-27 12:38:44 +00:00
baldurk cba76414e1 Add exporter for Chrome's trace profiler from chunk metadata. 2017-11-24 18:14:23 +00:00
baldurk 15ddb868e1 Record chunk thread IDs, timestamps and durations 2017-11-24 18:14:23 +00:00
baldurk 01e2e00b5f Add error checking and handling while loading captures
* Previously once we started loading a capture we'd blindly continue
  until we loaded it (and then it's assumed to be successful), or we
  crash.
* Now errors can be reported during serialisation and bubbled up to
  abort the file load process. The next steps are to add error checking
  in each function serialise before doing any replay calls to the API
  with potentially corrupt data, and on top of that catching API-only
  errors when the serialisation is (seemingly) fine, and propagating
  those in a reasonable way.
* We also harden the serialisation a bit so that if it reads an
  obviously invalid byte length for a buffer or array count, it won't
  continue. It's still not perfect as the sizes could still be large and
  invalid but within range, but it should catch the worst cases.
2017-11-24 18:14:21 +00:00
baldurk 7ec2c79e86 Fix conditional branches on 'constant' values
* Reported by Coverity Scan
2017-11-22 11:59:18 +00:00
baldurk 016bc29609 Add a tool menu item that will recompress a capture file 2017-11-17 16:33:05 +00:00
baldurk a238d3022a Move section data types into the public replay interface 2017-11-17 16:31:00 +00:00
baldurk 0b899d90b6 Add ability to replace sections in RDCFile 2017-11-17 16:30:59 +00:00
baldurk b1c0de3016 Add and tweak some FileIO OS-specific functions
* fflush is a no-op wrapper but nice to have for consistency.
* ftruncateat will take a file read-write handle and truncate it at a
  given length. Useful if re-writing a file and the new data ends up
  being shorter than the oldd ata.
* Move in addition to Copy, and success/fail bool return on both.
2017-11-17 16:30:58 +00:00
baldurk 335919a42c Add a fast path when skipping bytes in a file-based I/O reader. 2017-11-10 18:36:03 +00:00
baldurk ebe1318f72 When exporting struct buffers we must always allocate memory to readback
* If the external code has a NULL pointer and doesn't want to allocate
  but we are exporting buffer data, we still need to read the data
  somewhere so make a temporary allocation to read it into.
2017-11-09 15:12:06 +00:00
baldurk 13f4ac481e Fix incorrect arguments to error printf 2017-11-09 15:11:20 +00:00
baldurk 9388d2b71b Change core capture code to be more centred around container handle
* When opening a capture file, a format is now available to allow
  easy import from another format without a completely different
  interface. Only rdc files can be replayed, but any other file can
  load and access structured data through the same interface.
* The replay initialisation and capture writing interfaces also use the
  RDCFile instead of passing filenames or Serialisers around directly.
  Driver initialisation parameters are now entirely private, and don't
  need to be exposed - any agnostic metadata like thumbnail, driver, etc
  are all accessed via the RDCFile container itself.
* Callstack resolution is now part of the container file, not the
  back-end via way of its Serialiser.
* Importers/Exporters to other non-RDC formats are registered in a
  similar way to replay/remote drivers.
* It is also then possible to construct an RDC file from thin air, by
  creating an empty RDCFile container and filling it with data, then
  requesting it to be written to disk.
2017-11-07 19:30:35 +00:00
baldurk 327fda94a0 Add refactored serialisation system
* The new system contains the ability to export serialised data to a
  structured form in memory - and conversion back to serialised bytes.
* This will allow offline transformations/visualisation of capture files
  as well as more rich representations of API calls in the UI.
* Likewise it enables a number of optimisations such as the ability to
  write straight from mapped API memory to disk via a compressor,
  without any intermediate copies.
2017-11-07 19:30:32 +00:00
baldurk 594c8ccae6 Fix for invalid use of assign() in new rdcstr interface
* This will go away with the serialise refactor, but is currently broken
2017-11-06 13:53:41 +00:00
baldurk 8a937a25d3 More errno.h fixes for OS X
* Because apparently the compiler isn't capable of giving more than one
  error at once :(.
2017-11-04 10:04:01 +00:00
baldurk 2cee89e326 Add errno.h header for OS X 2017-11-04 09:30:22 +00:00
baldurk 8fd388ae26 Fix for unit tests 2017-11-03 19:50:54 +00:00
baldurk 5bd3493238 Add an XML codec for converting to/from structured data representation 2017-11-03 17:25:11 +00:00
baldurk f147ece4c6 Add separate handling for new RDC container format
* The new serialiser system will not handle the container file itself,
  so we've separated it out to deal in sections and stream I/O to read
  from and write to sections.
* We also add the ability to choose the compression scheme for a section
  instead of always using LZ4. LZ4 will still be used on the fly for
  fast write performance, but then RDC files can be re-compressed for
  savings offline.
2017-11-03 16:32:03 +00:00
baldurk 459c5a856e Add new I/O streaming system, with pluggable compression
* This I/O will form the basis of the new serialiser - it will simply
  read to or write from one of these I/O streams. Then that stream can
  come from a file, go to a memory buffer, or go through a compressor
  or decompressor transparently.
* It also allows a unified way of writing over sockets instead of
  needing special socket helper functions.
* With this commit, the code isn't used aside from in tests.
2017-11-03 16:26:06 +00:00
baldurk 3aa3262089 Expose ToStr interface publicly, split out into separate files
* Note that while this is public and uses std::string, because it's a
  template with specialisations in a .inl the string never crosses a
  module boundary - each including module has its own implementation.
* This will be used as part of the upcoming serialisation refactor.
* Some POD structs are still given ToStr implementations as we haven't
  yet switched over the serialisation system to expect all structs to
  have serialise functions.
2017-11-03 16:23:02 +00:00
baldurk 9ef0c5282c Make aligned buffer allocation a common function, out of serialiser 2017-11-03 16:15:19 +00:00
baldurk 276783b948 Move custom printf & string_utils out of serialise/ folder 2017-11-03 16:07:46 +00:00
baldurk e6c5c03896 Remove rdctype namespace. Rename rdctype::str -> rdcstr, rdcarray, etc
* Since these types are more prevalent than originally designed, it
  makes more sense to remove the namespace for ease of typing/naming.
* Also add a specialised type 'bytebuf' for an array of bytes.
* This makes mapping easier to SWIG since there's no special casing for
  namespaced arrays. Especially so for nested cases like
  rdctype::array<rdctype::str> -> rdcarray<rdcstr>
2017-11-03 16:04:59 +00:00
baldurk 5e59616a8c Update rdctype::array to have a more stl-like mutable interface
* For the most part the interface is stl-compatible, but we have a few
  little changes of our own for convenience.
* This class is still needed after deleting the C# UI, because we don't
  want to pass C++ stl structs over module boundaries and possibly run
  into hard to diagnose incompatibilities.
2017-11-03 16:01:58 +00:00
baldurk d3d35ee216 Change thread creation type to std::function to allow lambdas 2017-09-29 12:11:13 +01:00
baldurk 5c4e21d6b5 printf fix for signed %zd formatters on 32-bit 2017-09-26 11:53:57 +01:00
baldurk 4988837175 Switch unit tests to CHECK instead of REQUIRE where possible 2017-08-30 18:32:20 +01:00
baldurk eb787f9a5f Add unit tests for custom printf 2017-08-29 13:19:51 +01:00
baldurk 6e19b57d85 Add unit tests for string_utils.cpp 2017-08-29 13:19:50 +01:00
baldurk cbbc779056 If the precision is lower than even the number after rounding, print 0.0 2017-08-29 13:19:49 +01:00
baldurk c8a160877f If the precision is 0 for strings, don't print anything 2017-08-29 13:19:49 +01:00
baldurk 56e1d6a527 Unsigned integer types don't ever have a prepended space or + 2017-08-29 13:19:48 +01:00
baldurk ed0c5650af Print the right sign on infinities 2017-08-29 13:19:47 +01:00
baldurk 8739c39f08 Don't write a NULL terminator at the end of the buffer
* Note: we do write a NULL terminator after the data (even if it's
  truncated) we just don't want to write it at the end of the buffer too
2017-08-29 13:19:46 +01:00
baldurk 9f1e830b50 Don't use uppercase 0X for alternate form hex printing 2017-08-29 13:19:46 +01:00
baldurk a6e2e9fea5 Support signed size_t sized objects in custom printf 2017-08-29 13:19:45 +01:00
baldurk bbf1c60859 Don't add separator after last element in merge() 2017-08-29 13:19:44 +01:00
baldurk eb15c43b41 Add Catch.hpp for unit testing, with appveyor hooks 2017-08-29 13:19:44 +01:00
baldurk ca88810df3 Fix NULL-terminating serialise of rdctype::str adding 0 into elems
* The +1 for internal NULL terminator must be done internally, otherwise
  we end up with "foobar" being a 7-character string of "foobar\0". If
  this is then re-serialised we add more and more null terminators.
2017-08-03 20:18:15 +01:00
Cody Northrop 296854da73 strings: Helper to remove pattern from the end 2017-07-21 10:29:46 -07:00
baldurk 7d5e047e66 Fix serialisation of rdctype::str to always NULL-terminate 2017-07-05 16:29:17 +01:00
baldurk f37079bff0 Use 64-bit counters for tracking compression sizes.
* There's still an issue lurking that the compressed size is stored as
  32-bit on disk, but at least now we don't store the uncompressed size
  as 64-bit but track it as 32-bit.
* The serialisation is going to change Soon(tm) anyway so this
  workaround should be enough for now, since hopefully compressed size
  is comfortably below uncompressed size.
2017-06-28 10:39:11 +01:00
Cody Northrop cced0e695b Add endswith helper to string_utils 2017-06-23 02:39:11 -07:00
baldurk 3fff6fa86a Ensure that in-memory buffer created serialisers have right version
* When flattening a log m_SerVer would be uninitialised which mean that
  if it was less than 0x32 we'd start aligning buffers when we shouldn't
  have.
2017-05-17 11:59:17 +01:00
baldurk d40fc8471d Change API enums to enum class, remove now redundant prefixing
* This gives a little nicer syntax, a bit better type safety, and also
  reflects better for SWIG bindings. Overall it's a minor change but
  better.
* We don't update the C# UI at all, since it's soon to be removed and
  not worth the effort/code churn.
* For now so we're ABI compatible with C#, all enums are uint32_t, but
  that is an obvious optimisation in future to reduce struct packing.
* We avoid 'None' as an enum value, because it's a reserved word in
  python so will cause problems generating bindings.
2017-04-18 14:57:33 +01:00