how can I import in the openmsx debugger the symbols generated by sdcc?

ページ 1/2
| 2

By ARTRAG

Enlighted (6845)

ARTRAG さんの画像

26-02-2022, 23:54

Is it possible?

Is there any debugger able to use the sym files from sdcc?

ログイン/登録して投稿

By Grauw

Ascended (10581)

Grauw さんの画像

27-02-2022, 01:37

I don’t know the details of the SDCC symbol file format, but as part of your build process you could convert the sym file to the common label: equ 0000h format with what should be a fairly simple script or even just sed.

By jepmsx

Master (131)

jepmsx さんの画像

27-02-2022, 06:33

You need to create the symbol files in the debugger format.

I have a script in python https://gitlab.com/brossaip/msx_bricks/-/blob/main/create_sy... that does this. It uses the lst and map file to creat a sym file with information of the instruction that is being debugged. I've used it several times and it woks well for me.

Any improvement is welcome

By ARTRAG

Enlighted (6845)

ARTRAG さんの画像

27-02-2022, 12:13

Thanks! Going to test your script

By Bengalack

Hero (580)

Bengalack さんの画像

27-02-2022, 14:38

You can get away with just using the map-file though, unless there is something I overlook.

By ARTRAG

Enlighted (6845)

ARTRAG さんの画像

27-02-2022, 15:02

Hi jepmsx
I've tried you script map and lst files in the sub directory build\ in my project
https://github.com/artrag/SDCC-msx2-side-scrolling-platform-...

From the command line I use
py create_sym_debug.py build\mytestrom

Your script gives the following errors I cannot understand and generates empty files

F:\SDCC\MSX_Fusion-C_V1.3\WorkingFolder\sdcc_megarom-master>py create_sym_debug.py build\mytestrom
Traceback (most recent call last):
  File "F:\SDCC\MSX_Fusion-C_V1.3\WorkingFolder\sdcc_megarom-master\create_sym_debug.py", line 37, in 
    adrecaBase = dicMap[nomFunc]
KeyError: '_main'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "F:\SDCC\MSX_Fusion-C_V1.3\WorkingFolder\sdcc_megarom-master\create_sym_debug.py", line 41, in 
    adrecaBase = adrecaBase + comptaBytesInit
NameError: name 'adrecaBase' is not defined

F:\SDCC\MSX_Fusion-C_V1.3\WorkingFolder\sdcc_megarom-master>

Any suggestion on what could be wrong?

By Bengalack

Hero (580)

Bengalack さんの画像

27-02-2022, 15:03

Oh, to clarify, by "just", I do not mean that openmsx accepts it, but you only need to parse one file (just ignore symbols starting with "l__", "s__" and ".__").

By ARTRAG

Enlighted (6845)

ARTRAG さんの画像

27-02-2022, 15:05

Bengalack wrote:

You can get away with just using the map-file though, unless there is something I overlook.

Openmsx debugger 0.10.0-282-g3a4538a does not acept the MAP files from SDCC, no symbol is recognised. Is there a different version compatible with SDCC files?

By Bengalack

Hero (580)

Bengalack さんの画像

27-02-2022, 15:06

Try this, based on DamnedAngel's script:

import string
import sys
import os

# Build symbol file from map-file
# (argv[0]: python filename) 
# argv[1]: filename without extension
# argv[2]: path
def is_hex(s):
	try:
		int(s, 16)
		return True
	except ValueError:
		return False

f1 = open(sys.argv[1] + os.path.sep + sys.argv[2] + '_.sym','w')

with open(sys.argv[1] + os.path.sep + sys.argv[2] + '.map','r') as f2:
	for line in f2:
		line1 = line.strip()
		words = line1.split()
		if len(words) > 1:
			if words[1].startswith('l__') or words[1].startswith('s__') or words[1].startswith('.__'): 
				continue

			if is_hex(words[0]):
				f1.write( "%s: equ %sH\n" % (words[1], words[0]))

f2.close()
f1.close()

exit()


By ARTRAG

Enlighted (6845)

ARTRAG さんの画像

27-02-2022, 15:07

Bengalack wrote:

Oh, to clarify, by "just", I do not mean that openmsx accepts it, but you only need to parse one file (just ignore symbols starting with "l__", "s__" and ".__").

ok, I was looking for a ready tool or for a way to use the SDCC files

By Bengalack

Hero (580)

Bengalack さんの画像

27-02-2022, 15:19

I use the script pasted in above all the time. python makesymbolfile.py <filename> <path> and it will output a file in the path-dir called <filename>_.sym. Just note that symbols are cut at 32 characters (done in the map-file).

ページ 1/2
| 2