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

Side by Side Diff: experimental/mac_debugger/nacl_debug_helper/nacl_oop_debugger_hooks.c

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
« no previous file with comments | « experimental/mac_debugger/debugger.cc ('k') | experimental/scons » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 /*
2 * Copyright (c) 2011 The Native Client Authors. All rights reserved.
3 * Use of this source code is governed by a BSD-style license that can be
4 * found in the LICENSE file.
5 */
6
7 #include "native_client/src/include/nacl_platform.h"
8 #include "native_client/src/trusted/service_runtime/nacl_oop_debugger_hooks.h"
9 #include "native_client/src/trusted/service_runtime/sel_ldr.h"
10 #include <unistd.h>
11 #include <sys/types.h>
12 #include <memory.h>
13 void SendMessageToDebuggerAndHalt(const char *fmt, ...);
14
15 void NaClOopDebuggerAppCreateHook(struct NaClApp *nap) {
16 char* ign_var = getenv("NACL_DANGEROUS_IGNORE_VALIDATOR");
17 if (!ign_var)
18 ign_var = "Null";
19 printf("------->CC2 NaClOopDebuggerAppCreateHook pid=%d ign_var=[%s]\n", getpi d(), ign_var);
20 sleep(3);
21 printf(" procedingÉ\n");
22
23 if (NULL == nap)
24 return;
25 SendMessageToDebuggerAndHalt(
26 "-event AppCreate -nap %p -mem_start %p -user_entry_pt %p "
27 "-initial_entry_pt %p",
28 nap,
29 (void *) nap->mem_start,
30 (void *) nap->user_entry_pt,
31 (void *) nap->initial_entry_pt);
32 }
33
34 void NaClOopDebuggerThreadCreateHook(struct NaClAppThread *natp) {
35 SendMessageToDebuggerAndHalt("-event ThreadCreate -natp %p", natp);
36 }
37 void NaClOopDebuggerThreadExitHook(struct NaClAppThread *natp,
38 int exit_code) {
39 SendMessageToDebuggerAndHalt("-event ThreadExit -natp %p -exit_code %d",
40 natp,
41 exit_code);
42 }
43
44 void NaClOopDebuggerAppExitHook(int exit_code) {
45 SendMessageToDebuggerAndHalt("-event AppExit -exit_code %d", exit_code);
46 }
47
48 void OutputDebugString(const char* msg) {
49 printf("--------> OutputDebugString #6 [%s]\n", msg);
50 asm ("movl %0, %%eax;"
51 "int $3;" // trap instruction
52 //"syscall"
53 //"vmxoff;"
54 "nop;"
55 :
56 :"r"(msg)
57 :"%eax"
58 );
59 }
60
61 void SendMessageToDebuggerAndHalt(const char *fmt, ...) {
62 if (NULL == fmt) {
63 NaClLog(LOG_FATAL, "SendMessageToDebuggerAndHalt: fmt == NULL\n");
64 return;
65 }
66
67 #define kVarMsgSize 512
68 /*
69 * Prefix has GUID string specific to our OOP debugger, so that it
70 * can differentiate it from other uses of trap instruction.
71 */
72 char const prefix[] = "{7AA7C9CF-89EC-4ed3-8DAD-6DC84302AB11} -version 1 ";
73 char msg[sizeof(prefix) - 1 + kVarMsgSize];
74 char *post_pref_msg = msg + sizeof(prefix) - 1;
75 signed int res = 0;
76 va_list marker;
77 strcpy(msg, prefix);
78 va_start(marker, fmt);
79 res = vsnprintf(post_pref_msg, kVarMsgSize, fmt, marker);
80 if (-1 != res) {
81 /*
82 * Sends a string to the debugger by raising TRAP signal.
83 */
84 OutputDebugString(msg);
85 } else {
86 NaClLog(LOG_FATAL,
87 "SendMessageToDebuggerAndHalt: _vsnprintf_s returned -1\n");
88 }
89 #undef kVarMsgSize
90 }
91
OLDNEW
« no previous file with comments | « experimental/mac_debugger/debugger.cc ('k') | experimental/scons » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698