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

[GDB] MatchLog enum kind raises TypeError when printed #726

Open
Robertorosmaninho opened this issue Apr 4, 2023 · 1 comment
Open

[GDB] MatchLog enum kind raises TypeError when printed #726

Robertorosmaninho opened this issue Apr 4, 2023 · 1 comment
Labels
bug Something isn't working debugger

Comments

@Robertorosmaninho
Copy link
Collaborator

Robertorosmaninho commented Apr 4, 2023

When debugging the MatchLog, it is desirable that every field be correctly printed without errors to the users/developers.

To reproduce this issue:

K Definition:

module TEST
  imports INT

  syntax Foo ::= foo(Int) | bar()
  rule [test]: foo(I) => bar() requires I ==Int 0
endmodule

kompile and krun:

kompile test.k --enable-llvm-debug && krun -cPGM='foo(1)' --debugger

On GDB:

(gdb) k start

...

(gdb)  python print(gdb.lookup_global_symbol('TEST.test.match').value()(gdb.parse_and_eval('subject')))
void

(gdb) python print(gdb.lookup_global_symbol("getMatchLog").value()()[0])
Python Exception <class 'TypeError'>: 'NoneType' object is not subscriptable

{kind = MatchLog::FUNCTION, function = 0x2f6560 <str_lit_side_condition_133> "side_condition_133", debugName = 0x2f6546 <str_lit_TEST.test.sc> "TEST.test.sc", result = 0x7ffff5500048, args = std::vector of length 1, capacity 1 = {0x7ffff5400088}, pattern = 0x0, subject = 0x0, sort = 0x0}

(gdb) python  print(gdb.lookup_global_symbol("getMatchLog").value()()[0]['kind'])
Python Exception <class 'TypeError'>: 'NoneType' object is not subscriptable
MatchLog::FUNCTION

Simple solutions: Work with Int or String
Harder solution: Workaround to pretty print the enum

@Robertorosmaninho Robertorosmaninho added the bug Something isn't working label Apr 4, 2023
@Robertorosmaninho
Copy link
Collaborator Author

This error mainly affects the developer side, as getting information from the MatchLog isn't something most users would use since it is only useful to compute the match function. Therefore, I'll mark this issue as ToDo.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working debugger
Projects
None yet
Development

No branches or pull requests

1 participant