Skip to content

[lldb] Add include for SBLanguages in lldb-enumerations #111907

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

Merged

Conversation

chelcassanova
Copy link
Contributor

This adds an include for SBLanguages.h in lldb-enumerations.h so that files that need this enum do not have to explicitly include SBLanguages.

@llvmbot
Copy link
Member

llvmbot commented Oct 10, 2024

@llvm/pr-subscribers-lldb

Author: Chelsea Cassanova (chelcassanova)

Changes

This adds an include for SBLanguages.h in lldb-enumerations.h so that files that need this enum do not have to explicitly include SBLanguages.


Full diff: https://github.com/llvm/llvm-project/pull/111907.diff

1 Files Affected:

  • (modified) lldb/include/lldb/lldb-enumerations.h (+1)
diff --git a/lldb/include/lldb/lldb-enumerations.h b/lldb/include/lldb/lldb-enumerations.h
index 938f6e3abe8f2a..df3aadcb0689c6 100644
--- a/lldb/include/lldb/lldb-enumerations.h
+++ b/lldb/include/lldb/lldb-enumerations.h
@@ -11,6 +11,7 @@
 
 #include <cstdint>
 #include <type_traits>
+#include <lldb/API/SBLanguages.h>
 
 #ifndef SWIG
 // Macro to enable bitmask operations on an enum.  Without this, Enum | Enum

Copy link

github-actions bot commented Oct 10, 2024

✅ With the latest revision this PR passed the C/C++ code formatter.

Copy link
Member

@medismailben medismailben left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM with format fix

@chelcassanova chelcassanova force-pushed the add-sblanguages-include-to-enumerations branch from 133ace4 to c179c08 Compare October 10, 2024 20:07
This adds an include for SBLanguages.h in lldb-enumerations.h so that
files that need this enum do not have to explicitly include SBLanguages.
@chelcassanova chelcassanova force-pushed the add-sblanguages-include-to-enumerations branch from c179c08 to e439392 Compare October 10, 2024 20:10
@chelcassanova chelcassanova merged commit b355426 into llvm:main Oct 10, 2024
5 of 6 checks passed
@vvereschaka
Copy link
Contributor

@chelcassanova lldb/API/SBLanguages.h is generated file. I suppose its generation must be enabled for the lldb-server target in that case; otherwise we get the following build errors:

In file included from /home/buildbot/worker/as-builder-9/lldb-remote-linux-ubuntu/llvm-project/lldb/include/lldb/lldb-types.h:12:
/home/buildbot/worker/as-builder-9/lldb-remote-linux-ubuntu/llvm-project/lldb/include/lldb/lldb-enumerations.h:15:10: fatal error: 'lldb/API/SBLanguages.h' file not found
   15 | #include <lldb/API/SBLanguages.h>
      |          ^~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.

https://lab.llvm.org/staging/#/builders/195/builds/4266

i.e. when only 'lldb-server' target gets built (cmake --build . --target lldb-server)

jasonmolenda added a commit that referenced this pull request Oct 10, 2024
)"

Temporarily Revert until Chelsea can look at this.  With a clean build,
SBLanguages.h won't be generated in the build directory at the point
when it is included by lldb-enumerations when compiling e.g.
Broadcaster.cpp.  On a clean build (no pre-existing build directory),
the dependency ordering is not explicitly stated so the build will fail.
An incremental build will succeed.

This reverts commit b355426.
Copy link
Collaborator

@jimingham jimingham left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This layering seems wrong to me. If you put an SB header in lldb-enumerations.h, then you are pretty much including it in all of lldb. But SB defines should really only be used in include/lldb/API and source/API.
Note, SBLanguages.h itself seems wrong to me. It is used to pass a language name enum to SBExpressionOptions::SetLanguage, which turns around and calls EvaluateExpressionOptions::SetLanguage, but in that latter API we call the parameter a uint16_t. Why didn't we make an lldb-languages.h and include that in some place that both the SB caller and the lldb API it wraps can share it on the up-and-up?

@chelcassanova
Copy link
Contributor Author

I was going to fix the dependency issue here to make sure that SBLanguages gets generated before trying to build any of these targets, but talking with @jimingham, this shouldn't have been included at all as lldb-enumerations shouldn't be exposed to any SB layer components whatsoever.

@bulbazord
Copy link
Member

