GDB (xrefs)
Loading...
Searching...
No Matches
Classes | Typedefs | Enumerations | Functions | Variables
main.c File Reference
#include "defs.h"
#include "top.h"
#include "ui.h"
#include "target.h"
#include "inferior.h"
#include "symfile.h"
#include "gdbcore.h"
#include "getopt.h"
#include <sys/types.h>
#include <sys/stat.h>
#include <ctype.h>
#include "gdbsupport/event-loop.h"
#include "ui-out.h"
#include "interps.h"
#include "main.h"
#include "source.h"
#include "cli/cli-cmds.h"
#include "objfiles.h"
#include "auto-load.h"
#include "maint.h"
#include "filenames.h"
#include "gdbsupport/filestuff.h"
#include <signal.h>
#include "event-top.h"
#include "infrun.h"
#include "gdbsupport/signals-state-save-restore.h"
#include <algorithm>
#include <vector>
#include "gdbsupport/pathstuff.h"
#include "cli/cli-style.h"
#include "gdbsupport/alt-stack.h"
#include "observable.h"
#include "serial.h"

Go to the source code of this file.

Classes

class  gdb_initfile_finder
 
struct  cmdarg
 

Typedefs

typedef void catch_command_errors_const_ftype(const char *, int)
 

Enumerations

enum  cmdarg_kind {
  CMDARG_FILE , CMDARG_COMMAND , CMDARG_INIT_FILE , CMDARG_INIT_COMMAND ,
  CMDARG_EARLYINIT_FILE , CMDARG_EARLYINIT_COMMAND
}
 

Functions

const char * get_gdb_program_name (void)
 
static void print_gdb_help (struct ui_file *)
 
void set_gdb_data_directory (const char *new_datadir)
 
static std::string relocate_path (const char *progname, const char *initial, bool relocatable)
 
std::string relocate_gdb_directory (const char *initial, bool relocatable)
 
static std::string relocate_file_path_maybe_in_datadir (const std::string &file, bool relocatable)
 
static void get_init_files (std::vector< std::string > *system_gdbinit, std::string *home_gdbinit, std::string *local_gdbinit)
 
static void get_earlyinit_files (std::string *home_gdbearlyinit)
 
static void start_event_loop ()
 
static void captured_command_loop () __attribute__((noinline))
 
static int handle_command_errors (const struct gdb_exception &e)
 
static int catch_command_errors (catch_command_errors_const_ftype command, const char *arg, int from_tty, bool do_bp_actions=false)
 
static void symbol_file_add_main_adapter (const char *arg, int from_tty)
 
static void validate_readnow_readnever ()
 
static void execute_cmdargs (const std::vector< struct cmdarg > *cmdarg_vec, cmdarg_kind file_type, cmdarg_kind cmd_type, int *ret)
 
static void captured_main_1 (struct captured_main_args *context)
 
static void captured_main (void *data)
 
int gdb_main (struct captured_main_args *args)
 

Variables

std::string interpreter_p
 
std::string gdb_sysroot
 
std::string gdb_datadir
 
static int gdb_datadir_provided = 0
 
std::string python_libdir
 
struct ui_filegdb_stdtargin
 
struct ui_filegdb_stdtarg
 
struct ui_filegdb_stdtargerr
 
int batch_flag = 0
 
int batch_silent = 0
 
int return_child_result = 0
 
int return_child_result_value = -1
 
static char * gdb_program_name
 

Typedef Documentation

◆ catch_command_errors_const_ftype

typedef void catch_command_errors_const_ftype(const char *, int)

Definition at line 500 of file main.c.

Enumeration Type Documentation

◆ cmdarg_kind

Enumerator
CMDARG_FILE 
CMDARG_COMMAND 
CMDARG_INIT_FILE 
CMDARG_INIT_COMMAND 
CMDARG_EARLYINIT_FILE 
CMDARG_EARLYINIT_COMMAND 

Definition at line 561 of file main.c.

Function Documentation

◆ captured_command_loop()

static void captured_command_loop ( )
static

◆ captured_main()

static void captured_main ( void * data)
static

Definition at line 1310 of file main.c.

References captured_command_loop(), captured_main_1(), exception_print(), gdb_stderr, and quit_force().

Referenced by gdb_main().

◆ captured_main_1()

static void captured_main_1 ( struct captured_main_args * context)
static

Definition at line 618 of file main.c.

