Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add Yasd\Api\setBreakpoint function * Add execute_init_file * Update init_file * Format * Check global is init * Rename filename to fileAbsolutePath * Call execute_init_file in rinit * Check init_file is exist
- Loading branch information
1 parent
c7ca465
commit 226be5a
Showing
7 changed files
with
110 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
<?php | ||
|
||
echo 'execute init_file success' . PHP_EOL; | ||
Yasd\Api\setBreakpoint(__DIR__ . DIRECTORY_SEPARATOR . 'test.php', 107); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
#include "main/php.h" | ||
#include "main/SAPI.h" | ||
#include "Zend/zend_extensions.h" | ||
#include "Zend/zend_API.h" | ||
#include "Zend/zend_exceptions.h" | ||
#include "ext/standard/info.h" | ||
#include "./php_yasd.h" | ||
|
||
#include "include/global.h" | ||
|
||
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_Yasd_Api_setBreakpoint, ZEND_RETURN_VALUE, 2, _IS_BOOL, 0) | ||
ZEND_ARG_INFO(0, fileAbsolutePath) | ||
ZEND_ARG_INFO(0, lineno) | ||
ZEND_END_ARG_INFO() | ||
|
||
static PHP_FUNCTION(Yasd_Api_setBreakpoint) { | ||
zend_string *file_absolute_path; | ||
zend_long lineno; | ||
|
||
ZEND_PARSE_PARAMETERS_START(2, 2) | ||
Z_PARAM_STR(file_absolute_path) | ||
Z_PARAM_LONG(lineno) | ||
ZEND_PARSE_PARAMETERS_END(); | ||
|
||
if (!global) { | ||
zend_throw_exception(zend_ce_exception, "debugger is not init", 0); | ||
RETURN_FALSE; | ||
} | ||
|
||
auto iter = global->breakpoints->find(ZSTR_VAL(file_absolute_path)); | ||
|
||
if (iter != global->breakpoints->end()) { | ||
iter->second.insert(lineno); | ||
} else { | ||
std::set<int> lineno_set; | ||
lineno_set.insert(lineno); | ||
global->breakpoints->insert(std::make_pair(ZSTR_VAL(file_absolute_path), lineno_set)); | ||
} | ||
|
||
RETURN_TRUE; | ||
} | ||
|
||
static const zend_function_entry yasd_api_functions[] = { | ||
ZEND_FENTRY(Yasd\\Api\\setBreakpoint, PHP_FN(Yasd_Api_setBreakpoint), arginfo_Yasd_Api_setBreakpoint, 0) | ||
PHP_FE_END /* Must be the last line in yasd_functions[] */ | ||
}; | ||
|
||
int yasd_api_module_init(int module_number) | ||
{ | ||
if (zend_register_functions(NULL, yasd_api_functions, NULL, MODULE_PERSISTENT) != SUCCESS) { | ||
return FAILURE; | ||
} | ||
|
||
return SUCCESS; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#pragma once | ||
|
||
int yasd_api_module_init(int module_number); |