- struct llist_header* proc_list = twimap_index(map, struct llist_header*);
- struct proc_info* proc =
- container_of(proc_list, struct proc_info, siblings);
- if (!proc)
- return;
- twimap_printf(map, "%d ", proc->pid);
+ twimap_printf(map, "%s", proc(map)->cmd);
+}
+
+static inline void
+__get_protection(struct mm_region* vmr, char* prot_buf)
+{
+ prot_buf[0] = (vmr->attr & REGION_READ) ? 'r' : '-';
+ prot_buf[1] = (vmr->attr & REGION_WRITE) ? 'w' : '-';
+ prot_buf[2] = (vmr->attr & REGION_EXEC) ? 'x' : '-';
+ prot_buf[3] = shared_writable_region(vmr) ? 's' : 'p';
+ prot_buf[4] = 0;
+}
+
+static inline void
+__get_vmr_name(struct mm_region* vmr, char* buf, unsigned int size)
+{
+ int region_type;
+
+ region_type = (vmr->attr >> 16) & 0xf;
+
+ if (region_type == REGION_TYPE_STACK) {
+ strcpy(buf, "[stack]");
+ }
+
+ else if (region_type == REGION_TYPE_HEAP) {
+ strcpy(buf, "[heap]");
+ }
+
+ else if (vmr->mfile) {
+ vfs_get_path(vmr->mfile->dnode, buf, size, 0);
+ }
+
+ else {
+ buf[0] = 0;
+ }
+}
+
+void
+__task_read_maps(struct twimap* map)
+{
+ struct llist_header* vmr_;
+ struct mm_region* vmr;
+ unsigned int size;
+
+ vmr_ = twimap_index(map, struct llist_header*);
+ vmr = container_of(vmr_, struct mm_region, head);
+
+ assert(vmr_);
+
+ char prot[5], name[256];
+
+ __get_protection(vmr, prot);
+ __get_vmr_name(vmr, name, 256);
+
+ size = vmr->end - vmr->start;
+
+ twimap_printf(map, "%012lx-%012lx %x %s %s\n",
+ vmr->start, vmr->end, size, prot, name);