1. phix and debugging question
- Posted by begin Jun 08, 2018
- 2373 views
hi, i have rather large and complex program now. when i run it, it seems it will go off in a loop at some point, which i can not pinpoint. i tried with profile and with trace, but trace does not work at all. a control c does not go to the source on stopping.
how does one best debug this situation with phix?
any pointers very welcome
richard
2. Re: phix and debugging question
- Posted by petelomax Jun 08, 2018
- 2332 views
I assume you have read http://phix.x10.mx/docs/html/debugging.htm
The "DEV (ctrace.out not yet supported)" comment should have been deleted some time ago.
with profile[_time] won't do anything until the program terminates successfully.
with trace by itself won't do anything; you need a trace(1) to start an interactive trace or trace(3) to start writing ctrace.out.
From the sound of things I'd recommend the latter, after <ctrl c> to kill the runaway app you should be able to inspect ctrace.out
to figure out what it was up to. You can also do things like this:
without trace include pGUI.e include builtins\VM\pcfunc.e with trace
so that lines from those files are omitted from the ctrace.out file. Repeat that sort of thing (for any code, not just includes) a few times until you get a clear picture of where it is going loopy.
Pete
3. Re: phix and debugging question
- Posted by begin Jun 08, 2018
- 2283 views
thanks for the advice. i tried that. i used
with trace trace(3)
i get
Reading h:/Euphoriaprog/Microexp/discount1.kb ................................................................................................... Parsing done! pDiagN.e line 3041: oops, rtn[=9134] out of range[1..2739] H:\Euphoriaprog\Microexp\myinferer_4.ew:-1 (era=#007399B7, from_addr=#0261FD32, ret_addr=#0261FD3E) in procedure init_infer() subscript is not an atom ... called from H:\Euphoriaprog\Microexp\testmicroexp.ew:11 Global & Local Variables --> see H:\Euphoriaprog\Microexp\ex.err Press Enter...
it's an expert system that constructs a lot of lists. is it possible to change [1..2739] to something larger in pDiagN.e?
richard
sorry i forget. the
public procedure init_infer() done = false goal_list = {} how_list = {} context = {} line_count = 0 active_rule = repeat(true, biggest_rule) clear_screen() end procedure
where biggest_rule = 13. i am using the 64 bit phix.
4. Re: phix and debugging question
- Posted by petelomax Jun 08, 2018
- 2273 views
i get
pDiagN.e line 3041: oops, rtn[=9134] out of range[1..2739] H:\Euphoriaprog\Microexp\myinferer_4.ew:-1 (era=#007399B7, from_addr=#0261FD32, ret_addr=#0261FD3E) in procedure init_infer() subscript is not an atom
Hmm. That routine does not seem to be doing any subscripting.
Try p -d testmicroexp.ew, then run the resulting .exe, then see if you can find the (new, +/-1) era/from/ret addresses in the list.asm, and post those snippets here
[EDIT]: DOH - it is probably trace(3) going wrong, and that may not help at all...
is it possible to change [1..2739] to something larger in pDiagN.e?
That refers to symtab being only 2739 entries long, but it has encountered a routine[-id] of 9134, so not really.
There is a mapping as the table is compacted, and there is a (sadly) now broken mapsymtab flag in pEmit2.e that
used to disable that compacting/mapping. I guess you could edit that flag, try "p p testmicroexp.ew", and edit it
back after seeing what happens (I wouldn't bother trying to recompile phix though)....
You might also try setting showmapsymtab (also in pEmit2.e) to 9134, and possibly retry if/while that changes the error,
again using the "p p xxx" method rather than bothering to rebuild phix, and undo that edit asap.
i am using the 64 bit phix.
It may be worth giving it a spin on 32 bit, see if that offers any better clues.
(Obviously I fix whatever I can, but 32 bit is simply much more thoroughly tested.)
Pete
5. Re: phix and debugging question
- Posted by begin Jun 09, 2018
- 2248 views
i renamed my old phix folder and installed anew with a setup from your website and left it as 32bit.
the test source i compile is:
include memory.ew include reader.ew include myinferer_4.ew integer err = Parse() with trace trace(3) init_infer() infer()
Reading h:/Euphoriaprog/Microexp/discount1.kb ................................................................................................... Parsing done! pDiagN.e line 3300: symtab[220] bad S_NTyp[1] "sleep(5)..." pDiagN.e line 3041: oops, rtn[=8841] out of range[1..2625] pDiagN.e line 3041: oops, rtn[=9133] out of range[1..2625] H:\Euphoriaprog\Microexp\testmicroexp.ew:-1 (era=#00600DDC, from_addr=#0, ret_addr=#0) type check failure, ???(varno=8738[or_ecx=#00002222]) is ??? Global & Local Variables --> see H:\Euphoriaprog\Microexp\ex.err Press Enter...
is displayed. ex.err (shortened):
pDiagN.e line 3300: symtab[220] bad S_NTyp[1] H:\Euphoriaprog\Microexp\testmicroexp.ew:-1 (era=#00600DDC, from_addr=#0, ret_addr=#0) type check failure, ???(varno=8738[or_ecx=#00002222]) is ??? Global & Local Variables H:\Euphoriaprog\Microexp\memory.ew: attr_list[1] = {"Acme done",99'c',0,-1,"",{},"","the Acme order has /not/ been completed",-1} attr_list[2] = {"XYZ done",99'c',0,-1,"",{},"","the XYZ Company order has /not/ been completed",-1} .... H:\Euphoriaprog\Microexp\reader.ew: token = {3} line = "" rule_name = "h:/Euphoriaprog/Microexp/discount1.kb" cf = "" attr = "OK done" pred = "IS" val = "yes" parm_word = "58" error = 0 defaultcf = 90'Z' rule_file = 3 error_in_line = 0 rule_no = 13 kind = 3 currcon = 1000 lastcon = 1000 confidence = 0 func_list = {} H:\Euphoriaprog\Microexp\myinferer_4.ew: goal_list = {} how_list = {} context = {} main_list = {} why_ptr = {} prmpt_ptr = {} proc_item = {} true_rules = {} answer_list = {} mark_context = {} done = 0 line_count = 0 p_pos = 0 main_goal = "" H:\Euphoriaprog\Microexp\testmicroexp.ew: err = 1 h:\Phix\builtins\get.e: input_file = <novalue> input_string = <novalue> string_next = 0 ch = 0 get_line_no = 0 h:\Phix\builtins\VM\pprntfN.e: init2 = 1 inf = inf nan = nan hexchar = "0123456789ABCDEFabcdef" bases = {10,16,8,2} h:\Phix\builtins\scanf.e: baseset = <novalue> binit = 0 ch = 56'8'
no trace file is created.
without the trace the program executes and runs into maybe some loop.
6. Re: phix and debugging question
- Posted by petelomax Jun 09, 2018
- 2241 views
type check failure, ???(varno=8738[or_ecx=#00002222]) is ???
Can you have a look in the list.asm and see what symtab[8738] is (plus 10 either either side) for me.
Also, you may want to try both "p -d xxx" and "p -d! xxx".
One other thing you can try is trace(1), hit F6 (animate) and let it run for half an hour, see if that manages to reach the loopy bit.
7. Re: phix and debugging question
- Posted by begin Jun 09, 2018
- 2248 views
- Last edited Jun 30, 2018
type check failure, ???(varno=8738[or_ecx=#00002222]) is ???
Can you have a look in the list.asm and see what symtab[8738] is (plus 10 either either side) for me.
Also, you may want to try both "p -d xxx" and "p -d! xxx".
p -d! xxx :
symtab[1]:{integer,S_Type,0,(S_used+K_used+K_gbl),0,0,{84'T',1},0,1,0,#0000003A} symtab[2]:{T_N,S_Type,0,(K_used+K_gbl),0,0,T,0,0,0,#FFFFFFFF} symtab[3]:{atom,S_Type,0,(S_used+K_used+K_gbl),0,0,{84'T',3},0,1,0,#0000003B} ... edited out....
last of symtab = 2625
p -d xxxxx:
symtab[2614]:{prompt,S_TVar,59,(S_used+S_set+K_used+K_wdb+K_othr+K_dlft),2609,2615,string,{string,MININT,MAXINT,integer,28},[esp]} symtab[2615]:{con,S_TVar,59,(S_used+S_set+K_used+K_wdb+K_othr+K_dlft),2610,0,integer,{integer,1,1,object,-1},[esp-4]} ... edited out
last of symtab = 2615
will start trace(1) F6 now
richard
8. Re: phix and debugging question
- Posted by begin Jun 09, 2018
- 2242 views
trace(1) and F6 dies with
pDiagN.e line 3300: symtab[220] bad S_NTyp[1] H:\Euphoriaprog\Microexp\testmicroexp.ew:-1 (era=#00600DDC, from_addr=#0, ret_addr=#0) type check failure, ???(varno=8738[or_ecx=#00002222]) is ???
EDIT
symtab[219]:{-1,S_TVar,0,(S_set),0,0,object,{object,MININT,MAXINT,object,-2},[esp-52]} symtab[220]:{fdelete,S_Proc,9,(S_used+K_used+K_wdb+K_ridt),0,232,{80'P',15},221,1,3,#0045477A} symtab[221]:{o,S_TVar,9,(S_used+S_set+K_used+K_wdb+K_othr),0,222,object,{object,MININT,MAXINT,object,-2},[esp]}
richard
ps. if you don' need tzhe symtab (previous post) any more, i edit and delete them - to shorten the post.
9. Re: phix and debugging question
- Posted by petelomax Jun 14, 2018
- 2101 views
trace(1) and F6 dies with
pDiagN.e line 3300: symtab[220] bad S_NTyp[1] H:\Euphoriaprog\Microexp\testmicroexp.ew:-1 (era=#00600DDC, from_addr=#0, ret_addr=#0) type check failure, ???(varno=8738[or_ecx=#00002222]) is ???
Can you try grabbing a fuller screenshot? For example, running Greg's "wrong file mode for attempted operation" sample as recently posted, trace(1) F6 (and <Ctrl A><CR>) gives me:
..Files (x86)\Phix\builtins\database.e F1=main F2=trace F3=help ? q Q ! 296: end function 297: 298: procedure put1(integer x) 299: -- write 1 byte to current database file 300: puts(current_db, x) 301: end procedure 302: 303: procedure put4(atom x) 304: -- write 4 bytes to current database file 305: -- x is 32-bits max 306: poke4(mem0, x) -- faster than doing divides etc. 307==> puts(current_db, peek(memseq)) C:\Program Files (x86)\Phix\builtins\database.e:307 in procedure put4() wrong file mode for attempted operation x = 45ocedure putn(sequence s) ... called from C:\Program Files (x86)\Phix\builtins\database.e:508 in function db_allocate()uts(current_db, s) n = 41d procedure free_list = <novalue> size = <novalue>fe_seek(atom pos) size_ptr = <novalue>ition in the current db file addr = <novalue>current_db, pos)!=0 then free_count = 0tal(sprintf("seek to position %d failed!\n", pos)) remaining = <novalue> i = <novalue> Global & Local Variables --> see C:\Program Files (x86)\Phix\ex.err Press Enter...
So obviously, in that case, it is failing on line 307 (and obviously the fact that you get a line number of -1 instead, is the biggest problem here).
Hopefully that somewhat garbled screen may contain some vital clues missing from the ex.err.
ps if you don' need the symtab (previous post) any more, i edit and delete them - to shorten the post.
yeah, that may as well go now.
Pete
10. Re: phix and debugging question
- Posted by begin Jun 14, 2018
- 2102 views
i can't do that - like greg. the program runs off into a loop, it doesn't crash or anything like that. i run out of memory eventually, the program fails without any messages. i wish it would crash.
richard
11. Re: phix and debugging question
- Posted by petelomax Jun 18, 2018
- 1975 views
Your only options now are either upload something I can run, or laboriously go through adding print statements, eg
include memory.ew include reader.ew include myinferer_4.ew integer err = Parse() --?"got here" init_infer() ?"got here" infer() ?"did not get here"
and, assuming those statements reflect reality, putting similar statements inside the infer() routine, and just keep on narrowing it down as far as possible.
Pete