ursadb icon indicating copy to clipboard operation
ursadb copied to clipboard

Add `debug parse` command

Open msm-code opened this issue 4 years ago • 2 comments

We need a way to introspect the running database, or debug some issues without either recompiling the db with debug prints or attaching with gdb.

Especially now that I'll be working on query parsing & optimisation, I have a few ideas in mind. Right now I'd like to have something easy - debug parse command:

debug parse index "hmm" with [gram3];

Will parse the command index "hmm" with [gram3] in this case, pretty print the parsed tree and return it to the user. Expected result is for example:

index
    "hmm"
    index_type_list
        gram3

(or whatever the real query tree looks like).

This can be returned as a structured JSON or as plain text - it's intended for debugging so we don't make any guarantees about the output.

msm-code avatar Apr 13 '20 17:04 msm-code

I'm not sure if modifying language is the way to go.

Why isn't a stderr debug print good enough?

chivay avatar Apr 13 '20 17:04 chivay

Two reasons:

  1. Adding an ad-hoc debug print every time and removing it before the commit sounds tedious. That's pretty common (for me) when writing a new commands.

  2. While parsing is pretty low level (I've chosen it, because it's the easiest debug command I could think of), I have more use cases for this. For example debug querygraph [query] which will return a query graph produced from the input. In the future maybe even debug queryplan [query].

  3. Of course these can all be solved with enough debug prints, but if we continue making new releases and changing the parsers, we may need to debug a compiled ursadb instance, and understanding the querygraph used may be a blessing.

What do you think? :thinking:

msm-code avatar Apr 13 '20 17:04 msm-code

Since @chivay 's not a fan of this change, I don't have a lot of spare time to work on this, and it really is not overly important, we can probably scrap this issue. I don't forsee adding a lot of new commands in the coming months anyway (I expect working on querygraphs, but I can begrudgingly accept debug prints for this).

msm-code avatar Nov 26 '22 01:11 msm-code