My mental model is that everything in lldb-enumerations.h should be public and all the private enumerations should go in lldb-private-enumerations.h. In practice I think there are tons of things in lldb-enumerations.h that should not be public at all, but I'm not sure which are safe to remove since they're all exposed through the Python bindings.

@jimingham
Copy link
Collaborator

jimingham commented Oct 10, 2024 via email

medismailben added a commit to medismailben/llvm-project that referenced this pull request Oct 11, 2024
This patch moves `SBLanguages.h` out of the API tree. This file gets
generated at build time using DWARF table-gen file and contains an
enumeration of the DWARF supported source language names and there
respective code/identifier.

Since this is an enum, this shouldn't be part of the API tree but rather
it should be included in the `lldb-enumeration` header.

Also, that enum was used in internal methods in `lldb_private` by
down-casting the enum value type to an `uint16_t`.
This patch changes that by making those internal methods use the enum
type.

This should address the feedbacks from llvm#111907.

Signed-off-by: Med Ismail Bennani <[email protected]>
@bulbazord
Copy link
Member

I agree with that, but the argument here was going the other way. lldb-enumerations.h are a base set of enumerations that anybody using LLDB, either lldb_private or the SB API's are free to use. But the SB API's are purely wrappers around lldb_private API's, and so should never be used in lldb_private. If you put an SB API header in lldb-enumerations.h, now most of lldb_private is going to see it. Does that also fit wth your mental model? Jim

Generally no, though I kind of think the enumeration shouldn't belong in the API directory to begin with. I see Ismail changed that so it seems like we're on the same page here.

@medismailben
Copy link
Member

medismailben commented Oct 11, 2024

I agree with that, but the argument here was going the other way. lldb-enumerations.h are a base set of enumerations that anybody using LLDB, either lldb_private or the SB API's are free to use. But the SB API's are purely wrappers around lldb_private API's, and so should never be used in lldb_private. If you put an SB API header in lldb-enumerations.h, now most of lldb_private is going to see it. Does that also fit wth your mental model? Jim

Generally no, though I kind of think the enumeration shouldn't belong in the API directory to begin with. I see Ismail changed that so it seems like we're on the same page here.

+1, may be there was a limitation explaining why it was put in the API tree but I didn't bump into any issue in #111929. May be @adrian-prantl has some more context with regard to that ?

medismailben added a commit to medismailben/llvm-project that referenced this pull request Oct 11, 2024
This patch moves `SBLanguages.h` out of the API tree. This file gets
generated at build time using DWARF table-gen file and contains an
enumeration of the DWARF supported source language names and there
respective code/identifier.

Since this is an enum, this shouldn't be part of the API tree but rather
it should be included in the `lldb-enumeration` header.

Also, that enum was used in internal methods in `lldb_private` by
down-casting the enum value type to an `uint16_t`.
This patch changes that by making those internal methods use the enum
type.

This should address the feedbacks from llvm#111907.

Signed-off-by: Med Ismail Bennani <[email protected]>
medismailben added a commit to medismailben/llvm-project that referenced this pull request Oct 14, 2024
This patch moves `SBLanguages.h` out of the API tree. This file gets
generated at build time using DWARF table-gen file and contains an
enumeration of the DWARF supported source language names and there
respective code/identifier.

Since this is an enum, this shouldn't be part of the API tree but rather
it should be included in the `lldb-enumeration` header.

Also, that enum was used in internal methods in `lldb_private` by
down-casting the enum value type to an `uint16_t`.
This patch changes that by making those internal methods use the enum
type.

This should address the feedbacks from llvm#111907.

Signed-off-by: Med Ismail Bennani <[email protected]>
DanielCChen pushed a commit to DanielCChen/llvm-project that referenced this pull request Oct 16, 2024
This adds an include for SBLanguages.h in lldb-enumerations.h so that
files that need this enum do not have to explicitly include SBLanguages.
DanielCChen pushed a commit to DanielCChen/llvm-project that referenced this pull request Oct 16, 2024
…#111907)"

Temporarily Revert until Chelsea can look at this.  With a clean build,
SBLanguages.h won't be generated in the build directory at the point
when it is included by lldb-enumerations when compiling e.g.
Broadcaster.cpp.  On a clean build (no pre-existing build directory),
the dependency ordering is not explicitly stated so the build will fail.
An incremental build will succeed.

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

Successfully merging this pull request may close these issues.

6 participants