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

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 7 additions & 3 deletions libunwind/src/AddressSpace.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
#define __ADDRESSSPACE_HPP__

#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

Expand Down Expand Up @@ -672,7 +671,10 @@ inline bool LocalAddressSpace::findFunctionName(pint_t addr, char *buf,
Dl_info dyldInfo;
if (dladdr((void *)addr, &dyldInfo)) {
if (dyldInfo.dli_sname != NULL) {
snprintf(buf, bufLen, "%s", dyldInfo.dli_sname);
size_t nameLen = strlen(dyldInfo.dli_sname);
size_t len = nameLen < (bufLen - 1) ? nameLen : (bufLen - 1);
memcpy(buf, dyldInfo.dli_sname, len);
buf[len] = '\0';
*offset = (addr - (pint_t) dyldInfo.dli_saddr);
return true;
}
Expand All @@ -681,7 +683,9 @@ inline bool LocalAddressSpace::findFunctionName(pint_t addr, char *buf,
uint16_t nameLen;
char *funcName = getFuncNameFromTBTable(addr, nameLen, offset);
if (funcName != NULL) {
snprintf(buf, bufLen, "%.*s", nameLen, funcName);
size_t len = nameLen < (bufLen - 1) ? nameLen : (bufLen - 1);
memcpy(buf, funcName, len);
buf[len] = '\0';
return true;
}
#else
Expand Down