void Init() { System::Init(); MainLoop oMainLoop; // Creates an object of the 'MainLoop' class oMainLoop.Run(); }
int WINAPI WinMain(HINSTANCE,HINSTANCE,LPSTR,int) { MainLoop main; CreateConsole(); main.Run(); CloseWindow(); return 0; }
//---------------------------------------------------------------------- // main //---------------------------------------------------------------------- int main_gdbserver (int argc, char *argv[]) { Error error; MainLoop mainloop; #ifndef _WIN32 // Setup signal handlers first thing. signal (SIGPIPE, signal_handler); MainLoop::SignalHandleUP sighup_handle = mainloop.RegisterSignal(SIGHUP, sighup_handler, error); #endif const char *progname = argv[0]; const char *subcommand = argv[1]; argc--; argv++; int long_option_index = 0; int ch; std::string platform_name; std::string attach_target; std::string named_pipe_path; std::string log_file; StringRef log_channels; // e.g. "lldb process threads:gdb-remote default:linux all" int unnamed_pipe_fd = -1; bool reverse_connect = false; // ProcessLaunchInfo launch_info; ProcessAttachInfo attach_info; bool show_usage = false; int option_error = 0; #if __GLIBC__ optind = 0; #else optreset = 1; optind = 1; #endif std::string short_options(OptionParser::GetShortOptionString(g_long_options)); while ((ch = getopt_long_only(argc, argv, short_options.c_str(), g_long_options, &long_option_index)) != -1) { switch (ch) { case 0: // Any optional that auto set themselves will return 0 break; case 'l': // Set Log File if (optarg && optarg[0]) log_file.assign(optarg); break; case 'c': // Log Channels if (optarg && optarg[0]) log_channels = StringRef(optarg); break; case 'p': // platform name if (optarg && optarg[0]) platform_name = optarg; break; case 'N': // named pipe if (optarg && optarg[0]) named_pipe_path = optarg; break; case 'U': // unnamed pipe if (optarg && optarg[0]) unnamed_pipe_fd = StringConvert::ToUInt32(optarg, -1); break; case 'r': // Do nothing, native regs is the default these days break; case 'R': reverse_connect = true; break; #ifndef _WIN32 case 'S': // Put llgs into a new session. Terminals group processes // into sessions and when a special terminal key sequences // (like control+c) are typed they can cause signals to go out to // all processes in a session. Using this --setsid (-S) option // will cause debugserver to run in its own sessions and be free // from such issues. // // This is useful when llgs is spawned from a command // line application that uses llgs to do the debugging, // yet that application doesn't want llgs receiving the // signals sent to the session (i.e. dying when anyone hits ^C). { const ::pid_t new_sid = setsid(); if (new_sid == -1) { const char *errno_str = strerror(errno); fprintf (stderr, "failed to set new session id for %s (%s)\n", LLGS_PROGRAM_NAME, errno_str ? errno_str : "<no error string>"); } } break; #endif case 'a': // attach {pid|process_name} if (optarg && optarg[0]) attach_target = optarg; break; case 'h': /* fall-through is intentional */ case '?': show_usage = true; break; } } if (show_usage || option_error) { display_usage(progname, subcommand); exit(option_error); } if (!LLDBServerUtilities::SetupLogging(log_file, log_channels, LLDB_LOG_OPTION_PREPEND_TIMESTAMP)) return -1; Log *log(lldb_private::GetLogIfAnyCategoriesSet (GDBR_LOG_VERBOSE)); if (log) { log->Printf ("lldb-server launch"); for (int i = 0; i < argc; i++) { log->Printf ("argv[%i] = '%s'", i, argv[i]); } } // Skip any options we consumed with getopt_long_only. argc -= optind; argv += optind; if (argc == 0) { display_usage(progname, subcommand); exit(255); } // Setup the platform that GDBRemoteCommunicationServerLLGS will use. lldb::PlatformSP platform_sp = setup_platform (platform_name); GDBRemoteCommunicationServerLLGS gdb_server (platform_sp, mainloop); const char *const host_and_port = argv[0]; argc -= 1; argv += 1; // Any arguments left over are for the program that we need to launch. If there // are no arguments, then the GDB server will start up and wait for an 'A' packet // to launch a program, or a vAttach packet to attach to an existing process, unless // explicitly asked to attach with the --attach={pid|program_name} form. if (!attach_target.empty ()) handle_attach (gdb_server, attach_target); else if (argc > 0) handle_launch (gdb_server, argc, argv); // Print version info. printf("%s-%s", LLGS_PROGRAM_NAME, LLGS_VERSION_STR); ConnectToRemote(mainloop, gdb_server, reverse_connect, host_and_port, progname, subcommand, named_pipe_path.c_str(), unnamed_pipe_fd); if (! gdb_server.IsConnected()) { fprintf (stderr, "no connection information provided, unable to run\n"); display_usage (progname, subcommand); return 1; } mainloop.Run(); fprintf(stderr, "lldb-server exiting...\n"); return 0; }