kevinpt / opbasm

Open PicoBlaze Assembler
http://kevinpt.github.io/opbasm/
MIT License
60 stars 13 forks source link

Error in index_expanded_line_numbers() #12

Closed seamusbleu closed 7 years ago

seamusbleu commented 8 years ago

Tried to use m4 and it bombs on line 792. I first tried a normal .psm file with the --m4 option, failed. Then I tried it on load.psm4 in the .\test\asm directory, failed. Problem(s) are that active_file = None and source_lines = {}.

Traceback (most recent call last): File "C:\Tools\opbasm-1.3\opbasm.py", line 2530, in main() File "C:\Tools\opbasm-1.3\opbasm.py", line 2381, in main for fname in asm.process_includes(): File "C:\Tools\opbasm-1.3\opbasm.py", line 810, in process_includes pp_source_file = self.preprocess_with_m4(source_file) File "C:\Tools\opbasm-1.3\opbasm.py", line 687, in preprocess_with_m4 self.index_expanded_line_numbers(m4_result, pp_source_file, source_file) File "C:\Tools\opbasm-1.3\opbasm.py", line 792, in index_expanded_line_numbers index.append((cur_line, source_lines[active_file], active_file)) KeyError: None

kevinpt commented 7 years ago

I can't reproduce this issue. Can you provide an exact command line, directory you're executing from, and the Python version that triggers the problem for you.

A crude fix would be to change line 782 to "active_file = source_file" but that introduces some subtle bugs with tracking line numbers in included files. In all my test cases m4 puts out a syncline entry as the first line of the expanded source code so the else condition is never reached before active_file has been set. The regex must be failing for some unexpected reason.

I have added a --verbose command line option to the Github repo head which is at version 1.3.2. If you install that and run with the verbose option on it will print the exact m4 command line to the output. Can you manually run that command, replacing the final "-" with the path to load.psm4, and capture the output to a file. Version 1.3.2 will also terminate with an error message when active_file is None. Please copy the result from that.

You can install direct from the repo using pip without needing git installed: pip install --upgrade https://github.com/kevinpt/opbasm/tarball/master

seamusbleu commented 7 years ago
It's been quite awhile since I visited this, but since you were kind enough to reply I looked into it.  I was using the opbasm by calling the python script, ala:"c:opbasm.py -i i2c_pb.psm -t ROM_form.vhd -6 -m 2048 -n i2c_rom"Not sure if that was right, but in trying to figure out where I was, I see opbasm.exe in the python scripts directory, so I substituted that for opbasm.py and viola, it compiled without errors.  That probably means it was operator error on my part.  Not sure, but good enough for now.  I think I asked you already, but just in case, I'll ask again.  Would it be possible to support Mediatronix syntax with opbasm?  I find it much nicer than the Xilinx syntax, and that's what all my current code is written in.Thanks - Woody-----Original Message----- From: kevinpt Sent: Sep 26, 2016 9:26 PM To: kevinpt/opbasm Cc: seamusbleu , Author Subject: Re: [kevinpt/opbasm] Error in index_expanded_line_numbers() (#12) I can't reproduce this issue. Can you provide an exact command line, directory you're executing from, and the Python version that triggers the problem for you. A crude fix would be to change line 782 to "active_file = source_file" but that introduces some subtle bugs with tracking line numbers in included files. In all my test cases m4 puts out a syncline entry as the first line of the expanded source code so the else condition is never reached before active_file has been set. The regex must be failing for some unexpected reason. I have added a --verbose command line option to the Github repo head which is at version 1.3.2. If you install that and run with the verbose option on it will print the exact m4 command line to the output. Can you manually run that command, replacing the final "-" with the path to load.psm4, and capture the output to a file. Version 1.3.2 will also terminate with an error message when active_file is None. Please copy the result from that. You can install direct from the repo using pip without needing git installed: pip install --upgrade https://github.com/kevinpt/opbasm/tarball/master —You are receiving this because you authored the thread.Reply to this email directly, view it on GitHub, or mute the thread. {"api_version":"1.0","publisher":{"api_key":"05dde50f1d1a384dd78767c55493e4bb","name":"GitHub"},"entity":{"external_key":"github/kevinpt/opbasm","title":"kevinpt/opbasm","subtitle":"GitHub repository","main_image_url":"https://cloud.githubusercontent.com/assets/143418/17495839/a5054eac-5d88-11e6-95fc-7290892c7bb5.png","avatar_image_url":"https://cloud.githubusercontent.com/assets/143418/15842166/7c72db34-2c0b-11e6-9aed-b52498112777.png","action":{"name":"Open in GitHub","url":"https://github.com/kevinpt/opbasm"}},"updates":{"snippets":[{"icon":"PERSON","message":"@kevinpt in #12: I can't reproduce this issue. Can you provide an exact command line, directory you're executing from, and the Python version that triggers the problem for you.\r\n\r\nA crude fix would be to change line 782 to \"active_file = source_file\" but that introduces some subtle bugs with tracking line numbers in included files. In all my test cases m4 puts out a syncline entry as the first line of the expanded source code so the else condition is never reached before active_file has been set. The regex must be failing for some unexpected reason.\r\n\r\nI have added a --verbose command line option to the Github repo head which is at version 1.3.2. If you install that and run with the verbose option on it will print the exact m4 command line to the output. Can you manually run that command, replacing the final \"-\" with the path to load.psm4, and capture the output to a file. Version 1.3.2 will also terminate with an error message when active_file is None. Please copy the result from that.\r\n\r\nYou can install direct from the repo using pip without needing git installed:\r\n pip install --upgrade https://github.com/kevinpt/opbasm/tarball/master"}],"action":{"name":"View Issue","url":"https://github.com/kevinpt/opbasm/issues/12#issuecomment-249750255"}}}