References add_substitute_path_rule(), annotation_level, captured_main_args::argc, captured_main_args::argv, attach_command(), auto_load_debug_printf, auto_load_local_gdbinit, auto_load_local_gdbinit_loaded, auto_load_local_gdbinit_pathname, batch_flag, batch_silent, baud_rate, BINDIR, catch_command_errors(), cd_command(), check_quiet_mode(), cli_styling, CMDARG_COMMAND, CMDARG_EARLYINIT_COMMAND, CMDARG_EARLYINIT_FILE, CMDARG_FILE, CMDARG_INIT_COMMAND, CMDARG_INIT_FILE, core_file_command(), current_inferior(), current_program_space, current_ui, debug_file_directory, DEBUGDIR, DEBUGDIR_RELOCATABLE, directory_switch(), exec_file_attach(), execute_cmdargs(), ext_lang_initialization(), file_is_auto_load_safe(), GDB_DATADIR, gdb_datadir, gdb_datadir_provided, GDB_DATADIR_RELOCATABLE, gdb_flush(), gdb_init(), gdb_printf(), gdb_program_name, gdb_stderr, gdb_stdin, gdb_stdout, gdb_stdtarg, gdb_stdtargerr, gdb_stdtargin, gdb_sysroot, get_earlyinit_files(), get_init_files(), global_auto_load, inhibit_gdbinit, init_history(), INTERP_CONSOLE, INTERP_INSIGHT, INTERP_TUI, interpreter_p, captured_main_args::interpreter_p, lim_at_start, load_auto_scripts_for_objfile(), main_ui, program_space::objfiles(), PACKAGE, perror_warning_with_name(), print_gdb_configuration(), print_gdb_help(), print_gdb_version(), python_libdir, PYTHON_LIBDIR_RELOCATABLE, quit_force(), rate, readnever_symbol_files, readnow_symbol_files, relocate_gdb_directory(), remote_timeout, return_child_result, inferior::set_args(), set_gdb_data_directory(), set_per_command_space(), set_per_command_time(), set_top_level_interpreter(), inferior::set_tty(), source_script(), symbol_file_add_main_adapter(), TARGET_SYSROOT_PREFIX, TARGET_SYSTEM_ROOT, TARGET_SYSTEM_ROOT_RELOCATABLE, validate_readnow_readnever(), warning_pre_print, windows_get_absolute_argv0(), WITH_PYTHON_LIBDIR, and write_files.

Referenced by captured_main().

◆ catch_command_errors()

static int catch_command_errors ( catch_command_errors_const_ftype command,
const char * arg,
int from_tty,
bool do_bp_actions = false )
static

◆ execute_cmdargs()

static void execute_cmdargs ( const std::vector< struct cmdarg > * cmdarg_vec,
cmdarg_kind file_type,
cmdarg_kind cmd_type,
int * ret )
static

Definition at line 602 of file main.c.

References batch_flag, catch_command_errors(), execute_command(), and source_script().

Referenced by captured_main_1().

◆ gdb_main()

int gdb_main ( struct captured_main_args * args)

Definition at line 1339 of file main.c.

References captured_main(), exception_print(), and gdb_stderr.

Referenced by main().

◆ get_earlyinit_files()

static void get_earlyinit_files ( std::string * home_gdbearlyinit)
static

Definition at line 380 of file main.c.

References GDBEARLYINIT.

Referenced by captured_main_1(), and print_gdb_help().

◆ get_gdb_program_name()

const char * get_gdb_program_name ( void )

Definition at line 101 of file main.c.

References gdb_program_name.

◆ get_init_files()

static void get_init_files ( std::vector< std::string > * system_gdbinit,
std::string * home_gdbinit,
std::string * local_gdbinit )
static

◆ handle_command_errors()

static int handle_command_errors ( const struct gdb_exception & e)
static

Definition at line 482 of file main.c.

References async_enable_stdin(), exception_print(), and gdb_stderr.

Referenced by catch_command_errors().

◆ print_gdb_help()

static void print_gdb_help ( struct ui_file * stream)
static

◆ relocate_file_path_maybe_in_datadir()

static std::string relocate_file_path_maybe_in_datadir ( const std::string & file,
bool relocatable )
static

◆ relocate_gdb_directory()

std::string relocate_gdb_directory ( const char * initial,
bool relocatable )

Definition at line 160 of file main.c.

References gdb_program_name, and relocate_path().

Referenced by captured_main_1().

◆ relocate_path()

static std::string relocate_path ( const char * progname,
const char * initial,
bool relocatable )
static

Definition at line 140 of file main.c.

References BINDIR.

Referenced by relocate_file_path_maybe_in_datadir(), and relocate_gdb_directory().

◆ set_gdb_data_directory()

void set_gdb_data_directory ( const char * new_datadir)

◆ start_event_loop()

static void start_event_loop ( )
static

◆ symbol_file_add_main_adapter()

static void symbol_file_add_main_adapter ( const char * arg,
int from_tty )
static

Definition at line 537 of file main.c.

References symbol_file_add_main(), and SYMFILE_VERBOSE.

Referenced by captured_main_1().

◆ validate_readnow_readnever()

static void validate_readnow_readnever ( )
static

Variable Documentation

◆ batch_flag

int batch_flag = 0

◆ batch_silent

int batch_silent = 0

Definition at line 87 of file main.c.

Referenced by captured_main_1().

◆ gdb_datadir

std::string gdb_datadir

◆ gdb_datadir_provided

int gdb_datadir_provided = 0
static

Definition at line 72 of file main.c.

Referenced by captured_main_1(), and relocate_file_path_maybe_in_datadir().

◆ gdb_program_name

char* gdb_program_name
static

◆ gdb_stdtarg

struct ui_file* gdb_stdtarg

◆ gdb_stdtargerr

struct ui_file* gdb_stdtargerr

◆ gdb_stdtargin

struct ui_file* gdb_stdtargin

Definition at line 79 of file main.c.

Referenced by captured_main_1(), and remote_fileio_func_read().

◆ gdb_sysroot

std::string gdb_sysroot

◆ interpreter_p

std::string interpreter_p

The name of the interpreter if specified on the command line.

Definition at line 61 of file main.c.

Referenced by captured_main_1(), and interp_set().

◆ python_libdir

std::string python_libdir

If not empty, the possibly relocated path to python's "lib" directory specified with –with-python.

Definition at line 76 of file main.c.

Referenced by captured_main_1().

◆ return_child_result

int return_child_result = 0

Definition at line 92 of file main.c.

Referenced by captured_main_1(), and quit_force().

◆ return_child_result_value

int return_child_result_value = -1

Definition at line 93 of file main.c.

Referenced by handle_inferior_event(), and quit_force().