SDCC : z80/sm83/mos6502 TD- 4.3.0 #14110 (Linux)
Issue
When the function in the example code below is added it prevents the const arrays declared above it from showing up in the debug .adb file (and eventual .cdb output). The const arrays declared below the function still show up. The non-const arrays all show up in the .adb file output without issue.
I investigated some and it seems that when flushStatics() (src/SDCCglue.c) gets called from genZ80Code() (src/z80/gen.c), that clears the contents of statsg before they have a chance to be written out to the .adb file when glue() calls outputDebugSymbols() (src/SDCCdebug.c).
I don't know sdcc well enough to understand the full consequences and if this is just a bad hack, but adding a call to outputDebugSymbols() in flushStatics() does seem to fix the issue without generating duplicate debug information (at least in the case of this example code).
Basically making sure that any static symbols that would get cleared first have their debug info written out. Maybe that could be reduced to just writing out the statsg debug symbols since those are the only ones getting cleared?
Example code
sdcc -msm83 --no-std-crt0 --fsigned-char --use-stdout -Wa-pogn --debug -c test.c -o test.o
unsigned char array_ram_1[19];
static unsigned char array_s_ram_1[19];
const unsigned char array_const_1[] = { 1,2,3,4,5,6,7,8,9 };
static const unsigned char array_s_const_1[] = {1,2,3,4,5,6,7,8,9};
unsigned char array_ram_2[19];
static unsigned char array_s_ram_2[19];
const unsigned char array_const_2[] = { 1,2,3,4,5,6,7,8,9 };
static const unsigned char array_s_const_2[] = {1,2,3,4,5,6,7,8,9};
// This function removes export of const variables above it function to .adb file and eventual .cdb output
void test(void) {
}
unsigned char array_ram_3[19];
static unsigned char array_s_ram_3[19];
const unsigned char array_const_3[] = { 1,2,3,4,5,6,7,8,9 };
static const unsigned char array_s_const_3[] = {1,2,3,4,5,6,7,8,9};