MCPcopy Create free account
hub / github.com/KuhakuPixel/AceTheGame / process_map_cmd_handler

Function process_map_cmd_handler

ACE/engine/src/main_cmd_handler.cpp:11–41  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

9#include <unistd.h> // for getpid
10
11void process_map_cmd_handler(int pid, bool ps_map_list_all) {
12
13 if (!proc_is_running(pid)) {
14 frontend_mark_task_fail("No processes is running with pid %d\n", pid);
15 return;
16 }
17 char path_to_maps[200];
18 snprintf(path_to_maps, 199, "/proc/%d/maps", pid);
19 //
20 std::vector<std::string> proc_maps_file = read_file(path_to_maps);
21
22 size_t special_mapping_count = 0;
23 //
24
25 for (size_t i = 0; i < proc_maps_file.size(); i++) {
26
27 struct mem_segment m_seg = parse_proc_map_str(proc_maps_file[i]);
28 // by default only show special region
29 if (!m_seg.is_special_region && !ps_map_list_all)
30 continue;
31 frontend_print("%s", m_seg.get_displayable_str().c_str());
32 // count special region
33 if (m_seg.is_special_region)
34 special_mapping_count++;
35 }
36
37 frontend_print("------------------------------------\n");
38 frontend_print("Found total of %zu mappings\n", proc_maps_file.size());
39 frontend_print("With %zu special region mapping\n", special_mapping_count);
40 frontend_print("------------------------------------\n");
41}
42
43void process_is_running_handler(int pid) {
44 bool is_running = proc_is_running(pid);

Callers 1

main_cmd_createFunction · 0.85

Calls 7

proc_is_runningFunction · 0.85
frontend_mark_task_failFunction · 0.85
read_fileFunction · 0.85
parse_proc_map_strFunction · 0.85
frontend_printFunction · 0.85
get_displayable_strMethod · 0.80
sizeMethod · 0.45

Tested by

no test coverage detected