finish intellisense support and sync with upstream

This commit is contained in:
Alexander Nicholi 2021-02-03 13:50:08 -05:00
commit ec9bfd8c56
No known key found for this signature in database
GPG key ID: B75B2EB05540F74C
221 changed files with 2360 additions and 1439 deletions

View file

@ -48,7 +48,6 @@ static int PrintBacktraceUsingAddr2line(int fd, const struct StackFrame *bp) {
struct Garbages *garbage;
sigset_t chldmask, savemask;
const struct StackFrame *frame;
struct sigaction ignore, saveint, savequit;
const char *debugbin, *p1, *p2, *p3, *addr2line;
char buf[kBacktraceBufSize], *argv[kBacktraceMaxFrames];
if (IsOpenbsd()) return -1;
@ -77,18 +76,11 @@ static int PrintBacktraceUsingAddr2line(int fd, const struct StackFrame *bp) {
j += uint64toarray_radix16(addr - 1, buf + j) + 1;
}
argv[i++] = NULL;
ignore.sa_flags = 0;
ignore.sa_handler = SIG_IGN;
sigemptyset(&ignore.sa_mask);
sigaction(SIGINT, &ignore, &saveint);
sigaction(SIGQUIT, &ignore, &savequit);
sigemptyset(&chldmask);
sigaddset(&chldmask, SIGCHLD);
sigprocmask(SIG_BLOCK, &chldmask, &savemask);
pipe(pipefds);
if (!(pid = vfork())) {
sigaction(SIGINT, &saveint, NULL);
sigaction(SIGQUIT, &savequit, NULL);
sigprocmask(SIG_SETMASK, &savemask, NULL);
dup2(pipefds[1], 1);
close(pipefds[0]);
@ -124,8 +116,6 @@ static int PrintBacktraceUsingAddr2line(int fd, const struct StackFrame *bp) {
if (errno == EINTR) continue;
return -1;
}
sigaction(SIGINT, &saveint, NULL);
sigaction(SIGQUIT, &savequit, NULL);
sigprocmask(SIG_SETMASK, &savemask, NULL);
if (WIFEXITED(ws) && !WEXITSTATUS(ws)) {
return 0;

View file

@ -25,19 +25,30 @@
/**
* Finds full executable path in overridable way.
*
* This is a higher level version of the commandv() function. Programs
* that spawn subprocesses can use this function to determine the path
* at startup.
*
* @param var is environment variable which may be used to override
* PATH search, and it can force a NULL result if it's empty
* @param cmd is name of program, which is returned asap if it's an
* absolute path
* @return pointer to exe path string, or NULL if it couldn't be found
* or the environment variable was empty; noting that the caller
* should copy this string before saving it
*/
nodiscard char *commandvenv(const char *var, const char *cmd) {
const char *commandvenv(const char *var, const char *cmd) {
const char *exepath;
char pathbuf[PATH_MAX];
static char pathbuf[PATH_MAX];
if (*cmd == '/' || *cmd == '\\') return cmd;
if ((exepath = getenv(var))) {
if (!isempty(exepath) && access(exepath, X_OK) != -1) {
return strdup(exepath);
if (isempty(exepath)) return NULL;
if (access(exepath, X_OK) != -1) {
return exepath;
} else {
return NULL;
}
} else if ((exepath = commandv(cmd, pathbuf))) {
return strdup(exepath);
} else {
return NULL;
}
return commandv(cmd, pathbuf);
}

View file

@ -40,7 +40,7 @@ void memsummary(int); /* light version of same thing */
uint16_t getttycols(uint16_t);
int getttysize(int, struct winsize *) paramsnonnull();
bool IsTerminalInarticulate(void) nosideeffect;
char *commandvenv(const char *, const char *) nodiscard;
const char *commandvenv(const char *, const char *);
const char *GetAddr2linePath(void);
const char *GetGdbPath(void);

View file

@ -28,7 +28,6 @@ LIBC_LOG_A_CHECKS = \
LIBC_LOG_A_DIRECTDEPS = \
LIBC_ALG \
LIBC_CALLS \
LIBC_CALLS_HEFTY \
LIBC_ELF \
LIBC_FMT \
LIBC_INTRIN \

View file

@ -17,9 +17,11 @@
PERFORMANCE OF THIS SOFTWARE.
*/
#include "libc/calls/calls.h"
#include "libc/fmt/itoa.h"
#include "libc/log/color.internal.h"
#include "libc/log/internal.h"
#include "libc/runtime/runtime.h"
#include "libc/str/str.h"
#include "libc/sysv/consts/fileno.h"
/**
@ -29,6 +31,18 @@
* @see __start_fatal_ndebug()
*/
relegated void __start_fatal(const char *file, int line) {
dprintf(STDERR_FILENO, "%s%s%s%s:%s:%d:%s%s: ", CLS, RED, "error", BLUE1,
file, line, program_invocation_short_name, RESET);
char s[16 + 16 + 16 + 16 + PATH_MAX + 16 + NAME_MAX + 16], *p;
p = stpcpy(s, CLS);
p = stpcpy(p, RED);
p = stpcpy(p, "error");
p = stpcpy(p, BLUE1);
p = stpcpy(p, ":");
p = stpcpy(p, file);
p = stpcpy(p, ":");
p += int64toarray_radix10(line, p);
p = stpcpy(p, ":");
p = stpcpy(p, program_invocation_short_name);
p = stpcpy(p, RESET);
p = stpcpy(p, ": ");
write(2, s, p - s);
}