Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(48)

Side by Side Diff: experimental/linux_debug_server/debugger/nacl-gdb_server/nacl-gdb_server.cc

Issue 10928195: First round of dead file removal (Closed) Base URL: https://github.com/samclegg/nativeclient-sdk.git@master
Patch Set: Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright (c) 2011 The Native Client Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 #include <stdio.h>
5 #include "debugger/base/debug_command_line.h"
6 #include "debugger/core/debug_api.h"
7 #include "debugger/nacl-gdb_server/debug_server.h"
8
9 namespace {
10 const int kErrNoProgramSpecified = 1;
11 const int kErrListenOnPortFailed = 2;
12 const int kErrStartProcessFailed = 3;
13 const int kErrDebugServerInitFailed = 4;
14
15 const int kDefaultPort = 4014;
16 const int kErrorBuffSize = 2000;
17 const int kWaitForDebugEventMilliseconds = 20;
18
19 const char* kVersionString = "nacl-gdb_server v0.002";
20 #ifdef _WIN64
21 const char* kBitsString = "64-bits";
22 #else
23 const char* kBitsString = "32-bits";
24 #endif
25 const char* kHelpString =
26 "Usage: nacl-gdb_server [options] --program \"program to debug\"\n"
27 "Options:\n"
28 " --port <number> : port to listen for a TCP connection\n"
29 "Example:\n"
30 "nacl-gdb_server --port 4014 --program \"c:\\chrome.exe --no-sandbox\"\n"
31 "Note: there's no need to specify --no-sandbox flag.\n"
32 "Type Ctrl-C or 'quit' to exit.";
33 } // namespace
34
35 int main(int argc, char **argv) {
36 printf("%s %s\n\n", kVersionString, kBitsString);
37
38 debug::CommandLine command_line(argc, argv);
39 if ((0 == command_line.GetParametersNum()) || command_line.HasSwitch("-h")) {
40 printf("%s\n", kHelpString);
41 return 0;
42 }
43 std::string cmd = command_line.GetStringSwitch("-program", "");
44 if (0 == cmd.size()) {
45 printf("Error: program to debug shall be specified with "
46 "\"--program\" switch.");
47 return kErrNoProgramSpecified;
48 }
49 int port = command_line.GetIntSwitch("-port", kDefaultPort);
50
51 debug::DebugAPI debug_api;
52 debug::DebugServer debug_server(&debug_api, port);
53
54 if (!debug_server.Init()) {
55 printf("ERR101.01: msg='debug_server.Init failed'");
56 return kErrDebugServerInitFailed;
57 }
58
59 pid_t pid = 0;
60 if (!debug_api.StartProcess(cmd.c_str(), true, &pid)) {
61 printf("ERR101.03: "
62 "msg='gdb_server.StartProcess failed' 'cmd=[%s]'",
63 cmd.c_str());
64 return kErrStartProcessFailed;
65 }
66
67 printf("TR101.04: msg='Debug server started' port=%d cmd='%s'", port, cmd.c_st r());
68 while (true)
69 debug_server.DoWork();
70 return 0;
71 }
72
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698