Skip to content

Commit

Permalink
Fix build and tests
Browse files Browse the repository at this point in the history
* Fix one x86-64-specific test to pass everywhere
  • Loading branch information
radare authored and trufae committed Apr 22, 2022
1 parent 9b7cbc9 commit 4823451
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 21 deletions.
31 changes: 17 additions & 14 deletions libr/debug/p/native/linux/linux_debug.c
Expand Up @@ -1337,12 +1337,11 @@ RList *linux_desc_list(int pid) {
r_sys_perror ("readlink failure");
return NULL;
}
free (fn);
buf[sizeof (buf) - 1] = 0;
type = perm = 0;

// Read file type
if (stat (fd_file, &st) != -1) {
if (stat (fn, &st) != -1) {
bool isfifo = st.st_mode & S_IFIFO;
#ifdef S_IFSOCK
/* Do *not* remove the == here. S_IFSOCK can be multiple
Expand All @@ -1363,29 +1362,33 @@ RList *linux_desc_list(int pid) {
}
}
// Read permissions
if (lstat (fd_file, &st) != -1) {
if (lstat (fn, &st) != -1) {
if (st.st_mode & S_IRUSR) {
perm |= R_PERM_R;
}
if (st.st_mode & S_IWUSR) {
perm |= R_PERM_W;
}
}
free (fn);
// Get offset
char *fn = r_str_newf ("/proc/%d/fdinfo/%s", pid, de->d_name) >= sizeof (fdinfo_file)) {
f = open (fn, O_RDONLY);
fn = r_str_newf ("/proc/%d/fdinfo/%s", pid, de->d_name);
int f = open (fn, O_RDONLY);
char fdinfo[512];
if (read (f, fdinfo, sizeof (fdinfo) - 1) < 0) {
R_WARN ("failed to read %s\n", fn);
close (f);
r_list_free (ret);
closedir (dd);
fdinfo[0] = 0;
if (f >= 0) {
if (read (f, fdinfo, sizeof (fdinfo) - 1) < 0) {
R_LOG_WARN ("failed to read %s", fn);
close (f);
r_list_free (ret);
closedir (dd);
free (fn);
return NULL;
}
free (fn);
return NULL;
fdinfo[sizeof (fdinfo) - 1] = '\0';
close (f);
}
free (fn);
fdinfo[sizeof (fdinfo) - 1] = '\0';
close (f);
/* First line of fdinfo is "pos: [offset]" */
ut64 offset = (int) r_num_math (NULL, r_str_trim_head_ro (fdinfo + 4));
RDebugDesc *desc = r_debug_desc_new (atoi (de->d_name), buf, perm, type, offset);
Expand Down
6 changes: 3 additions & 3 deletions libr/util/log.c
Expand Up @@ -10,7 +10,7 @@ static const char *level_tags[] = { // Log level to tag string lookup array
[R_LOGLVL_ERROR] = "ERROR",
[R_LOGLVL_INFO] = "INFO",
[R_LOGLVL_WARN] = "WARN",
[R_LOGLVL_DEBUG] = "DEBG",
[R_LOGLVL_DEBUG] = "DEBUG",
};

static const char *level_name(int i) {
Expand Down Expand Up @@ -133,14 +133,14 @@ R_API void r_log_vmessage(RLogLevel level, const char *origin, const char *fmt,
default:
break;
}
r_strbuf_appendf (sb, "%s[%s] ", k, level_name (level));
r_strbuf_appendf (sb, "%s%s: ", k, level_name (level));
if (rlog->show_origin) {
r_strbuf_appendf (sb, Color_YELLOW "[%s] " Color_RESET, origin);
} else {
r_strbuf_appendf (sb, Color_RESET);
}
} else {
r_strbuf_appendf (sb, "[%s] ", level_name (level));
r_strbuf_appendf (sb, "%s: ", level_name (level));
if (rlog->show_origin) {
r_strbuf_appendf (sb, "[%s] ", origin);
}
Expand Down
4 changes: 2 additions & 2 deletions test/db/cmd/cmd_i
Expand Up @@ -3312,7 +3312,7 @@ RUN

NAME=i (no rbin - file x86_64)
FILE=bins/elf/analysis/hello-linux-x86_64
ARGS=-n
ARGS=-n -a x86 -b 64
CMDS=i~!file
EXPECT=<<EOF
fd 3
Expand Down Expand Up @@ -4154,7 +4154,7 @@ format elf
bintype elf
EOF
EXPECT_ERR=<<EOF
[DEBUG] [elf] Dynamic tag 16 not handled
DEBUG: Dynamic tag 16 not handled
Cannot determine entrypoint, using 0x00000d28.
EOF
RUN
Expand Down
4 changes: 2 additions & 2 deletions test/db/io/write
Expand Up @@ -25,7 +25,7 @@ EXPECT=<<EOF
EOF
EXPECT_ERR=<<EOF
Warning: run r2 with -e bin.cache=true to fix relocations in disassembly
ERROR: Cannot write in here, check map permissions or reopen the file with oo+
ERROR: Cannot write. Check `omp` or reopen the file with `oo+`
EOF
RUN

Expand All @@ -44,6 +44,6 @@ hello
EOF
EXPECT_ERR=<<EOF
Warning: run r2 with -e bin.cache=true to fix relocations in disassembly
ERROR: Cannot write in here, check map permissions or reopen the file with oo+
ERROR: Cannot write. Check `omp` or reopen the file with `oo+`
EOF
RUN

0 comments on commit 4823451

Please sign in to comment.