Skip to content

include/debug.h: Move to include/nuttx/debug.h#18660

Open
PiyushPatle26 wants to merge 1 commit intoapache:masterfrom
PiyushPatle26:include/refactor-debug-h-location
Open

include/debug.h: Move to include/nuttx/debug.h#18660
PiyushPatle26 wants to merge 1 commit intoapache:masterfrom
PiyushPatle26:include/refactor-debug-h-location

Conversation

@PiyushPatle26
Copy link
Copy Markdown
Contributor

@PiyushPatle26 PiyushPatle26 commented Apr 1, 2026

Note: Please adhere to Contributing Guidelines.

Summary

Move the NuttX-specific debug.h header from the top-level include/
directory to include/nuttx/debug.h, and update in-tree includes to use the new path.

debug.h is not a POSIX or standard C header. Keeping it at the top level
creates avoidable naming conflicts with external projects that also provide a
debug.h. Moving it under include/nuttx/ aligns it with NuttX conventions for non-standard headers.

A backward-compatibility shim is left at include/debug.h that emits a deprecation #warning
and re-includes <nuttx/debug.h>, allowing out-of-tree code to continue building while migrating.

Impact

  • Moves the header to include/nuttx/debug.h.
  • Updates in-tree references to include <nuttx/debug.h>.
  • Keeps backward compatibility for existing code that still includes <debug.h>.
  • Emits a deprecation warning for the old include path to encourage migration.
  • No intended functional change beyond header location and include path cleanup.

Other PR for nuttx_apps

Testing

Tested on Ubuntu Linux in the local NuttX tree.

Host:

  • Ubuntu Linux

Target:

  • native NuttX

Test application:

  • ostest

I have also tested with sim:nsh configuration:

./tools/configure.sh sim:nsh
make -j$(nproc)
./nuttx
>nsh ostest

Test logs
Image

No board runtime testing was performed because this change is a mechanical
header relocation and include-path update.

Fixes #8986

#include <stdint.h>
#include <assert.h>
#include <debug.h>
#include <nuttx/debug.h>
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

could you use script or AI to make nuttx/xxx.h in the same group, e.g.:

#include <stdint.h>
#include <assert.h>

#include <nuttx/debug.h> 
#include <nuttx/irq.h>

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done!

@github-actions github-actions bot added Arch: arm Issues related to ARM (32-bit) architecture Arch: arm64 Issues related to ARM64 (64-bit) architecture Arch: avr Issues related to all AVR(8-bit or 32-bit) architectures Arch: ceva Issues related to CEVA architecture Arch: hc Issues related to HC architecture Arch: mips Issues related to the MIPS architecture Arch: openrisc Issues related to the OpenRISC architecture Arch: renesas Issues related to the Renesas chips Arch: risc-v Issues related to the RISC-V (32-bit or 64-bit) architecture Arch: simulator Issues related to the SIMulator Arch: sparc Issues related to the SPARC architecture Arch: tricore Issues related to the TriCore architecture from Infineon Arch: x86 Issues related to the x86 architecture Arch: x86_64 Issues related to the x86_64 architecture Arch: xtensa Issues related to the Xtensa architecture Arch: z16 Issues related to the Z16 architecture Arch: z80 Issues related to the Z80 architecture Size: XL The size of the change in this PR is very large. Consider breaking down the PR into smaller pieces. Area: Audio Board: arm labels Apr 1, 2026
@PiyushPatle26 PiyushPatle26 force-pushed the include/refactor-debug-h-location branch from 9921de7 to 968b6ed Compare April 1, 2026 16:09
@PiyushPatle26
Copy link
Copy Markdown
Contributor Author

@xiaoxiang781216 I have done the change you asked for! Can you help me with the CI

@linguini1
Copy link
Copy Markdown
Contributor

Please test by enabling the debug features in Kconfig.

debug.h is a NuttX-specific, non-POSIX header. Placing it in the
top-level include/ directory creates naming conflicts with external
projects that define their own debug.h.
This commit moves the canonical header to include/nuttx/debug.h,
following the NuttX convention for non-POSIX/non-standard headers,
and updates all in-tree references.

A backward-compatibility shim is left at include/debug.h that
emits a deprecation #warning and re-includes <nuttx/debug.h>,
allowing out-of-tree code to continue building while migrating.

Signed-off-by: Piyush Patle <piyushpatle228@gmail.com>
@PiyushPatle26 PiyushPatle26 force-pushed the include/refactor-debug-h-location branch from 968b6ed to df05041 Compare April 1, 2026 20:52
@PiyushPatle26
Copy link
Copy Markdown
Contributor Author

@linguini1 I ran as you asked, I received a bunch of warnings:

