Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dbgfile contains no reference to static locals #2349

Open
pm100 opened this issue Jan 10, 2024 · 2 comments
Open

dbgfile contains no reference to static locals #2349

pm100 opened this issue Jan 10, 2024 · 2 comments

Comments

@pm100
Copy link
Contributor

pm100 commented Jan 10, 2024

the -g -dbgfile combination outputs a ton of info however it misses information on local static variables

int main{
  int foo;
}

generates a .dbg that eventually ends up as a csym in the dbgfile

int foo;
int main{

}

generates a .export that ends up as a sym in dbgfile (but notably not a csym, and with the name '_foo', not 'foo', however functions in c get csyms with their c names)

static int foo;
in main(){
}

does not generate a .export but still appears as a sym in dbgfile (again with its internal name)
but

int main{
 static int foo;
}

or

int main{
#pragma static-locals(on)
  int foo;
}

They both generate internal symbols (M0001) that are propagated to the dbgfile but there is no way to match the name in the c code with the name in the C file

THe obvious solution seems to be to change the symbol name to be main_foo rather than M0001. This will, however, break any code that is reading the dbgfile and expecting to see M0001. So an alternative would be

main_foo:
M0001:
	.res	2,$00
@acqn
Copy link
Contributor

acqn commented Jan 10, 2024

There can be multiple static locals with the same identifier in the same function:

int main()
{
    static int foo;
    {
        static int foo; /* This shadows the previous static local 'foo' */
    }
}

So the name mangling has to be a bit more complex.

@colinleroy
Copy link
Contributor

There can be multiple static locals with the same identifier in the same function:

int main()
{
    static int foo;
    {
        static int foo; /* This shadows the previous static local 'foo' */
    }
}

So the name mangling has to be a bit more complex.

Something that'd help debugging for auto variables, (the ones that get M0001 symbols with no csym), could be to have
foo_M0001, foo_M0002 as identifiers.

I gave a look at how it could be done and still, it seems complicated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants