Stackdb
Stackdb is a stackable, multi-target and -level source debugger and memory forensics library.
|
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <sys/mman.h>
#include <fcntl.h>
#include <signal.h>
#include <sys/user.h>
#include "log.h"
#include "dwdebug.h"
#include "dlmalloc.h"
Go to the source code of this file.
Macros | |
#define | MADDR 0x100000000 |
Functions | |
void * | shm_morecore (int size) |
int | shm_init (char *name, off_t size) |
void * | calloc (size_t nmemb, size_t size) |
void | free (void *ptr) |
void * | malloc (size_t size) |
void * | realloc (void *ptr, size_t size) |
void * | memalign (size_t alignment, size_t size) |
int | posix_memalign (void **memptr, size_t alignment, size_t size) |
void * | valloc (size_t size) |
void * | pvalloc (size_t size) |
struct mallinfo | mallinfo (void) |
int | mallopt (int param, int value) |
int | malloc_trim (size_t pad) |
void | malloc_stats (void) |
size_t | malloc_usable_size (void *ptr) |
void | cleanup () |
void | sigh (int signo) |
int | main (int argc, char **argv) |
#define MADDR 0x100000000 |
debugserver "serves" a single debug file, meaning it fully loads a non-relocatable debugging information file (using dwdebug) into a shared memory segment. We don't serve relocatable debugfiles because they have to be relocated on a per-instance basis, and there's not much point caching a per-instance relocated version of a debuginfo file.
To make this work, we bump the size of /proc/sys/kernel/shmmax to 4GB (/proc/sys/kernel/shmall should already be 8GB). No single debugfile should require more than 2.5GB anyway (Linux kernel files top out a bit over 2GB when fully loaded and indexed).
dwdebug insists on fully loading shared debugfiles. The whole idea behind this server is that when it is started, no dwdebug user (like the target lib) has started any debugging work — and thus we have time to build a full index so that runtime use is as fast as possible. That's the exact use case we're targeting.
If we added multi-thread support to dwdebug, we could relax this case, because multiple debugserver clients could expand partial symbols on-demand. However, then we run the risk of one client blocking another. Since the goal is to optimize runtime lookups, we aren't going to bother with this at present. Moreover, all access to the dwdebug debugfile, scope, and symbol structs that we create would have to be mitigated by a per-debugfile write lock that blocks all readers (i.e., symbol lookups) (and a per-debugfile read lock that blocks all writers) — because otherwise one client's lookup could obviously encounter an incomplete debugfile struct modification during partial symbol expansion triggered by another client (and one client's partial symbol expansion could corrupt the structures during another client's lookup).
Obviously, these problems are all fixable, but it's not really necessary right now. The main reason to fix them would be if memory usage is really a concern. So for now, if that's really a concern, you're stuck not using debugservers. Right now, the target library (the only real user of the dwdebug library) only checks to see if there's a debugserver running, but it doesn't automatically start a debugserver — it just opens debugfiles internal to the program using it.
Definition at line 124 of file debugserver.c.
void* calloc | ( | size_t | nmemb, |
size_t | size | ||
) |
Definition at line 200 of file debugserver.c.
void cleanup | ( | void | ) |
Definition at line 295 of file debugserver.c.
void free | ( | void * | ptr | ) |
Definition at line 207 of file debugserver.c.
int main | ( | int | argc, |
char ** | argv | ||
) |
Definition at line 306 of file debugserver.c.
Definition at line 258 of file debugserver.c.
void* malloc | ( | size_t | size | ) |
Definition at line 214 of file debugserver.c.
void malloc_stats | ( | void | ) |
Definition at line 280 of file debugserver.c.
int malloc_trim | ( | size_t | pad | ) |
Definition at line 273 of file debugserver.c.
size_t malloc_usable_size | ( | void * | ptr | ) |
Definition at line 287 of file debugserver.c.
int mallopt | ( | int | param, |
int | value | ||
) |
Definition at line 265 of file debugserver.c.
void* memalign | ( | size_t | alignment, |
size_t | size | ||
) |
Definition at line 228 of file debugserver.c.
int posix_memalign | ( | void ** | memptr, |
size_t | alignment, | ||
size_t | size | ||
) |
Definition at line 235 of file debugserver.c.
void* pvalloc | ( | size_t | size | ) |
Definition at line 249 of file debugserver.c.
void* realloc | ( | void * | ptr, |
size_t | size | ||
) |
Definition at line 221 of file debugserver.c.
int shm_init | ( | char * | name, |
off_t | size | ||
) |
Definition at line 171 of file debugserver.c.
void* shm_morecore | ( | int | size | ) |
Definition at line 136 of file debugserver.c.
void sigh | ( | int | signo | ) |
Definition at line 302 of file debugserver.c.
void* valloc | ( | size_t | size | ) |
Definition at line 242 of file debugserver.c.