| 920 | } |
| 921 | |
| 922 | bool DebuggerClientDap::evaluate( |
| 923 | const std::string& expression, const std::string& context, std::optional<int> frameId, |
| 924 | std::function<void( const std::string&, const std::optional<EvaluateInfo>& )> cb ) { |
| 925 | nlohmann::json arguments{ { DAP_EXPRESSION, expression } }; |
| 926 | if ( !context.empty() ) |
| 927 | arguments[DAP_CONTEXT] = context; |
| 928 | if ( frameId ) |
| 929 | arguments[DAP_FRAME_ID] = *frameId; |
| 930 | |
| 931 | makeRequest( |
| 932 | "evaluate", arguments, |
| 933 | [this, cb = std::move( cb )]( const auto& response, const auto& request ) { |
| 934 | auto expression = request.value( DAP_EXPRESSION, "" ); |
| 935 | if ( response.success ) { |
| 936 | EvaluateInfo info( response.body ); |
| 937 | |
| 938 | for ( auto listener : mListeners ) |
| 939 | listener->expressionEvaluated( expression, info, mCurrentSessionId ); |
| 940 | |
| 941 | if ( cb ) |
| 942 | cb( expression, info ); |
| 943 | } else { |
| 944 | for ( auto listener : mListeners ) |
| 945 | listener->expressionEvaluated( expression, std::nullopt, mCurrentSessionId ); |
| 946 | |
| 947 | if ( cb ) |
| 948 | cb( expression, std::nullopt ); |
| 949 | } |
| 950 | }, |
| 951 | mCurrentSessionId ); |
| 952 | |
| 953 | return true; |
| 954 | } |
| 955 | |
| 956 | bool DebuggerClientDap::setBreakpoints( const std::string& path, |
| 957 | const std::vector<dap::SourceBreakpoint>& breakpoints, |
no test coverage detected