1 /*DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64
4 for INTEL64(R), AMD64(R)
6 Copyright(C) 2007-2009 Koine Yuusuke(koinec). All rights reserved.
8 Redistribution and use in source and binary forms, with or without
9 modification, are permitted provided that the following conditions are met:
11 1. Redistributions of source code must retain the above copyright notice,
12 this list of conditions and the following disclaimer.
13 2. Redistributions in binary form must reproduce the above copyright
14 notice, this list of conditions and the following disclaimer in the
15 documentation and/or other materials provided with the distribution.
17 THIS SOFTWARE IS PROVIDED BY Koine Yuusuke(koinec) ``AS IS'' AND ANY
18 EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20 DISCLAIMED. IN NO EVENT SHALL Koine Yuusuke(koinec) OR CONTRIBUTORS BE
21 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25 CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
27 OF THE POSSIBILITY OF SUCH DAMAGE.
29 DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64*/
31 /* File Info -----------------------------------------------------------
35 ----------------------------------------------------------------------*/
37 #define DRD64_SRCID_MARSHALD_BOOT_DEBUGD 0x0000
38 #include"drd64_marshald.h"
40 #define DRD64_FUNCID_Marshald_Boot_Debugd 0x01
42 /*----------------------------------------------------------------------
43 ----------------------------------------------------------------------*/
45 Drd64_Marshald_Boot_Debugd(
46 char *pstr_sockname_debugd,
52 char str_sockname[DRD64_MAX_PATH+1];
53 char str_pid_debugd[10];
54 char str_request_fd[10];
55 char str_debugd_connect_id[10];
59 DRD64_LOG_DEBUG(" [DEBUG] Boot Debugd Start");
61 /* Phase 0 : Init ----------------------------*/
62 dw_errcode = DRD64_ERROR_CODE_CLEAR;
63 dw_location = DRD64_ERROR_SET_LOCATION(
64 DRD64_ERROR_MODULE_MARSHALD,
65 DRD64_ERROR_ARCH_NODEPEND,
66 DRD64_SRCID_MARSHALD_BOOT_DEBUGD,
67 DRD64_FUNCID_Marshald_Boot_Debugd );
69 /* Phase 1 : Generate Debugd Param -----------*/
70 /* n : socketname(PF_UNIX) for debugd<=>Client */
71 strcpy( str_sockname, "/tmp/tmpdrd64debugd_client_XXXXXXXXXX" );
72 if( NULL == mktemp( str_sockname )) {
73 dw_errcode = DRD64_ERROR_SET_CODE(
74 DRD64_ERROR_TYPE_ERROR,
75 DRD64_ERROR_PTN_SYSCALL,
77 //Drd64_LibBrownie_Error_SetErrorInfo( dw_errcode, dw_location, errno );
82 /* a : attach pid => p_attach->i_prog_pid */
83 snprintf( str_pid_debugd, 10, "%d", i_prog_pid );
86 snprintf( str_request_fd, 10, "%d", i_request_rid );
88 /* m : to Debugd ConnectInfo ID */
89 snprintf( str_debugd_connect_id, 10, "%d", i_attach_cid );
91 /* XXX c : coredump file */
94 /* Phase 2 : Exec debugd ----------------------*/
95 i_pid_debugd = fork();
97 if( 0 > i_pid_debugd ) {
98 dw_errcode = DRD64_ERROR_SET_CODE(
99 DRD64_ERROR_TYPE_ERROR,
100 DRD64_ERROR_PTN_SYSCALL,
102 //Drd64_LibBrownie_Error_SetErrorInfo( dw_errcode, dw_location, errno );
107 else if( 0 == i_pid_debugd ) {
109 execl( drd64_marshald_info.str_path_debugd,
110 DRD64_MODULENAME_DEBUGD,
112 "-r", str_request_fd,
113 "-m", str_debugd_connect_id,
114 "-a", str_pid_debugd, NULL );
119 strncpy( pstr_sockname_debugd, str_sockname, DRD64_MAX_PATH );
121 DRD64_LOG_DEBUG(" [DEBUG] Boot Debugd Ended");
127 /* EOF of drd64_.c ----------------------------------- */