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

fix Issue 22590 - importC: static functions have no debug information… #13640

Merged
merged 1 commit into from Feb 12, 2022

Conversation

WalterBright
Copy link
Member

… generated for them

Let's see if this works.

@WalterBright WalterBright added Easy Review ImportC Pertaining to ImportC support labels Feb 11, 2022
@dlang-bot
Copy link
Contributor

Thanks for your pull request, @WalterBright!

Bugzilla references

Auto-close Bugzilla Severity Description
22590 normal importC: static functions have no debug information generated for them

Testing this PR locally

If you don't have a local development environment setup, you can use Digger to test this PR:

dub run digger -- build "master + dmd#13640"

@thewilsonator
Copy link
Contributor

test?

@ibuclaw
Copy link
Member

ibuclaw commented Feb 11, 2022

I pretty much dictated the fix in the issue, so I know that this will make debug generation work for static functions.

But why?

@WalterBright
Copy link
Member Author

The SDsym is set when functions are placed in COMDATs. But static symbols are not in COMDATs.

@WalterBright
Copy link
Member Author

@thewilsonator we don't have a good way to test debug info generation.

@RazvanN7
Copy link
Contributor

@thewilsonator historically, PRs that fixed debug info issues were not required any tests. Although, a fail compilation tests which ends up in a SEGV for which the output is checked by a bash script wouldn't be too difficult to add.

@MoonlightSentinel
Copy link
Contributor

@thewilsonator historically, PRs that fixed debug info issues were not required any tests. Although, a fail compilation tests which ends up in a SEGV for which the output is checked by a bash script wouldn't be too difficult to add.

False. The test runner explicitly supports GDB_SCRIPT for that purpose.

See e.g. https://github.com/dlang/dmd/blob/f0d454a3dadeb70a51e780705126e49258c815fc/test/runnable/gdb4149.d

@WalterBright
Copy link
Member Author

@MoonlightSentinel great! Can you show how to make one for this?

@MoonlightSentinel
Copy link
Contributor

A small example:

/// runnable/debuginfo.c
/*
REQUIRED_ARGS: -g
PERMUTE_ARGS:
GDB_SCRIPT:
---
run
---
GDB_MATCH: \*ptr = 1
*/

static
void foo(int* ptr)
{
    *ptr = 1;
}

int main(int argc, char** argv)
{
    foo(0);
    return 0;
}

GDB will print the line number + *ptr = 1 when foo isn't marked as static.

@maxhaton
Copy link
Member

@WalterBright #13081 is another small example

@WalterBright
Copy link
Member Author

@MoonlightSentinel thanks I added your example as a test.

@ibuclaw ibuclaw merged commit 94386a1 into dlang:master Feb 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
7 participants