Skip to content

Commit c6c08ee

Browse files
authored
[lldb] Remove setupterm workaround on macOS (#93714)
Remove setupterm workaround on macOS which caused an issues after the removal of the terminfo dependency. There's a comment that explains why the workaround is present, but neither Jim nor I were able to reproduce the issue by setting TERM to vt100.
1 parent 1880a7b commit c6c08ee

File tree

1 file changed

+0
-43
lines changed

1 file changed

+0
-43
lines changed

lldb/source/Host/common/Editline.cpp

Lines changed: 0 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -31,20 +31,6 @@
3131
using namespace lldb_private;
3232
using namespace lldb_private::line_editor;
3333

34-
// Workaround for what looks like an OS X-specific issue, but other platforms
35-
// may benefit from something similar if issues arise. The libedit library
36-
// doesn't explicitly initialize the curses termcap library, which it gets away
37-
// with until TERM is set to VT100 where it stumbles over an implementation
38-
// assumption that may not exist on other platforms. The setupterm() function
39-
// would normally require headers that don't work gracefully in this context,
40-
// so the function declaration has been hoisted here.
41-
#if defined(__APPLE__)
42-
extern "C" {
43-
int setupterm(char *term, int fildes, int *errret);
44-
}
45-
#define USE_SETUPTERM_WORKAROUND
46-
#endif
47-
4834
// Editline uses careful cursor management to achieve the illusion of editing a
4935
// multi-line block of text with a single line editor. Preserving this
5036
// illusion requires fairly careful management of cursor state. Read and
@@ -1402,35 +1388,6 @@ Editline::Editline(const char *editline_name, FILE *input_file,
14021388
// Get a shared history instance
14031389
m_editor_name = (editline_name == nullptr) ? "lldb-tmp" : editline_name;
14041390
m_history_sp = EditlineHistory::GetHistory(m_editor_name);
1405-
1406-
#ifdef USE_SETUPTERM_WORKAROUND
1407-
if (m_output_file) {
1408-
const int term_fd = fileno(m_output_file);
1409-
if (term_fd != -1) {
1410-
static std::recursive_mutex *g_init_terminal_fds_mutex_ptr = nullptr;
1411-
static std::set<int> *g_init_terminal_fds_ptr = nullptr;
1412-
static llvm::once_flag g_once_flag;
1413-
llvm::call_once(g_once_flag, [&]() {
1414-
g_init_terminal_fds_mutex_ptr =
1415-
new std::recursive_mutex(); // NOTE: Leak to avoid C++ destructor
1416-
// chain issues
1417-
g_init_terminal_fds_ptr = new std::set<int>(); // NOTE: Leak to avoid
1418-
// C++ destructor chain
1419-
// issues
1420-
});
1421-
1422-
// We must make sure to initialize the terminal a given file descriptor
1423-
// only once. If we do this multiple times, we start leaking memory.
1424-
std::lock_guard<std::recursive_mutex> guard(
1425-
*g_init_terminal_fds_mutex_ptr);
1426-
if (g_init_terminal_fds_ptr->find(term_fd) ==
1427-
g_init_terminal_fds_ptr->end()) {
1428-
g_init_terminal_fds_ptr->insert(term_fd);
1429-
setupterm((char *)0, term_fd, (int *)0);
1430-
}
1431-
}
1432-
}
1433-
#endif
14341391
}
14351392

14361393
Editline::~Editline() {

0 commit comments

Comments
 (0)