2023-11-11 10:20:02 +00:00
|
|
|
/* radare - LGPL - Copyright 2009-2023 - pancake */
|
2010-02-04 12:23:53 +00:00
|
|
|
|
|
|
|
#include <r_debug.h>
|
|
|
|
#include <r_list.h>
|
|
|
|
|
2018-06-15 09:10:43 +00:00
|
|
|
/* Print out the JSON body for memory maps in the passed map region */
|
2021-01-09 00:10:37 +00:00
|
|
|
static void print_debug_map_json(RDebugMap *map, PJ *pj) {
|
|
|
|
pj_o (pj);
|
2018-06-15 09:10:43 +00:00
|
|
|
if (map->name && *map->name) {
|
2021-01-09 00:10:37 +00:00
|
|
|
pj_ks (pj, "name", map->name);
|
2018-06-15 09:10:43 +00:00
|
|
|
}
|
|
|
|
if (map->file && *map->file) {
|
2021-01-09 00:10:37 +00:00
|
|
|
pj_ks (pj, "file", map->file);
|
2018-06-15 09:10:43 +00:00
|
|
|
}
|
2021-01-09 00:10:37 +00:00
|
|
|
pj_kn (pj, "addr", map->addr);
|
|
|
|
pj_kn (pj, "addr_end", map->addr_end);
|
|
|
|
pj_ks (pj, "type", map->user ? "u" : "s");
|
|
|
|
pj_ks (pj, "perm", r_str_rwx_i (map->perm));
|
|
|
|
pj_end (pj);
|
2018-06-15 09:10:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Write the memory map header describing the line columns */
|
|
|
|
static void print_debug_map_line_header(RDebug *dbg, const char *input) {
|
|
|
|
// TODO: Write header to console based on which command is being ran
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Write a single memory map line to the console */
|
|
|
|
static void print_debug_map_line(RDebug *dbg, RDebugMap *map, ut64 addr, const char *input) {
|
2018-11-14 22:35:44 +00:00
|
|
|
char humansz[8];
|
2018-06-15 09:10:43 +00:00
|
|
|
if (input[0] == 'q') { // "dmq"
|
|
|
|
char *name = (map->name && *map->name)
|
|
|
|
? r_str_newf ("%s.%s", map->name, r_str_rwx_i (map->perm))
|
2018-11-14 22:35:44 +00:00
|
|
|
: r_str_newf ("%08" PFMT64x ".%s", map->addr, r_str_rwx_i (map->perm));
|
2018-06-15 09:10:43 +00:00
|
|
|
r_name_filter (name, 0);
|
2018-11-14 22:35:44 +00:00
|
|
|
r_num_units (humansz, sizeof (humansz), map->addr_end - map->addr);
|
|
|
|
dbg->cb_printf ("0x%016" PFMT64x " - 0x%016" PFMT64x " %6s %5s %s\n",
|
|
|
|
map->addr,
|
|
|
|
map->addr_end,
|
|
|
|
humansz,
|
|
|
|
r_str_rwx_i (map->perm),
|
|
|
|
name
|
|
|
|
);
|
2018-06-15 09:10:43 +00:00
|
|
|
free (name);
|
|
|
|
} else {
|
|
|
|
const char *fmtstr = dbg->bits & R_SYS_BITS_64
|
2018-11-14 22:35:44 +00:00
|
|
|
? "0x%016" PFMT64x " - 0x%016" PFMT64x " %c %s %6s %c %s %s %s%s%s\n"
|
|
|
|
: "0x%08" PFMT64x " - 0x%08" PFMT64x " %c %s %6s %c %s %s %s%s%s\n";
|
|
|
|
const char *type = map->shared ? "sys": "usr";
|
2022-05-07 09:38:54 +00:00
|
|
|
const char *flagname = dbg->coreb.getName
|
|
|
|
? dbg->coreb.getName (dbg->coreb.core, map->addr) : NULL;
|
2018-06-15 09:10:43 +00:00
|
|
|
if (!flagname) {
|
|
|
|
flagname = "";
|
|
|
|
} else if (map->name) {
|
|
|
|
char *filtered_name = strdup (map->name);
|
|
|
|
r_name_filter (filtered_name, 0);
|
|
|
|
if (!strncmp (flagname, "map.", 4) && \
|
|
|
|
!strcmp (flagname + 4, filtered_name)) {
|
|
|
|
flagname = "";
|
|
|
|
}
|
|
|
|
free (filtered_name);
|
|
|
|
}
|
2018-11-14 22:35:44 +00:00
|
|
|
r_num_units (humansz, sizeof (humansz), map->size);
|
2018-06-15 09:10:43 +00:00
|
|
|
dbg->cb_printf (fmtstr,
|
|
|
|
map->addr,
|
|
|
|
map->addr_end,
|
2018-11-14 22:35:44 +00:00
|
|
|
(addr >= map->addr && addr < map->addr_end) ? '*' : '-',
|
|
|
|
type,
|
|
|
|
humansz,
|
|
|
|
map->user ? 'u' : 's',
|
2018-06-15 09:10:43 +00:00
|
|
|
r_str_rwx_i (map->perm),
|
2020-12-21 07:51:44 +00:00
|
|
|
r_str_get_fail (map->name, "?"),
|
|
|
|
r_str_get_fail (map->file, "?"),
|
2018-11-14 22:35:44 +00:00
|
|
|
*flagname ? " ; " : "",
|
|
|
|
flagname
|
|
|
|
);
|
2018-06-15 09:10:43 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
R_API void r_debug_map_list(RDebug *dbg, ut64 addr, const char *input) {
|
2018-03-27 14:32:39 +00:00
|
|
|
int i;
|
2012-02-14 17:19:16 +00:00
|
|
|
RListIter *iter;
|
|
|
|
RDebugMap *map;
|
2021-01-13 00:27:11 +00:00
|
|
|
PJ *pj = NULL;
|
2016-10-16 00:34:54 +00:00
|
|
|
if (!dbg) {
|
|
|
|
return;
|
|
|
|
}
|
2018-03-27 14:32:39 +00:00
|
|
|
|
2018-06-15 09:10:43 +00:00
|
|
|
switch (input[0]) {
|
2018-08-14 03:51:13 +00:00
|
|
|
case 'j': // "dmj" add JSON opening array brace
|
2021-01-09 00:10:37 +00:00
|
|
|
pj = pj_new ();
|
|
|
|
if (!pj) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
pj_a (pj);
|
2018-08-14 03:51:13 +00:00
|
|
|
break;
|
2019-06-20 04:45:00 +00:00
|
|
|
case '*': // "dm*" don't print a header for r2 commands output
|
2018-08-14 03:51:13 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
// TODO: Find a way to only print headers if output isn't being grepped
|
|
|
|
print_debug_map_line_header (dbg, input);
|
2018-03-27 14:32:39 +00:00
|
|
|
}
|
|
|
|
|
2018-06-15 09:10:43 +00:00
|
|
|
for (i = 0; i < 2; i++) { // Iterate over dbg::maps and dbg::maps_user
|
2018-03-27 14:32:39 +00:00
|
|
|
RList *maps = (i == 0) ? dbg->maps : dbg->maps_user;
|
2021-11-13 23:50:54 +00:00
|
|
|
if (!maps) {
|
|
|
|
continue;
|
|
|
|
}
|
2018-03-27 14:32:39 +00:00
|
|
|
r_list_foreach (maps, iter, map) {
|
2018-06-15 09:10:43 +00:00
|
|
|
switch (input[0]) {
|
|
|
|
case 'j': // "dmj"
|
2021-01-09 00:10:37 +00:00
|
|
|
print_debug_map_json (map, pj);
|
2018-03-27 14:32:39 +00:00
|
|
|
break;
|
2018-06-15 09:10:43 +00:00
|
|
|
case '*': // "dm*"
|
2018-03-27 14:32:39 +00:00
|
|
|
{
|
|
|
|
char *name = (map->name && *map->name)
|
|
|
|
? r_str_newf ("%s.%s", map->name, r_str_rwx_i (map->perm))
|
2018-11-14 22:35:44 +00:00
|
|
|
: r_str_newf ("%08" PFMT64x ".%s", map->addr, r_str_rwx_i (map->perm));
|
2018-03-27 14:32:39 +00:00
|
|
|
r_name_filter (name, 0);
|
2018-11-14 22:35:44 +00:00
|
|
|
dbg->cb_printf ("f map.%s 0x%08" PFMT64x " 0x%08" PFMT64x "\n",
|
2018-03-27 14:32:39 +00:00
|
|
|
name, map->addr_end - map->addr + 1, map->addr);
|
|
|
|
free (name);
|
|
|
|
}
|
|
|
|
break;
|
2018-06-15 09:10:43 +00:00
|
|
|
case 'q': // "dmq"
|
|
|
|
if (input[1] == '.') { // "dmq."
|
|
|
|
if (addr >= map->addr && addr < map->addr_end) {
|
|
|
|
print_debug_map_line (dbg, map, addr, input);
|
|
|
|
}
|
|
|
|
break;
|
2018-03-27 14:32:39 +00:00
|
|
|
}
|
2018-06-15 09:10:43 +00:00
|
|
|
print_debug_map_line (dbg, map, addr, input);
|
2018-03-27 14:32:39 +00:00
|
|
|
break;
|
2018-06-15 09:10:43 +00:00
|
|
|
case '.':
|
|
|
|
if (addr >= map->addr && addr < map->addr_end) {
|
|
|
|
print_debug_map_line (dbg, map, addr, input);
|
2016-10-16 00:34:54 +00:00
|
|
|
}
|
2018-03-27 14:32:39 +00:00
|
|
|
break;
|
2018-06-15 09:10:43 +00:00
|
|
|
default:
|
|
|
|
print_debug_map_line (dbg, map, addr, input);
|
|
|
|
break;
|
2016-10-16 00:34:54 +00:00
|
|
|
}
|
2011-10-09 17:45:34 +00:00
|
|
|
}
|
2018-03-27 14:32:39 +00:00
|
|
|
}
|
|
|
|
|
2021-01-13 00:27:11 +00:00
|
|
|
if (pj) { // "dmj" add JSON closing array brace
|
2021-01-09 00:10:37 +00:00
|
|
|
pj_end (pj);
|
|
|
|
dbg->cb_printf ("%s\n", pj_string (pj));
|
|
|
|
pj_free (pj);
|
2010-02-04 12:23:53 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-03-18 22:13:35 +00:00
|
|
|
static int cmp(const void *a, const void *b) {
|
|
|
|
RDebugMap *ma = (RDebugMap*) a;
|
|
|
|
RDebugMap *mb = (RDebugMap*) b;
|
|
|
|
return ma->addr - mb->addr;
|
|
|
|
}
|
|
|
|
|
2018-06-15 09:10:43 +00:00
|
|
|
/**
|
|
|
|
* \brief Find the min and max addresses in an RList of maps.
|
|
|
|
* \param maps RList of maps that will be searched through
|
|
|
|
* \param min Pointer to a ut64 that the min will be stored in
|
|
|
|
* \param max Pointer to a ut64 that the max will be stored in
|
|
|
|
* \param skip How many maps to skip at the start of iteration
|
|
|
|
* \param width Divisor for the return value
|
|
|
|
* \return (max-min)/width
|
|
|
|
*
|
|
|
|
* Used to determine the min & max addresses of maps and
|
|
|
|
* scale the ascii bar to the width of the terminal
|
|
|
|
*/
|
2017-03-18 22:13:35 +00:00
|
|
|
static int findMinMax(RList *maps, ut64 *min, ut64 *max, int skip, int width) {
|
|
|
|
RDebugMap *map;
|
|
|
|
RListIter *iter;
|
|
|
|
*min = UT64_MAX;
|
|
|
|
*max = 0;
|
|
|
|
r_list_foreach (maps, iter, map) {
|
|
|
|
if (skip > 0) {
|
|
|
|
skip--;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (map->addr < *min) {
|
|
|
|
*min = map->addr;
|
|
|
|
}
|
|
|
|
if (map->addr_end > *max) {
|
|
|
|
*max = map->addr_end;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return (*max - *min) / width;
|
|
|
|
}
|
|
|
|
|
2018-06-15 09:10:43 +00:00
|
|
|
static void print_debug_maps_ascii_art(RDebug *dbg, RList *maps, ut64 addr, int colors) {
|
|
|
|
ut64 mul; // The amount of address space a single console column will represent in bar graph
|
|
|
|
ut64 min = -1, max = 0;
|
|
|
|
int width = r_cons_get_size (NULL) - 90;
|
2015-10-13 15:18:20 +00:00
|
|
|
RListIter *iter;
|
|
|
|
RDebugMap *map;
|
2019-04-16 13:56:41 +00:00
|
|
|
RConsPrintablePalette *pal = &r_cons_singleton ()->context->pal;
|
2017-03-18 22:13:35 +00:00
|
|
|
if (width < 1) {
|
|
|
|
width = 30;
|
2015-10-13 15:18:20 +00:00
|
|
|
}
|
2017-03-18 22:13:35 +00:00
|
|
|
r_list_sort (maps, cmp);
|
|
|
|
mul = findMinMax (maps, &min, &max, 0, width);
|
|
|
|
ut64 last = min;
|
2015-10-13 15:18:20 +00:00
|
|
|
if (min != -1 && mul != 0) {
|
2018-06-15 09:10:43 +00:00
|
|
|
const char *color_prefix = ""; // Color escape code prefixed to string (address coloring)
|
|
|
|
const char *color_suffix = ""; // Color escape code appended to end of string
|
2015-10-13 15:18:20 +00:00
|
|
|
const char *fmtstr;
|
2018-11-14 22:35:44 +00:00
|
|
|
char humansz[8]; // Holds the human formatted size string [124K]
|
2018-06-15 09:10:43 +00:00
|
|
|
int skip = 0; // Number of maps to skip when re-calculating the minmax
|
2015-10-13 15:18:20 +00:00
|
|
|
r_list_foreach (maps, iter, map) {
|
2018-11-14 22:35:44 +00:00
|
|
|
r_num_units (humansz, sizeof (humansz), map->size); // Convert map size to human readable string
|
2018-06-15 09:10:43 +00:00
|
|
|
if (colors) {
|
|
|
|
color_suffix = Color_RESET;
|
2019-03-24 22:46:33 +00:00
|
|
|
if ((map->perm & 2) && (map->perm & 1)) { // Writable & Executable
|
2019-04-16 13:56:41 +00:00
|
|
|
color_prefix = pal->widget_sel;
|
2019-03-24 22:46:33 +00:00
|
|
|
} else if (map->perm & 2) { // Writable
|
2019-04-16 13:56:41 +00:00
|
|
|
color_prefix = pal->graph_false;
|
2019-03-24 22:46:33 +00:00
|
|
|
} else if (map->perm & 1) { // Executable
|
2019-04-16 13:56:41 +00:00
|
|
|
color_prefix = pal->graph_true;
|
2016-11-05 23:43:12 +00:00
|
|
|
} else {
|
2018-06-15 09:10:43 +00:00
|
|
|
color_prefix = "";
|
|
|
|
color_suffix = "";
|
2016-11-05 23:43:12 +00:00
|
|
|
}
|
2015-10-13 15:18:20 +00:00
|
|
|
} else {
|
2018-06-15 09:10:43 +00:00
|
|
|
color_prefix = "";
|
|
|
|
color_suffix = "";
|
2015-10-13 15:18:20 +00:00
|
|
|
}
|
2018-06-15 09:10:43 +00:00
|
|
|
if ((map->addr - last) > UT32_MAX) { // TODO: Comment what this is for
|
|
|
|
mul = findMinMax (maps, &min, &max, skip, width); // Recalculate minmax
|
2017-03-18 22:13:35 +00:00
|
|
|
}
|
2018-06-15 09:10:43 +00:00
|
|
|
skip++;
|
2018-11-14 22:35:44 +00:00
|
|
|
fmtstr = dbg->bits & R_SYS_BITS_64 // Prefix formatting string (before bar)
|
|
|
|
? "map %4.8s %c %s0x%016" PFMT64x "%s |"
|
|
|
|
: "map %4.8s %c %s0x%08" PFMT64x "%s |";
|
|
|
|
dbg->cb_printf (fmtstr, humansz,
|
2015-10-13 15:18:20 +00:00
|
|
|
(addr >= map->addr && \
|
|
|
|
addr < map->addr_end) ? '*' : '-',
|
2019-06-20 04:45:00 +00:00
|
|
|
color_prefix, map->addr, color_suffix); // * indicates map is within our current sought offset
|
2018-06-15 09:10:43 +00:00
|
|
|
int col;
|
|
|
|
for (col = 0; col < width; col++) { // Iterate over the available width/columns for bar graph
|
|
|
|
ut64 pos = min + (col * mul); // Current address space to check
|
|
|
|
ut64 npos = min + ((col + 1) * mul); // Next address space to check
|
2015-10-13 15:18:20 +00:00
|
|
|
if (map->addr < npos && map->addr_end > pos) {
|
2018-06-15 09:10:43 +00:00
|
|
|
dbg->cb_printf ("#"); // TODO: Comment what a # represents
|
2015-10-13 15:18:20 +00:00
|
|
|
} else {
|
2018-06-15 09:10:43 +00:00
|
|
|
dbg->cb_printf ("-");
|
2015-10-13 15:18:20 +00:00
|
|
|
}
|
|
|
|
}
|
2018-06-15 09:10:43 +00:00
|
|
|
fmtstr = dbg->bits & R_SYS_BITS_64 ? // Suffix formatting string (after bar)
|
2018-11-14 22:35:44 +00:00
|
|
|
"| %s0x%016" PFMT64x "%s %s %s\n" :
|
|
|
|
"| %s0x%08" PFMT64x "%s %s %s\n";
|
2018-06-15 09:10:43 +00:00
|
|
|
dbg->cb_printf (fmtstr, color_prefix, map->addr_end, color_suffix,
|
2015-10-13 15:18:20 +00:00
|
|
|
r_str_rwx_i (map->perm), map->name);
|
2017-03-18 22:13:35 +00:00
|
|
|
last = map->addr;
|
2015-10-13 15:18:20 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2015-10-19 00:41:21 +00:00
|
|
|
|
2018-06-15 09:10:43 +00:00
|
|
|
R_API void r_debug_map_list_visual(RDebug *dbg, ut64 addr, const char *input, int colors) {
|
2024-08-05 11:31:58 +00:00
|
|
|
R_RETURN_IF_FAIL (dbg);
|
2023-11-11 10:20:02 +00:00
|
|
|
int i;
|
|
|
|
for (i = 0; i < 2; i++) { // Iterate over dbg::maps and dbg::maps_user
|
|
|
|
RList *maps = (i == 0) ? dbg->maps : dbg->maps_user;
|
|
|
|
if (maps) {
|
|
|
|
RListIter *iter;
|
|
|
|
RDebugMap *map;
|
|
|
|
if (input[1] == '.') { // "dm=." Only show map overlapping current offset
|
|
|
|
dbg->cb_printf ("TODO:\n");
|
|
|
|
r_list_foreach (maps, iter, map) {
|
|
|
|
if (addr >= map->addr && addr < map->addr_end) {
|
|
|
|
// print_debug_map_ascii_art (dbg, map);
|
2018-06-15 09:10:43 +00:00
|
|
|
}
|
|
|
|
}
|
2023-11-11 10:20:02 +00:00
|
|
|
} else { // "dm=" Show all maps with a graph
|
|
|
|
print_debug_maps_ascii_art (dbg, maps, addr, colors);
|
2018-06-15 09:10:43 +00:00
|
|
|
}
|
2015-10-19 00:41:21 +00:00
|
|
|
}
|
|
|
|
}
|
2015-10-13 15:18:20 +00:00
|
|
|
}
|
|
|
|
|
2015-08-25 19:29:08 +00:00
|
|
|
R_API RDebugMap *r_debug_map_new(char *name, ut64 addr, ut64 addr_end, int perm, int user) {
|
2016-07-02 11:22:28 +00:00
|
|
|
/* range could be 0k on OpenBSD, it's a honeypot */
|
2016-09-19 12:44:47 +00:00
|
|
|
if (!name || addr > addr_end) {
|
2022-09-05 23:43:44 +00:00
|
|
|
R_LOG_ERROR ("r_debug_map_new: invalid (0x%" PFMT64x " > 0x%" PFMT64x ")", addr, addr_end);
|
2010-02-04 12:23:53 +00:00
|
|
|
return NULL;
|
2010-11-11 02:13:44 +00:00
|
|
|
}
|
2023-11-11 10:20:02 +00:00
|
|
|
RDebugMap *map = R_NEW0 (RDebugMap);
|
|
|
|
if (map) {
|
|
|
|
map->name = strdup (name);
|
|
|
|
map->addr = addr;
|
|
|
|
map->addr_end = addr_end;
|
|
|
|
map->size = addr_end-addr;
|
|
|
|
map->perm = perm;
|
|
|
|
map->user = user;
|
2017-03-12 11:31:22 +00:00
|
|
|
}
|
2010-02-04 12:23:53 +00:00
|
|
|
return map;
|
|
|
|
}
|
|
|
|
|
2015-08-23 23:27:29 +00:00
|
|
|
R_API RList *r_debug_modules_list(RDebug *dbg) {
|
2023-11-15 11:04:17 +00:00
|
|
|
RDebugPlugin *ds = R_UNWRAP3 (dbg, current, plugin);
|
|
|
|
return (ds && ds->modules_get)? ds->modules_get (dbg): NULL;
|
2015-08-23 23:27:29 +00:00
|
|
|
}
|
|
|
|
|
2020-01-15 09:58:30 +00:00
|
|
|
R_API bool r_debug_map_sync(RDebug *dbg) {
|
2015-10-19 00:41:21 +00:00
|
|
|
bool ret = false;
|
2023-11-15 11:04:17 +00:00
|
|
|
RDebugPlugin *ds = R_UNWRAP3 (dbg, current, plugin);
|
|
|
|
if (ds && ds->map_get) {
|
|
|
|
RList *newmaps = ds->map_get (dbg);
|
2010-02-04 12:23:53 +00:00
|
|
|
if (newmaps) {
|
2015-08-25 19:29:08 +00:00
|
|
|
r_list_free (dbg->maps);
|
2010-02-04 12:23:53 +00:00
|
|
|
dbg->maps = newmaps;
|
2015-10-19 00:41:21 +00:00
|
|
|
ret = true;
|
2010-02-04 12:23:53 +00:00
|
|
|
}
|
|
|
|
}
|
2020-01-15 09:58:30 +00:00
|
|
|
return ret;
|
2010-02-04 12:23:53 +00:00
|
|
|
}
|
|
|
|
|
2019-08-03 13:09:07 +00:00
|
|
|
R_API RDebugMap* r_debug_map_alloc(RDebug *dbg, ut64 addr, int size, bool thp) {
|
2023-11-15 11:04:17 +00:00
|
|
|
RDebugPlugin *ds = R_UNWRAP3 (dbg, current, plugin);
|
|
|
|
if (ds && ds->map_alloc) {
|
|
|
|
return ds->map_alloc (dbg, addr, size, thp);
|
2010-02-04 12:23:53 +00:00
|
|
|
}
|
2023-11-11 10:20:02 +00:00
|
|
|
return NULL;
|
2010-02-04 12:23:53 +00:00
|
|
|
}
|
|
|
|
|
2010-03-02 10:18:49 +00:00
|
|
|
R_API int r_debug_map_dealloc(RDebug *dbg, RDebugMap *map) {
|
2023-11-15 11:04:17 +00:00
|
|
|
RDebugPlugin *ds = R_UNWRAP3 (dbg, current, plugin);
|
2015-10-19 00:41:21 +00:00
|
|
|
bool ret = false;
|
2010-02-04 12:23:53 +00:00
|
|
|
ut64 addr = map->addr;
|
2023-11-15 11:04:17 +00:00
|
|
|
if (ds->map_dealloc) {
|
|
|
|
if (ds->map_dealloc (dbg, addr, map->size)) {
|
2015-10-19 00:41:21 +00:00
|
|
|
ret = true;
|
2017-09-10 23:22:21 +00:00
|
|
|
}
|
|
|
|
}
|
2015-10-19 00:41:21 +00:00
|
|
|
return (int)ret;
|
2010-02-04 12:23:53 +00:00
|
|
|
}
|
2010-03-02 10:18:49 +00:00
|
|
|
|
2010-02-04 12:23:53 +00:00
|
|
|
R_API RDebugMap *r_debug_map_get(RDebug *dbg, ut64 addr) {
|
2024-08-05 10:26:32 +00:00
|
|
|
R_RETURN_VAL_IF_FAIL (dbg, NULL);
|
2012-02-14 17:19:16 +00:00
|
|
|
RDebugMap *map, *ret = NULL;
|
|
|
|
RListIter *iter;
|
|
|
|
r_list_foreach (dbg->maps, iter, map) {
|
2010-02-04 12:23:53 +00:00
|
|
|
if (addr >= map->addr && addr <= map->addr_end) {
|
|
|
|
ret = map;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2010-03-02 10:18:49 +00:00
|
|
|
R_API void r_debug_map_free(RDebugMap *map) {
|
2023-11-11 10:20:02 +00:00
|
|
|
if (map) {
|
|
|
|
free (map->name);
|
|
|
|
free (map->file);
|
|
|
|
free (map);
|
|
|
|
}
|
2010-02-04 12:23:53 +00:00
|
|
|
}
|
|
|
|
|
2020-06-14 14:08:32 +00:00
|
|
|
R_API RList *r_debug_map_list_new(void) {
|
2023-11-15 11:04:17 +00:00
|
|
|
return r_list_newf ((RListFree)r_debug_map_free);
|
2010-02-04 12:23:53 +00:00
|
|
|
}
|