[libunwind] [libunwind] Remove unnecessary dependencies on fprintf and stdio.h for increased baremetal friendliness (PR #72040)

Michael Kenzel via cfe-commits cfe-commits at lists.llvm.org
Sat Nov 18 21:38:19 PST 2023


michael-kenzel wrote:

As discussed, I've removed unnecessary includes of `<stdio.h>` as well as a couple other unnecessary includes. I've put the include of `<stdio.h>` in `config.h` under an `#ifdef` so it only gets included when logging is potentially active. I've also moved the include of `<assert.h>` from `config.h` into only the files that actually need it. In two places, I replaced the include `<stdio.h>` with an include of the header that was actually needed (`<stdint.h>` or `<string.h>`).

[AddressSpace.hpp](https://github.com/llvm/llvm-project/pull/72040/files#diff-dc10e493a84f7de241e331f66a5af195689f08d45a6fd0da90b275a662856327) was using `snprintf` to copy strings into a buffer. I replaced those uses with `strncpy` to remove the need for `<stdio.h>`.

Finally, I've added `_LIBUNWIND_TRACE_COMPACT_UNWIND` to also deal with the debug logging in [UnwindCursor.hpp](https://github.com/llvm/llvm-project/pull/72040/files#diff-e59aa90030d7262678863315066b19c20f770a3b02ef960961d7d01fa4b15596).

Unfortunately, I can't really exercise all these code paths here as these changes now span code specific to multiple different platforms. I'll trust that if all the tests pass, that means it works…

https://github.com/llvm/llvm-project/pull/72040


More information about the cfe-commits mailing list