nuttx/include/debug.h:28:2: warning: #warning "include <debug.h> is deprecated, use <nuttx/debug.h> instead" [-Wcpp]
   28 | #warning "include <debug.h> is deprecated, use <nuttx/debug.h> instead"
      |  ^~~~~~~
CC:  sim/sim_copyfullstate.c In file included from configfat.c:32:

nuttx/include/debug.h:28:2: warning: #warning "include <debug.h> is deprecated, use <nuttx/debug.h> instead" [-Wcpp]
   28 | #warning "include <debug.h> is deprecated, use <nuttx/debug.h> instead"
      |  ^~~~~~~
CC:  sim/sim_cpuinfo.c In file included from mkfatfs.c:34:

nuttx/include/debug.h:28:2: warning: #warning "include <debug.h> is deprecated, use <nuttx/debug.h> instead" [-Wcpp]
   28 | #warning "include <debug.h> is deprecated, use <nuttx/debug.h> instead"
      |  ^~~~~~~
CC:  sched/sched_get_tls.c In file included from writefat.c:34:

nuttx/include/debug.h:28:2: warning: #warning "include <debug.h> is deprecated, use <nuttx/debug.h> instead" [-Wcpp]
   28 | #warning "include <debug.h> is deprecated, use <nuttx/debug.h> instead"
      |  ^~~~~~~
In file included from nsh_console.c:39:

Now , I have removed the unconditional deprecation #warning from include/debug.h
This should fix the CI

@linguini1
Copy link
Copy Markdown
Contributor

Doesn't the warning indicate that you haven't migrated all places to use the new header location?

@PiyushPatle26
Copy link
Copy Markdown
Contributor Author

PiyushPatle26 commented Apr 1, 2026

Doesn't the warning indicate that you haven't migrated all places to use the new header location?

No

@PiyushPatle26
Copy link
Copy Markdown
Contributor Author

Doesn't the warning indicate that you haven't migrated all places to use the new header location?

@linguini1 I think the warning is from checkpatch on the modified files, not from a scan of remaining #include <debug.h> usages.

@linguini1
Copy link
Copy Markdown
Contributor

linguini1 commented Apr 1, 2026

Doesn't the warning indicate that you haven't migrated all places to use the new header location?

@linguini1 I think the warning is from checkpatch on the modified files, not from a scan of remaining #include <debug.h> usages.

No, the warnings you pasted in your last comment are from compilation.

If I understand correctly, this warning is inside the legacy debug.h header you kept for backwards compatibility? So if it's appearing, it means that header is still getting included somewhere.

One inclusion is in nsh_console.c. Maybe you can open a twin PR to nuttx-apps to replace the includes there too

@PiyushPatle26
Copy link
Copy Markdown
Contributor Author

@linguini1 I’ve already submitted the PR for nuttx_apps. Regarding the warnings, you’re right.

My understanding is that the CI is failing because it checks against the current master of nuttx_apps, which doesn’t yet include the corresponding changes.

@linguini1
Copy link
Copy Markdown
Contributor

@linguini1 I’ve already submitted the PR for nuttx_apps. Regarding the warnings, you’re right.

My bad, didn't realize! Could you please link to it in the description of this PR?

My understanding is that the CI is failing because it checks against the current master of nuttx_apps, which doesn’t yet include the corresponding changes.

Hmmm, usually warnings do not cause CI to fail, but I'm on mobile right now so I can't check to give a reason.

@PiyushPatle26
Copy link
Copy Markdown
Contributor Author

@linguini1 I have updated the description

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

Labels

Arch: arm Issues related to ARM (32-bit) architecture Arch: arm64 Issues related to ARM64 (64-bit) architecture Arch: avr Issues related to all AVR(8-bit or 32-bit) architectures Arch: ceva Issues related to CEVA architecture Arch: hc Issues related to HC architecture Arch: mips Issues related to the MIPS architecture Arch: openrisc Issues related to the OpenRISC architecture Arch: renesas Issues related to the Renesas chips Arch: risc-v Issues related to the RISC-V (32-bit or 64-bit) architecture Arch: simulator Issues related to the SIMulator Arch: sparc Issues related to the SPARC architecture Arch: tricore Issues related to the TriCore architecture from Infineon Arch: x86 Issues related to the x86 architecture Arch: x86_64 Issues related to the x86_64 architecture Arch: xtensa Issues related to the Xtensa architecture Arch: z16 Issues related to the Z16 architecture Arch: z80 Issues related to the Z80 architecture Area: Audio Board: arm Size: XL The size of the change in this PR is very large. Consider breaking down the PR into smaller pieces.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Move debug.h from include to include/nuttx

3 participants