Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Split --debug mode into several flags #332

Closed
GreyCat opened this issue Jan 30, 2018 · 5 comments
Closed

Split --debug mode into several flags #332

GreyCat opened this issue Jan 30, 2018 · 5 comments
Milestone

Comments

@GreyCat
Copy link
Member

GreyCat commented Jan 30, 2018

I guess the time had come to think of splitting --debug mode, which was originally designed solely for visualization tools integration, into several meaningful compilation options / flags:

  1. Store positions of attributes in the stream — my_obj._debug['attr_id']
    1.1. May be additional submode — store positions of individual elements in the array
  2. Read-in-constructor vs separate constructor + _read() call
  3. Dump sequence of seq elements as array — MyType::SEQ_FIELDS

May be also we could think of:

  • dump doc / doc-ref elements as strings for visualization tools to annotate fields
  • dump other metainformation (title, license, etc) as strings
  • dump unofficial YAML fields (i.e. stuff like -webide-representation, etc) as is into relevant parts of the class
  • for hardcore languages such as C++ — preparing arrays of getter function pointers, i.e. something like:

The main concern is that (1) is super slow and actually rarely needed outside of visualization / debugging purposes. (2) is super useful per se for parsing "bad" data and being able to cope with half-filled classes. (3) is not a big deal, but it adds extra pollution and, again, is pretty much useless outside of scope of vis tools.

From top of my head, I'd go with --debug-pos for (1), --no-ctor-read for (2), --debug-seq for (3).

@KOLANICH
Copy link

KOLANICH commented Jan 30, 2018

For 1 we need more meaningful names. I guess _offsets and --save-offsets.

@GreyCat
Copy link
Member Author

GreyCat commented Jan 30, 2018

Currently, it's highly implementation-dependent:

  • Ruby uses:
    • _debug hashmap of attribute name strings which map to:
      • {:start => ..., :end => ...} if that's a regular attribute
      • {:arr => [{:start => ..., :end => ...}, {:start => ..., :end => ...}, ...]} additionally, if that's an array
    • SEQ_FIELDS class-level constant, array of strings
  • Java uses:
    • _attrStart + _attrEnd, which are Map<String, Long>
    • _arrStart + _arrEnd, which are Map<String, ArrayList<Integer>>
    • _seqFields class-level static string array
  • JavaScript uses:
    • _debug object, inside which by name of the attribute we can get:
      • { start: ..., ioOffset: ..., end: ... } for regular attributes
      • { arr: [{ start: ..., ioOffset: ..., end: ... }, ...] } for arrays
  • Python uses:
    • _debug dictionary of attribute name strings which map to:
      • {'start': ..., 'end': ...} if that's a regular attribute
      • {'arr': [{'start': ..., 'end': ...}, {'start': ..., 'end': ...}, ...]} additionally, if that's an array
    • SEQ_FIELDS class-level constant, array of strings

@GreyCat GreyCat added this to the v0.9 milestone Jan 16, 2019
@GreyCat
Copy link
Member Author

GreyCat commented Jan 16, 2019

--debug is now separated into --no-auto-read for (2) and --read-pos for (1).

@GreyCat
Copy link
Member Author

GreyCat commented Jan 22, 2019

Python support was added in kaitai-io/kaitai_struct_compiler@18cecf4 in 2018-07. I'll update the overall description of data structures above.

@GreyCat
Copy link
Member Author

GreyCat commented Apr 18, 2019

The --debug flag has been split. On the second though, it's kind of pointless to have separate flag for SEQ_FIELDS generation. Right now it just uses config.readStoresPos (--read-pos in command line).

Closing this one as done.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants