no longer works with Python 3.12
When running diff.py with Python 3.12.1, I get a number of warnings, and it is no longer able to correctly parse the map file.
/diff.py CARDRenameAsync
/home/cameron/Sources/smb-decomp/./diff.py:1240: SyntaxWarning: invalid escape sequence '\S'
+ "(\S+)",
/home/cameron/Sources/smb-decomp/./diff.py:3200: SyntaxWarning: invalid escape sequence '\.'
if source_line and re.fullmatch(".*\.c(?:pp)?:\d+", source_line):
/home/cameron/Sources/smb-decomp/./diff.py:1024: DeprecationWarning: ast.Num is deprecated and will be removed in Python 3.14; use ast.Constant instead
if isinstance(node, ast.Num): # <number>
/home/cameron/Sources/smb-decomp/./diff.py:1025: DeprecationWarning: Attribute n is deprecated and will be removed in Python 3.14; use value instead
return node.n
Not able to find function in map file.
965eaa30535109e2b4f237df38ea93f2aabd5101 fixes those warnings, does that help?
There's still another one.
./diff.py:1034: DeprecationWarning: ast.Num is deprecated and will be removed in Python 3.14; use ast.Constant instead
elif hasattr(ast, "Num") and isinstance(node, ast.Num): # <number>, pre 3.8
Right, fixed in 738c7af49503c2cf0d671f5191036d34ed6f6906. Does the map file parsing work now?
The regex doesn't appear to be compatible with the map file anymore, at least the one in my smb-decomp repo. I seem to remember the map file format changed between CodeWarrior versions.
Does it work with older Python versions? I don't have the smb-decomp repo set up nor any knowledge of the cw map file format, so I think this would best be fixed by someone on your side debugging what the issue could be.
My distro doesn't have any older Python versions, but I'm 99% sure it's an issue with the regex. I'll look into it later and see what the differences are.
SMB's map file format looks like this
.text section layout
Starting Virtual
address Size address
-----------------------
00000000 000000 800065a0 1 .text c++_exception_data.s.o
00000000 0002f8 800065a0 1 .text main.c.o
00000000 0002f8 800065a0 4 main main.c.o
000002f8 0006f0 80006898 1 .text init.c.o
000002f8 000060 80006898 4 initialize init.c.o
00000358 000184 800068f8 4 init_gx init.c.o
000004dc 0000b4 80006a7c 4 init_tv init.c.o
00000590 000058 80006b30 4 init_vi init.c.o
000005e8 00009c 80006b88 4 init_gx_2 init.c.o
00000684 000024 80006c24 4 init_dvd init.c.o
000006a8 000260 80006c48 4 init_heaps init.c.o
00000908 00008c 80006ea8 4 init_rel init.c.o
00000994 000054 80006f34 4 init_cache init.c.o
000009e8 0000ac 80006f88 1 .text init_2.c.o
000009e8 0000ac 80006f88 4 init_cache_ptrs init_2.c.o
00000a94 00249c 80007034 1 .text mathutil.c.o
00000a94 00004c 80007034 4 mathutil_init mathutil.c.o
00000ae0 000030 80007080 4 float_return_values mathutil.c.o
The first field looks to be the offset into the section, the second field is the size, and the third field is the virtual (RAM) address.