cdt-gdb-adapter
Advanced tools
Comparing version 1.0.4 to 1.0.5
@@ -1,6 +0,6 @@ | ||
"use strict";var yt=Object.create;var L=Object.defineProperty,It=Object.defineProperties,Rt=Object.getOwnPropertyDescriptor,xt=Object.getOwnPropertyDescriptors,wt=Object.getOwnPropertyNames,Oe=Object.getOwnPropertySymbols,_e=Object.getPrototypeOf,Fe=Object.prototype.hasOwnProperty,kt=Object.prototype.propertyIsEnumerable,Bt=Reflect.get;var Ne=(s,t,e)=>t in s?L(s,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):s[t]=e,$=(s,t)=>{for(var e in t||(t={}))Fe.call(t,e)&&Ne(s,e,t[e]);if(Oe)for(var e of Oe(t))kt.call(t,e)&&Ne(s,e,t[e]);return s},je=(s,t)=>It(s,xt(t));var oe=(s,t)=>()=>(t||s((t={exports:{}}).exports,t),t.exports),Dt=(s,t)=>{for(var e in t)L(s,e,{get:t[e],enumerable:!0})},He=(s,t,e,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of wt(t))!Fe.call(s,r)&&r!==e&&L(s,r,{get:()=>t[r],enumerable:!(n=Rt(t,r))||n.enumerable});return s};var _=(s,t,e)=>(e=s!=null?yt(_e(s)):{},He(t||!s||!s.__esModule?L(e,"default",{value:s,enumerable:!0}):e,s)),Pt=s=>He(L({},"__esModule",{value:!0}),s);var ze=(s,t,e)=>Bt(_e(s),e,t);var f=(s,t,e)=>new Promise((n,r)=>{var i=d=>{try{o(e.next(d))}catch(c){r(c)}},a=d=>{try{o(e.throw(d))}catch(c){r(c)}},o=d=>d.done?n(d.value):Promise.resolve(d.value).then(i,a);o((e=e.apply(s,t)).next())});var rt=oe((bn,Le)=>{"use strict";var C=typeof Reflect=="object"?Reflect:null,Ue=C&&typeof C.apply=="function"?C.apply:function(t,e,n){return Function.prototype.apply.call(t,e,n)},K;C&&typeof C.ownKeys=="function"?K=C.ownKeys:Object.getOwnPropertySymbols?K=function(t){return Object.getOwnPropertyNames(t).concat(Object.getOwnPropertySymbols(t))}:K=function(t){return Object.getOwnPropertyNames(t)};function Vt(s){console&&console.warn&&console.warn(s)}var Je=Number.isNaN||function(t){return t!==t};function b(){b.init.call(this)}Le.exports=b;Le.exports.once=Gt;b.EventEmitter=b;b.prototype._events=void 0;b.prototype._eventsCount=0;b.prototype._maxListeners=void 0;var Ke=10;function J(s){if(typeof s!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof s)}Object.defineProperty(b,"defaultMaxListeners",{enumerable:!0,get:function(){return Ke},set:function(s){if(typeof s!="number"||s<0||Je(s))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+s+".");Ke=s}});b.init=function(){(this._events===void 0||this._events===Object.getPrototypeOf(this)._events)&&(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0};b.prototype.setMaxListeners=function(t){if(typeof t!="number"||t<0||Je(t))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+t+".");return this._maxListeners=t,this};function Qe(s){return s._maxListeners===void 0?b.defaultMaxListeners:s._maxListeners}b.prototype.getMaxListeners=function(){return Qe(this)};b.prototype.emit=function(t){for(var e=[],n=1;n<arguments.length;n++)e.push(arguments[n]);var r=t==="error",i=this._events;if(i!==void 0)r=r&&i.error===void 0;else if(!r)return!1;if(r){var a;if(e.length>0&&(a=e[0]),a instanceof Error)throw a;var o=new Error("Unhandled error."+(a?" ("+a.message+")":""));throw o.context=a,o}var d=i[t];if(d===void 0)return!1;if(typeof d=="function")Ue(d,this,e);else for(var c=d.length,l=tt(d,c),n=0;n<c;++n)Ue(l[n],this,e);return!0};function Xe(s,t,e,n){var r,i,a;if(J(e),i=s._events,i===void 0?(i=s._events=Object.create(null),s._eventsCount=0):(i.newListener!==void 0&&(s.emit("newListener",t,e.listener?e.listener:e),i=s._events),a=i[t]),a===void 0)a=i[t]=e,++s._eventsCount;else if(typeof a=="function"?a=i[t]=n?[e,a]:[a,e]:n?a.unshift(e):a.push(e),r=Qe(s),r>0&&a.length>r&&!a.warned){a.warned=!0;var o=new Error("Possible EventEmitter memory leak detected. "+a.length+" "+String(t)+" listeners added. Use emitter.setMaxListeners() to increase limit");o.name="MaxListenersExceededWarning",o.emitter=s,o.type=t,o.count=a.length,Vt(o)}return s}b.prototype.addListener=function(t,e){return Xe(this,t,e,!1)};b.prototype.on=b.prototype.addListener;b.prototype.prependListener=function(t,e){return Xe(this,t,e,!0)};function Lt(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length===0?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function Ye(s,t,e){var n={fired:!1,wrapFn:void 0,target:s,type:t,listener:e},r=Lt.bind(n);return r.listener=e,n.wrapFn=r,r}b.prototype.once=function(t,e){return J(e),this.on(t,Ye(this,t,e)),this};b.prototype.prependOnceListener=function(t,e){return J(e),this.prependListener(t,Ye(this,t,e)),this};b.prototype.removeListener=function(t,e){var n,r,i,a,o;if(J(e),r=this._events,r===void 0)return this;if(n=r[t],n===void 0)return this;if(n===e||n.listener===e)--this._eventsCount===0?this._events=Object.create(null):(delete r[t],r.removeListener&&this.emit("removeListener",t,n.listener||e));else if(typeof n!="function"){for(i=-1,a=n.length-1;a>=0;a--)if(n[a]===e||n[a].listener===e){o=n[a].listener,i=a;break}if(i<0)return this;i===0?n.shift():$t(n,i),n.length===1&&(r[t]=n[0]),r.removeListener!==void 0&&this.emit("removeListener",t,o||e)}return this};b.prototype.off=b.prototype.removeListener;b.prototype.removeAllListeners=function(t){var e,n,r;if(n=this._events,n===void 0)return this;if(n.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):n[t]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete n[t]),this;if(arguments.length===0){var i=Object.keys(n),a;for(r=0;r<i.length;++r)a=i[r],a!=="removeListener"&&this.removeAllListeners(a);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(e=n[t],typeof e=="function")this.removeListener(t,e);else if(e!==void 0)for(r=e.length-1;r>=0;r--)this.removeListener(t,e[r]);return this};function Ze(s,t,e){var n=s._events;if(n===void 0)return[];var r=n[t];return r===void 0?[]:typeof r=="function"?e?[r.listener||r]:[r]:e?Tt(r):tt(r,r.length)}b.prototype.listeners=function(t){return Ze(this,t,!0)};b.prototype.rawListeners=function(t){return Ze(this,t,!1)};b.listenerCount=function(s,t){return typeof s.listenerCount=="function"?s.listenerCount(t):et.call(s,t)};b.prototype.listenerCount=et;function et(s){var t=this._events;if(t!==void 0){var e=t[s];if(typeof e=="function")return 1;if(e!==void 0)return e.length}return 0}b.prototype.eventNames=function(){return this._eventsCount>0?K(this._events):[]};function tt(s,t){for(var e=new Array(t),n=0;n<t;++n)e[n]=s[n];return e}function $t(s,t){for(;t+1<s.length;t++)s[t]=s[t+1];s.pop()}function Tt(s){for(var t=new Array(s.length),e=0;e<t.length;++e)t[e]=s[e].listener||s[e];return t}function Gt(s,t){return new Promise(function(e,n){function r(a){s.removeListener(t,i),n(a)}function i(){typeof s.removeListener=="function"&&s.removeListener("error",r),e([].slice.call(arguments))}nt(s,t,i,{once:!0}),t!=="error"&&qt(s,r,{once:!0})})}function qt(s,t,e){typeof s.on=="function"&&nt(s,"error",t,e)}function nt(s,t,e,n){if(typeof s.on=="function")n.once?s.once(t,e):s.on(t,e);else if(typeof s.addEventListener=="function")s.addEventListener(t,function r(i){n.once&&s.removeEventListener(t,r),e(i)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof s)}});var ot=oe(I=>{I.endianness=function(){return"LE"};I.hostname=function(){return typeof location!="undefined"?location.hostname:""};I.loadavg=function(){return[]};I.uptime=function(){return 0};I.freemem=function(){return Number.MAX_VALUE};I.totalmem=function(){return Number.MAX_VALUE};I.cpus=function(){return[]};I.type=function(){return"Browser"};I.release=function(){return typeof navigator!="undefined"?navigator.appVersion:""};I.networkInterfaces=I.getNetworkInterfaces=function(){return{}};I.arch=function(){return"javascript"};I.platform=function(){return"browser"};I.tmpdir=I.tmpDir=function(){return"/tmp"};I.EOL=` | ||
`;I.homedir=function(){return"/"}});var ut=oe((Vn,ct)=>{"use strict";function w(s){if(typeof s!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(s))}function dt(s,t){for(var e="",n=0,r=-1,i=0,a,o=0;o<=s.length;++o){if(o<s.length)a=s.charCodeAt(o);else{if(a===47)break;a=47}if(a===47){if(!(r===o-1||i===1))if(r!==o-1&&i===2){if(e.length<2||n!==2||e.charCodeAt(e.length-1)!==46||e.charCodeAt(e.length-2)!==46){if(e.length>2){var d=e.lastIndexOf("/");if(d!==e.length-1){d===-1?(e="",n=0):(e=e.slice(0,d),n=e.length-1-e.lastIndexOf("/")),r=o,i=0;continue}}else if(e.length===2||e.length===1){e="",n=0,r=o,i=0;continue}}t&&(e.length>0?e+="/..":e="..",n=2)}else e.length>0?e+="/"+s.slice(r+1,o):e=s.slice(r+1,o),n=o-r-1;r=o,i=0}else a===46&&i!==-1?++i:i=-1}return e}function Ot(s,t){var e=t.dir||t.root,n=t.base||(t.name||"")+(t.ext||"");return e?e===t.root?e+n:e+s+n:n}var V={resolve:function(){for(var t="",e=!1,n,r=arguments.length-1;r>=-1&&!e;r--){var i;r>=0?i=arguments[r]:(n===void 0&&(n=process.cwd()),i=n),w(i),i.length!==0&&(t=i+"/"+t,e=i.charCodeAt(0)===47)}return t=dt(t,!e),e?t.length>0?"/"+t:"/":t.length>0?t:"."},normalize:function(t){if(w(t),t.length===0)return".";var e=t.charCodeAt(0)===47,n=t.charCodeAt(t.length-1)===47;return t=dt(t,!e),t.length===0&&!e&&(t="."),t.length>0&&n&&(t+="/"),e?"/"+t:t},isAbsolute:function(t){return w(t),t.length>0&&t.charCodeAt(0)===47},join:function(){if(arguments.length===0)return".";for(var t,e=0;e<arguments.length;++e){var n=arguments[e];w(n),n.length>0&&(t===void 0?t=n:t+="/"+n)}return t===void 0?".":V.normalize(t)},relative:function(t,e){if(w(t),w(e),t===e||(t=V.resolve(t),e=V.resolve(e),t===e))return"";for(var n=1;n<t.length&&t.charCodeAt(n)===47;++n);for(var r=t.length,i=r-n,a=1;a<e.length&&e.charCodeAt(a)===47;++a);for(var o=e.length,d=o-a,c=i<d?i:d,l=-1,u=0;u<=c;++u){if(u===c){if(d>c){if(e.charCodeAt(a+u)===47)return e.slice(a+u+1);if(u===0)return e.slice(a+u)}else i>c&&(t.charCodeAt(n+u)===47?l=u:u===0&&(l=0));break}var m=t.charCodeAt(n+u),h=e.charCodeAt(a+u);if(m!==h)break;m===47&&(l=u)}var p="";for(u=n+l+1;u<=r;++u)(u===r||t.charCodeAt(u)===47)&&(p.length===0?p+="..":p+="/..");return p.length>0?p+e.slice(a+l):(a+=l,e.charCodeAt(a)===47&&++a,e.slice(a))},_makeLong:function(t){return t},dirname:function(t){if(w(t),t.length===0)return".";for(var e=t.charCodeAt(0),n=e===47,r=-1,i=!0,a=t.length-1;a>=1;--a)if(e=t.charCodeAt(a),e===47){if(!i){r=a;break}}else i=!1;return r===-1?n?"/":".":n&&r===1?"//":t.slice(0,r)},basename:function(t,e){if(e!==void 0&&typeof e!="string")throw new TypeError('"ext" argument must be a string');w(t);var n=0,r=-1,i=!0,a;if(e!==void 0&&e.length>0&&e.length<=t.length){if(e.length===t.length&&e===t)return"";var o=e.length-1,d=-1;for(a=t.length-1;a>=0;--a){var c=t.charCodeAt(a);if(c===47){if(!i){n=a+1;break}}else d===-1&&(i=!1,d=a+1),o>=0&&(c===e.charCodeAt(o)?--o===-1&&(r=a):(o=-1,r=d))}return n===r?r=d:r===-1&&(r=t.length),t.slice(n,r)}else{for(a=t.length-1;a>=0;--a)if(t.charCodeAt(a)===47){if(!i){n=a+1;break}}else r===-1&&(i=!1,r=a+1);return r===-1?"":t.slice(n,r)}},extname:function(t){w(t);for(var e=-1,n=0,r=-1,i=!0,a=0,o=t.length-1;o>=0;--o){var d=t.charCodeAt(o);if(d===47){if(!i){n=o+1;break}continue}r===-1&&(i=!1,r=o+1),d===46?e===-1?e=o:a!==1&&(a=1):e!==-1&&(a=-1)}return e===-1||r===-1||a===0||a===1&&e===r-1&&e===n+1?"":t.slice(e,r)},format:function(t){if(t===null||typeof t!="object")throw new TypeError('The "pathObject" argument must be of type Object. Received type '+typeof t);return Ot("/",t)},parse:function(t){w(t);var e={root:"",dir:"",base:"",ext:"",name:""};if(t.length===0)return e;var n=t.charCodeAt(0),r=n===47,i;r?(e.root="/",i=1):i=0;for(var a=-1,o=0,d=-1,c=!0,l=t.length-1,u=0;l>=i;--l){if(n=t.charCodeAt(l),n===47){if(!c){o=l+1;break}continue}d===-1&&(c=!1,d=l+1),n===46?a===-1?a=l:u!==1&&(u=1):a!==-1&&(u=-1)}return a===-1||d===-1||u===0||u===1&&a===d-1&&a===o+1?d!==-1&&(o===0&&r?e.base=e.name=t.slice(1,d):e.base=e.name=t.slice(o,d)):(o===0&&r?(e.name=t.slice(1,a),e.base=t.slice(1,d)):(e.name=t.slice(o,a),e.base=t.slice(o,d)),e.ext=t.slice(a,d)),o>0?e.dir=t.slice(0,o-1):r&&(e.dir="/"),e},sep:"/",delimiter:":",win32:null,posix:null};V.posix=V;ct.exports=V});var Wt={};Dt(Wt,{GDBBackend:()=>G,GDBDebugSession:()=>N,GDBDebugSessionBase:()=>O,GDBTargetDebugSession:()=>qe,MIRequest:()=>de,MIVarPrintValues:()=>Se,base64ToHex:()=>bt,functionBreakpointLocation:()=>j,hexToBase64:()=>gt,sendBreakDelete:()=>H,sendBreakList:()=>z,sendBreakpointInsert:()=>ue,sendDataDisassemble:()=>pe,sendDataEvaluateExpression:()=>he,sendDataListRegisterNames:()=>ge,sendDataListRegisterValues:()=>be,sendDataReadMemoryBytes:()=>W,sendDataWriteMemoryBytes:()=>fe,sendExecArguments:()=>ve,sendExecContinue:()=>D,sendExecFinish:()=>ke,sendExecInterrupt:()=>Be,sendExecNext:()=>Ie,sendExecNextInstruction:()=>Re,sendExecRun:()=>ye,sendExecStep:()=>xe,sendExecStepInstruction:()=>we,sendFunctionBreakpointInsert:()=>le,sendInterpreterExecConsole:()=>Ve,sendSourceBreakpointInsert:()=>me,sendStackInfoDepth:()=>P,sendStackListFramesRequest:()=>De,sendStackListVariables:()=>Pe,sendStackSelectFrame:()=>Mt,sendTargetAttachRequest:()=>Ae,sendTargetSelectRequest:()=>Me,sendThreadInfoRequest:()=>U,sendThreadSelectRequest:()=>St,sendVarAssign:()=>T,sendVarCreate:()=>B,sendVarDelete:()=>E,sendVarEvaluateExpression:()=>Ct,sendVarInfoPathExpression:()=>Ee,sendVarListChildren:()=>M,sendVarSetFormatToHex:()=>Ce,sendVarUpdate:()=>S,sourceBreakpointLocation:()=>F});module.exports=Pt(Wt);var de=class{};function ce(s,t=!0){let e="";for(let n of s)(n==="\\"||n==='"')&&(e+="\\"),n==" "&&(t=!0),e+=n;return t&&(e=`"${e}"`),e}function At(s){if(Array.isArray(s.bkpt)){let t=s.bkpt[0],e=s.bkpt.slice(1);return{_class:s._class,bkpt:t,multiple:e}}return{_class:s._class,bkpt:s.bkpt}}function F(s,t,e="",n=!1){let r=s.gdbVersionAtLeast("8.0");if(n){if(r)return`--source ${ce(t)} --line ${e}`;{let i=`"${t}:${e}"`;return`${ce(i,!0)}`}}else return r?`-source ${t} -line ${e}`:`${t}:${e}`}function j(s,t,e=!1){let n=s.gdbVersionAtLeast("8.0");return e?n?`--function ${t}`:t:n?`-function ${t}`:t}function ue(s,t,e){return f(this,null,function*(){let n=e!=null&&e.temporary?"-t ":"",r=e!=null&&e.ignoreCount?`-i ${e==null?void 0:e.ignoreCount} `:"",i=e!=null&&e.hardware?"-h ":"",a=e!=null&&e.pending?"-f ":"",o=`-break-insert ${n}${i}${r}${a}${t}`,d=yield s.sendCommand(o),c=At(d);return e!=null&&e.condition&&(yield s.sendCommand(`-break-condition ${c.bkpt.number} ${e.condition}`)),c})}function H(s,t){return s.sendCommand(`-break-delete ${t.breakpoints.join(" ")}`)}function z(s){return s.sendCommand("-break-list")}function le(s,t,e){return f(this,null,function*(){let n=yield j(s,t,!0);return ue(s,n,e)})}function me(s,t,e,n){return f(this,null,function*(){let r=yield F(s,t,e,!0);return ue(s,r,n)})}function W(s,t,e,n=0){return s.sendCommand(`-data-read-memory-bytes -o ${n} "${t}" ${e}`)}function fe(s,t,e){return s.sendCommand(`-data-write-memory-bytes "${t}" "${e}"`)}function he(s,t){return s.sendCommand(`-data-evaluate-expression "${t}"`)}function pe(s,t,e){return f(this,null,function*(){let n=s.gdbVersionAtLeast("7.11")?"5":"3",r=yield s.sendCommand(`-data-disassemble -s "${t}" -e "${e}" -- ${n}`);if(r.asm_insns.length>0){if(!Object.prototype.hasOwnProperty.call(r.asm_insns[0],"line_asm_insn")){let i={line_asm_insn:r.asm_insns};r.asm_insns=[i]}for(let i of r.asm_insns)Object.prototype.hasOwnProperty.call(i,"line_asm_insn")||(i.line_asm_insn=[])}return Promise.resolve(r)})}function ge(s,t){let e=`-data-list-register-names --frame ${t.frameId} --thread ${t.threadId}`;return t.regno&&(e+=t.regno.join(" ")),s.sendCommand(e)}function be(s,t){let e=`-data-list-register-values --frame ${t.frameId} --thread ${t.threadId} ${t.fmt}`;return t.regno&&(e+=t.regno.join(" ")),s.sendCommand(e)}function ve(s,t){return s.sendCommand(`-exec-arguments ${t.arguments}`)}function ye(s){return s.sendCommand("-exec-run")}function D(s,t){let e="-exec-continue";return t!==void 0&&(e+=` --thread ${t}`),s.sendCommand(e)}function Ie(s,t){let e="-exec-next";return t!==void 0&&(e+=` --thread ${t}`),s.sendCommand(e)}function Re(s,t){let e="-exec-next-instruction";return t!==void 0&&(e+=` --thread ${t}`),s.sendCommand(e)}function xe(s,t){let e="-exec-step";return t!==void 0&&(e+=` --thread ${t}`),s.sendCommand(e)}function we(s,t){let e="-exec-step-instruction";return t!==void 0&&(e+=` --thread ${t}`),s.sendCommand(e)}function ke(s,t){let e="-exec-finish";return t!==void 0&&(e+=` --thread ${t}`),s.sendCommand(e)}function Be(s,t){let e="-exec-interrupt";return t!==void 0?e+=` --thread ${t}`:e+=" --all",s.sendCommand(e)}function P(s,t){let e="-stack-info-depth";return t.threadId!==void 0&&(e+=` --thread ${t.threadId}`),t.maxDepth&&(e+=` ${t.maxDepth}`),s.sendCommand(e)}function De(s,t){let e="-stack-list-frames";return t.threadId!==void 0&&(e+=` --thread ${t.threadId}`),t.noFrameFilters&&(e+=" -no-frame-filters"),t.lowFrame!==void 0&&(e+=` ${t.lowFrame}`),t.highFrame!==void 0&&(e+=` ${t.highFrame}`),s.sendCommand(e)}function Mt(s,t){return s.sendCommand(`-stack-select-frame ${t.framenum}`)}function Pe(s,t){let e="-stack-list-variables";return t.noFrameFilters&&(e+=" --no-frame-filters"),t.skipUnavailable&&(e+=" --skip-unavailable"),t.thread!==void 0&&(e+=` --thread ${t.thread}`),t.frame!==void 0&&(e+=` --frame ${t.frame}`),e+=` --${t.printValues}`,s.sendCommand(e)}function Ae(s,t){return s.sendCommand(`-target-attach ${t.pid}`)}function Me(s,t){return s.sendCommand(`-target-select ${t.type} ${t.parameters.join(" ")}`)}function U(s,t){let e="-thread-info";return t.threadId&&(e+=` ${t.threadId}`),s.sendCommand(e)}function St(s,t){return s.sendCommand(`-thread-select ${t.threadId}`)}var Se=(n=>(n.no="0",n.all="1",n.simple="2",n))(Se||{});function Et(s){return`"${s}"`}function B(s,t){let e="-var-create";if(t.threadId!==void 0&&(e+=` --thread ${t.threadId}`),t.frameId!==void 0&&(e+=` --frame ${t.frameId}`),e+=` ${t.name?t.name:"-"}`,t.frameAddr)e+=` ${t.frameAddr}`;else if(t.frame)switch(t.frame){default:case"current":e+=" *";break;case"floating":e+=" @";break}else e+=" *";return e+=` ${Et(t.expression)}`,s.sendCommand(e)}function M(s,t){let e="-var-list-children";return t.printValues&&(e+=` ${t.printValues}`),e+=` ${t.name}`,t.from&&t.to&&(e+=` ${t.from} ${t.to}`),s.sendCommand(e)}function S(s,t){let e="-var-update";return t.printValues?e+=` ${t.printValues}`:e+=" 1",t.name?e+=` ${t.name}`:e+=" *",s.sendCommand(e)}function E(s,t){let e=`-var-delete ${t.varname}`;return s.sendCommand(e)}function T(s,t){let e=`-var-assign ${t.varname} ${t.expression}`;return s.sendCommand(e)}function Ct(s,t){let e=`-var-evaluate-expression ${t.varname}`;return s.sendCommand(e)}function Ee(s,t){let e=`-var-info-path-expression ${t}`;return s.sendCommand(e)}function Ce(s,t){let e=`-var-set-format ${t} hexadecimal`;return s.sendCommand(e)}function Ve(s,t){return s.sendCommand(`-interpreter-exec --thread ${t.threadId} --frame ${t.frameId} console "${t.command}"`)}var at=_(rt()),$e=require("@vscode/debugadapter/lib/logger");var Q=class{constructor(t){this.gdb=t;this.variableMap=new Map;this.gdb=t}getKey(t,e,n){return`frame${t}_thread${e}_depth${n}`}getVars(t,e,n){return this.variableMap.get(this.getKey(t,e,n))}getVar(t,e,n,r,i){let a=this.getVars(t,e,n);if(a){for(let o of a)if(o.expression===r&&(i!=="registers"&&(i="local"),i===o.varType))return o}}getVarByName(t,e,n,r){let i=this.getVars(t,e,n);if(i){for(let a of i)if(a.varname===r)return a}}addVar(t,e,n,r,i,a,o,d){let c=this.variableMap.get(this.getKey(t,e,n));c||(c=[],this.variableMap.set(this.getKey(t,e,n),c));let l={varname:o.name,expression:r,numchild:o.numchild,children:[],value:o.value,type:o.type,isVar:i,isChild:a,varType:d||"local"};return c.push(l),l}removeVar(t,e,n,r){return f(this,null,function*(){let i,a=this.variableMap.get(this.getKey(t,e,n));if(a){for(let o of a)if(o.varname===r){i=o;break}if(i){yield E(this.gdb,{varname:i.varname}),a.splice(a.indexOf(i),1);for(let o of i.children)yield this.removeVar(t,e,n,o.varname)}}})}updateVar(t,e,n,r){return f(this,null,function*(){let i=r,o=(yield S(this.gdb,{name:r.varname})).changelist[0];if(o)if(o.in_scope==="true")o.name===r.varname&&(r.value=o.value);else{this.removeVar(t,e,n,r.varname),yield E(this.gdb,{varname:r.varname});let d=yield B(this.gdb,{frame:"current",expression:r.expression,frameId:t,threadId:e});i=this.addVar(t,e,n,r.expression,r.isVar,r.isChild,d)}return Promise.resolve(i)})}};var A=require("@vscode/debugadapter/lib/logger"),st=_(require("utf8")),X=class{constructor(t){this.gdb=t;this.line="";this.pos=0;this.commandQueue={}}parse(t){return new Promise(e=>{this.waitReady=e;let n=/\r?\n/,r="";t.on("data",i=>{let a=i.toString(),o=n.exec(a);for(o&&(o.index+=r.length),r+=a;o;){let d=r.slice(0,o.index);this.parseLine(d),r=r.slice(o.index+o[0].length),o=n.exec(r)}})})}parseLine(t){this.line=t,this.pos=0,this.handleLine()}queueCommand(t,e){this.commandQueue[t]=e}peek(){return this.pos<this.line.length?this.line[this.pos]:null}next(){return this.pos<this.line.length?this.line[this.pos++]:null}back(){this.pos--}restOfLine(){return this.line.substr(this.pos)}handleToken(t){let e=t,n=this.next();for(;n&&n>="0"&&n<="9";)e+=n,n=this.next();return this.back(),e}handleCString(){let t=this.next();if(!t||t!=='"')return null;let e="",n="";e:for(t=this.next();t;t=this.next()){if(n){n+=t,n.length==3&&(e+=String.fromCodePoint(parseInt(n,8)),n="");continue}switch(t){case'"':break e;case"\\":if(t=this.next(),t)switch(t){case"n":e+=` | ||
`;break;case"t":e+=" ";break;case"r":break;case"0":case"1":case"2":case"3":case"4":case"5":case"6":case"7":n=t;break;default:e+=t}else this.back();break;default:e+=t}}try{return st.decode(e)}catch(r){return A.logger.error(`Failed to decode cstring '${e}'. ${JSON.stringify(r)}`),e}}handleString(){let t="";for(let e=this.next();e;e=this.next()){if(e==="="||e===",")return this.back(),t;t+=e}return t}handleObject(){let t=this.next(),e={};if(t==="{")if(t=this.next(),t!=='"')for(;t!=="}";){t!==","&&this.back();let n=this.handleString();this.next()==="="&&(e[n]=this.handleValue()),t=this.next()}else{this.back();let n=0;for(;t!=="}";){let r=this.handleCString();r&&(e[n++]=r),t=this.next()}}return t==="}"?e:null}handleArray(){let t=this.next(),e=[];if(t==="[")for(t=this.next();t!=="]";)t!==","&&this.back(),e.push(this.handleValue()),t=this.next();return t==="]"?e:null}handleValue(){let t=this.next();switch(this.back(),t){case'"':return this.handleCString();case"{":return this.handleObject();case"[":return this.handleArray();default:if(this.handleString(),this.next()==="=")return this.handleValue()}return null}handleAsyncData(){let t={},e=this.next(),n="missing";for(;e===",";)this.peek()!=="{"?(n=this.handleString(),this.next()==="="&&(t[n]=this.handleValue())):(Array.isArray(t[n])||(t[n]=[t[n]]),t[n].push(this.handleValue())),e=this.next();return t}handleConsoleStream(){let t=this.handleCString();t&&this.gdb.emit("consoleStreamOutput",t,"stdout")}handleLogStream(){let t=this.handleCString();t&&this.gdb.emit("consoleStreamOutput",t,"log")}handleLine(){let t=this.next();if(!t)return;let e="";switch(t>="0"&&t<="9"&&(e=this.handleToken(t),t=this.next()),t){case"^":{let n=this.restOfLine();for(let i=0;i<n.length;i+=1e3){let a=i===0?"result":"-cont-";A.logger.verbose(`GDB ${a}: ${e} ${n.substr(i,1e3)}`)}let r=this.commandQueue[e];if(r){let i=this.handleString(),a=this.handleAsyncData();r(i,a),delete this.commandQueue[e]}else A.logger.error("GDB response with no command: "+e);break}case"~":case"@":this.handleConsoleStream();break;case"&":this.handleLogStream();break;case"=":{A.logger.verbose("GDB notify async: "+this.restOfLine());let n=this.handleString();this.gdb.emit("notifyAsync",n,this.handleAsyncData());break}case"*":{A.logger.verbose("GDB exec async: "+this.restOfLine());let n=this.handleString();this.gdb.emit("execAsync",n,this.handleAsyncData());break}case"+":{A.logger.verbose("GDB status async: "+this.restOfLine());let n=this.handleString();this.gdb.emit("statusAsync",n,this.handleAsyncData());break}case"(":this.waitReady&&(this.waitReady(),this.waitReady=void 0);break;default:this.back(),this.gdb.emit("consoleStreamOutput",this.restOfLine()+` | ||
`,"stdout")}}};function it(s,t){let e=s.split(/\./),n=t.split(/\./);for(let r=0;r<e.length&&r<n.length;r++){let i=parseInt(e[r],10),a=parseInt(n[r],10);if(!(isNaN(i)||isNaN(a))){if(i>a)return 1;if(i<a)return-1}}if(e.length<n.length)for(let r=e.length;r<n.length;r++){let i=parseInt(n[r],10);if(!isNaN(i)&&i!=0)return-1}if(e.length>n.length)for(let r=n.length;r<e.length;r++){let i=parseInt(e[r],10);if(!isNaN(i)&&i!=0)return 1}return 0}var G=class extends at.EventEmitter{constructor(e){super();this.processManager=e;this.parser=new X(this);this.varMgr=new Q(this);this.token=0;this.gdbAsync=!1;this.gdbNonStop=!1;this.hardwareBreakpoint=!1}get varManager(){return this.varMgr}spawn(e){return f(this,null,function*(){if(this.gdbVersion=yield this.processManager.getVersion(e),this.proc=yield this.processManager.start(e),this.proc.stdin==null||this.proc.stdout==null)throw new Error("Spawned GDB does not have stdout or stdin");this.out=this.proc.stdin,this.hardwareBreakpoint=!!e.hardwareBreakpoint,yield this.parser.parse(this.proc.stdout),this.proc.stderr&&this.proc.stderr.on("data",n=>{let r=n.toString();this.emit("consoleStreamOutput",r,"stderr")}),yield this.setNonStopMode(e.gdbNonStop),yield this.setAsyncMode(e.gdbAsync)})}setAsyncMode(e){return f(this,null,function*(){let n=this.gdbVersionAtLeast("7.8")?"mi-async":"target-async";e===void 0&&(e=!0),this.gdbNonStop&&(e=!0);let r=e?"on":"off";try{yield this.sendCommand(`-gdb-set ${n} ${r}`),this.gdbAsync=e}catch(i){yield this.sendCommand(`-gdb-set ${n} off`),this.gdbAsync=!1}})}getAsyncMode(){return this.gdbAsync}setNonStopMode(e){return f(this,null,function*(){e===void 0&&(e=!1),e&&(yield this.sendCommand("-gdb-set pagination off"));let n=e?"on":"off";try{yield this.sendCommand(`-gdb-set non-stop ${n}`),this.gdbNonStop=e}catch(r){yield this.sendCommand("-gdb-set non-stop off"),this.gdbNonStop=!1}})}isNonStopMode(){return this.gdbNonStop}getBreakpointOptions(e,n){return f(this,null,function*(){return n})}isUseHWBreakpoint(){return this.hardwareBreakpoint}pause(e){if(this.gdbAsync)Be(this,e);else{if(!this.proc)throw new Error("GDB is not running, nothing to interrupt");$e.logger.verbose(`GDB signal: SIGINT to pid ${this.proc.pid}`),this.proc.kill("SIGINT")}}gdbVersionAtLeast(e){if(!this.gdbVersion)throw new Error("gdbVersion needs to be set first");return it(this.gdbVersion,e)>=0}sendCommands(e){return f(this,null,function*(){if(e)for(let n of e)yield this.sendCommand(n)})}sendCommand(e){let n=this.nextToken();return $e.logger.verbose(`GDB command: ${n} ${e}`),new Promise((r,i)=>{if(this.out){let a=new Error;this.parser.queueCommand(n,(o,d)=>{switch(o){case"done":case"running":case"connected":case"exit":r(d);break;case"error":a.message=d.msg,i(a);break;default:a.message=`Unknown response ${o}: ${JSON.stringify(d)}`,i(a)}}),this.out.write(`${n}${e} | ||
`)}else i(new Error("gdb is not running."))})}sendEnablePrettyPrint(){return this.sendCommand("-enable-pretty-printing")}standardEscape(e,n=!0){let r="";for(let i of e)(i==="\\"||i==='"')&&(r+="\\"),i==" "&&(n=!0),r+=i;return n&&(r=`"${r}"`),r}sendFileExecAndSymbols(e){return this.sendCommand(`-file-exec-and-symbols ${this.standardEscape(e)}`)}sendFileSymbolFile(e){return this.sendCommand(`-file-symbol-file ${this.standardEscape(e)}`)}sendAddSymbolFile(e,n){return this.sendCommand(`add-symbol-file ${this.standardEscape(e)} ${n}`)}sendLoad(e,n){return this.sendCommand(`load ${this.standardEscape(e)} ${n||""}`)}sendGDBSet(e){return this.sendCommand(`-gdb-set ${e}`)}sendGDBShow(e){return this.sendCommand(`-gdb-show ${e}`)}sendGDBExit(){return this.sendCommand("-gdb-exit")}nextToken(){return this.token++}};var ht=_(ot()),pt=_(ut());var g=require("@vscode/debugadapter");var lt=require("@vscode/debugadapter"),Y=class extends lt.Event{constructor(t,e=!1){super("continued"),this.body={threadId:t,allThreadsContinued:e}}};var mt=require("@vscode/debugadapter"),Z=class extends mt.Event{constructor(t,e,n=!1){super("stopped"),this.body={reason:t,allThreadsStopped:n},typeof e=="number"&&(this.body.threadId=e)}};var ee=s=>/^0x[\da-f]+$/i.test(s);var q=(s,t)=>{var e;if(ee(s)){let n=s.length-2,r=BigInt(s)+BigInt(t);return r<0?`(0x${"0".padStart(n,"0")})${r}`:`0x${r.toString(16).padStart(n,"0")}`}else{let n=/^([^+-]*)([+-]\d+)?$/g.exec(s),r=n==null?void 0:n[1],i=BigInt((e=n==null?void 0:n[2])!=null?e:0),a=BigInt(t)+i;return`${r}${a<0?"-":"+"}${a<0?-a:a}`}};var Nt=s=>{let t;return s["func-name"]&&s.offset?t=`${s["func-name"]}+${s.offset}`:s["func-name"]?t=s["func-name"]:t=void 0,$({address:s.address,instructionBytes:s.opcodes,instruction:s.inst},t?{symbol:t}:{})},_t=(s,t,e)=>{let n=a=>({address:a,instruction:"failed to retrieve instruction",presentationHint:"invalid"}),r=[],i=s;for(let a=0;a<t;a++)e<0?(i=q(i,e),r.unshift(n(i))):(r.push(n(i)),i=q(i,e));return r},Te=(s,t,e)=>f(void 0,null,function*(){let n=[],i=e<0,a=Math.abs(e),o=h=>`(${t})${h<0?"-":"+"}${Math.abs(h)}`,d=(h,p)=>f(void 0,null,function*(){if(h===p)return[];let v=[],R=yield pe(s,o(h),o(p));for(let y of R.asm_insns){let k=y.line?parseInt(y.line,10):void 0,ie={name:y.file,path:y.fullname};for(let ae of y.line_asm_insn)v.push(je($({},Nt(ae)),{location:ie,line:k}))}return v}),c={lower:0,higher:0},l=h=>{i?(c.higher=c.lower,c.lower+=h*4,ee(t)&&BigInt(t)+BigInt(c.lower)<0&&(c.lower=Number(t)*-1)):(c.lower=c.higher,c.higher+=h*4)},u=()=>Math.sign(e)*Math.max(a-n.length,0),m=h=>{i?n.unshift(...h):n.push(...h)};try{for(;a>n.length;){l(u());let h=yield d(c.lower,c.higher);if(h.length===0)break;m(h)}}catch(h){if(n.length===0)throw h}if(a<n.length&&(e<0?n.splice(0,n.length-a):n.splice(a,n.length-a)),a>n.length){if(n.length===0)throw new Error("Cannot retrieve instructions!");let h=n[i?0:n.length-1].address,p=_t(h,a-n.length,Math.sign(e)*2);m(p)}return n});var Ge=class{constructor(t,e,n){this.id=t,this.name=e,this.running=n}},Ft=/\s|>/g,te=/.*\[[\d]+\].*/,ft=/[\d]+/,jt=/^-?\d+(?:\.\d*)?$/,Ht=/\b(?:char|short|int|long|float|double)$/,zt=/\bbool$/;function gt(s){if(s.length%2!==0)throw new Error("Received memory with incomplete bytes.");let t=Buffer.from(s,"hex").toString("base64");if(t.length===0&&s.length!==0)throw new Error("Received ill-formed hex input: "+s);return t}function bt(s){let t=Buffer.from(s,"base64");if(t.length===0||!t.toString("base64").startsWith(s))throw new Error("Received ill-formed base64 input: "+s);return t.toString("hex")}var O=class extends g.LoggingDebugSession{constructor(e){super();this.backendFactory=e;this.isAttach=!1;this.isRunning=!1;this.supportsRunInTerminalRequest=!1;this.supportsGdbConsole=!1;this.frameHandles=new g.Handles;this.variableHandles=new g.Handles;this.functionBreakpoints=[];this.logPointMessages={};this.threads=[];this.waitPausedThreadId=0;this.waitPausedNeeded=!1;this.isInitialized=!1;this.registerMap=new Map;this.registerMapReverse=new Map;this.logger=g.logger}applyRequestArguments(e,n){return[e,$({},n)]}customRequest(e,n,r){var i,a;if(e==="cdt-gdb-adapter/Memory")this.memoryRequest(n,r);else if(e==="cdt-gdb-tests/executeCommand"){let o=[],d=c=>o.push(c);(i=this.gdb)==null||i.addListener("consoleStreamOutput",d),(a=this.gdb)==null||a.sendCommand(r.command).then(c=>{n.body={status:"Ok",result:c,console:o},this.sendResponse(n)}).catch(c=>{let l=c instanceof Error?c.message:`Encountered a problem executing ${r.command}`;this.sendErrorResponse(n,1,l)}).finally(()=>{var c;(c=this.gdb)==null||c.removeListener("consoleStreamOutput",d)})}else return super.customRequest(e,n,r)}initializeRequest(e,n){this.supportsRunInTerminalRequest=n.supportsRunInTerminalRequest===!0,this.supportsGdbConsole=ht.platform()==="linux"&&this.supportsRunInTerminalRequest,e.body=e.body||{},e.body.supportsConfigurationDoneRequest=!0,e.body.supportsEvaluateForHovers=!0,e.body.supportsSetVariable=!0,e.body.supportsConditionalBreakpoints=!0,e.body.supportsHitConditionalBreakpoints=!0,e.body.supportsLogPoints=!0,e.body.supportsFunctionBreakpoints=!0,e.body.supportsDisassembleRequest=!0,e.body.supportsReadMemoryRequest=!0,e.body.supportsWriteMemoryRequest=!0,e.body.supportsSteppingGranularity=!0,this.sendResponse(e)}setupCommonLoggerAndBackends(e){return f(this,null,function*(){g.logger.setup(e.verbose?g.Logger.LogLevel.Verbose:g.Logger.LogLevel.Warn,e.logFile||!1);let n=yield this.backendFactory.createGDBManager(this,e);this.gdb=yield this.backendFactory.createBackend(this,n,e),this.gdb.on("consoleStreamOutput",(r,i)=>{this.sendEvent(new g.OutputEvent(r,i))}),this.gdb.on("execAsync",(r,i)=>this.handleGDBAsync(r,i)),this.gdb.on("notifyAsync",(r,i)=>this.handleGDBNotify(r,i))})}attachOrLaunchRequest(e,n,r){return f(this,null,function*(){if(yield this.setupCommonLoggerAndBackends(r),yield this.spawn(r),!r.program){this.sendErrorResponse(e,1,"The program must be specified in the request arguments");return}if(yield this.gdb.sendFileExecAndSymbols(r.program),yield this.gdb.sendEnablePrettyPrint(),n==="attach"){this.isAttach=!0;let i=r;yield Ae(this.gdb,{pid:i.processId}),this.sendEvent(new g.OutputEvent(`attached to process ${i.processId}`))}if(yield this.gdb.sendCommands(r.initCommands),n==="launch"){let i=r;i.arguments&&(yield ve(this.gdb,{arguments:i.arguments}))}this.sendEvent(new g.InitializedEvent),this.sendResponse(e),this.isInitialized=!0})}attachRequest(e,n){return f(this,null,function*(){try{let[r,i]=this.applyRequestArguments("attach",n);yield this.attachOrLaunchRequest(e,r,i)}catch(r){this.sendErrorResponse(e,1,r instanceof Error?r.message:String(r))}})}launchRequest(e,n){return f(this,null,function*(){try{let[r,i]=this.applyRequestArguments("launch",n);yield this.attachOrLaunchRequest(e,r,i)}catch(r){this.sendErrorResponse(e,1,r instanceof Error?r.message:String(r))}})}spawn(e){return f(this,null,function*(){var n;return(n=this.gdb)==null?void 0:n.spawn(e)})}pauseIfNeeded(e=!1){return f(this,null,function*(){if(this.waitPausedNeeded=this.isRunning&&(!e||this.gdb.getAsyncMode()),this.waitPausedNeeded){let n=new Promise(r=>{this.waitPaused=r});if(this.gdb.isNonStopMode()){let r=yield U(this.gdb,{});this.waitPausedThreadId=parseInt(r["current-thread-id"],10),this.gdb.pause(this.waitPausedThreadId)}else this.gdb.pause();yield n}})}continueIfNeeded(){return f(this,null,function*(){this.waitPausedNeeded&&(this.gdb.isNonStopMode()?yield D(this.gdb,this.waitPausedThreadId):yield D(this.gdb))})}setBreakPointsRequest(e,n){return f(this,null,function*(){yield this.pauseIfNeeded();try{let r=yield z(this.gdb),i=n.source.path,a=yield F(this.gdb,i),o=r.BreakpointTable.body.filter(m=>m.number.includes(".")||!m["original-location"]||!m["original-location"].startsWith(a)?!1:this.functionBreakpoints.indexOf(m.number)===-1),{resolved:d,deletes:c}=this.resolveBreakpoints(n.breakpoints||[],o,(m,h)=>{if(m.hitCondition)return!1;let p=m.condition||void 0,v=h.cond||void 0,R=`${a}${m.line}`;return h["original-location"]===R&&p===v});c.length>0&&(yield H(this.gdb,{breakpoints:c}),c.forEach(m=>delete this.logPointMessages[m])),this.logPointMessages={};let l=(m,h)=>{m.logMessage&&(this.logPointMessages[h.number]=m.logMessage);let p=0;return h.line?p=parseInt(h.line,10):m.line&&(p=m.line),{id:parseInt(h.number,10),line:p,verified:!0}},u=[];for(let m of d){if(m.gdbbp){u.push(l(m.vsbp,m.gdbbp));continue}let h=!1,p,v=m.vsbp;if(v.hitCondition!==void 0){if(p=parseInt(v.hitCondition.replace(Ft,""),10),isNaN(p)){this.sendEvent(new g.OutputEvent(`Unable to decode expression: ${v.hitCondition}`));continue}h=!v.hitCondition.startsWith(">"),h&&p--}try{let R=v.line.toString(),y=yield this.gdb.getBreakpointOptions({locationType:"source",source:i,line:R},{condition:v.condition,temporary:h,ignoreCount:p,hardware:this.gdb.isUseHWBreakpoint()}),k=yield me(this.gdb,i,R,y);u.push(l(v,k.bkpt))}catch(R){u.push({verified:!1,message:R instanceof Error?R.message:String(R)})}}e.body={breakpoints:u},this.sendResponse(e)}catch(r){this.sendErrorResponse(e,1,r instanceof Error?r.message:String(r))}yield this.continueIfNeeded()})}setFunctionBreakPointsRequest(e,n){return f(this,null,function*(){yield this.pauseIfNeeded();try{let i=(yield z(this.gdb)).BreakpointTable.body.filter(l=>this.functionBreakpoints.indexOf(l.number)>-1),{resolved:a,deletes:o}=this.resolveBreakpoints(n.breakpoints,i,(l,u)=>{if(l.hitCondition)return!1;let m=l.condition||void 0,h=u.cond||void 0,p=j(this.gdb,l.name);return u["original-location"]===p&&m===h});o.length>0&&(yield H(this.gdb,{breakpoints:o}),this.functionBreakpoints=this.functionBreakpoints.filter(l=>o.indexOf(l)===-1));let d=l=>({id:parseInt(l.number,10),verified:!0}),c=[];for(let l of a){if(l.gdbbp){c.push(d(l.gdbbp));continue}try{let u=yield this.gdb.getBreakpointOptions({locationType:"function",fn:l.vsbp.name},{hardware:this.gdb.isUseHWBreakpoint()}),m=yield le(this.gdb,l.vsbp.name,u);this.functionBreakpoints.push(m.bkpt.number),c.push(d(m.bkpt))}catch(u){c.push({verified:!1,message:u instanceof Error?u.message:String(u)})}}e.body={breakpoints:c},this.sendResponse(e)}catch(r){this.sendErrorResponse(e,1,r instanceof Error?r.message:String(r))}yield this.continueIfNeeded()})}resolveBreakpoints(e,n,r){let i=e.map(o=>({vsbp:o,gdbbp:n.find(d=>r(o,d))})),a=n.filter(o=>!e.find(d=>r(d,o))).map(o=>o.number);return{resolved:i,deletes:a}}configurationDoneRequest(e,n){return f(this,null,function*(){try{this.sendEvent(new g.OutputEvent(` | ||
"use strict";var yt=Object.create;var $=Object.defineProperty,It=Object.defineProperties,Rt=Object.getOwnPropertyDescriptor,wt=Object.getOwnPropertyDescriptors,xt=Object.getOwnPropertyNames,Oe=Object.getOwnPropertySymbols,_e=Object.getPrototypeOf,Fe=Object.prototype.hasOwnProperty,kt=Object.prototype.propertyIsEnumerable,Bt=Reflect.get;var Ne=(s,t,e)=>t in s?$(s,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):s[t]=e,T=(s,t)=>{for(var e in t||(t={}))Fe.call(t,e)&&Ne(s,e,t[e]);if(Oe)for(var e of Oe(t))kt.call(t,e)&&Ne(s,e,t[e]);return s},He=(s,t)=>It(s,wt(t));var oe=(s,t)=>()=>(t||s((t={exports:{}}).exports,t),t.exports),Dt=(s,t)=>{for(var e in t)$(s,e,{get:t[e],enumerable:!0})},je=(s,t,e,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of xt(t))!Fe.call(s,r)&&r!==e&&$(s,r,{get:()=>t[r],enumerable:!(n=Rt(t,r))||n.enumerable});return s};var F=(s,t,e)=>(e=s!=null?yt(_e(s)):{},je(t||!s||!s.__esModule?$(e,"default",{value:s,enumerable:!0}):e,s)),Mt=s=>je($({},"__esModule",{value:!0}),s);var We=(s,t,e)=>Bt(_e(s),e,t);var f=(s,t,e)=>new Promise((n,r)=>{var i=d=>{try{o(e.next(d))}catch(c){r(c)}},a=d=>{try{o(e.throw(d))}catch(c){r(c)}},o=d=>d.done?n(d.value):Promise.resolve(d.value).then(i,a);o((e=e.apply(s,t)).next())});var rt=oe((bn,Le)=>{"use strict";var C=typeof Reflect=="object"?Reflect:null,Ue=C&&typeof C.apply=="function"?C.apply:function(t,e,n){return Function.prototype.apply.call(t,e,n)},J;C&&typeof C.ownKeys=="function"?J=C.ownKeys:Object.getOwnPropertySymbols?J=function(t){return Object.getOwnPropertyNames(t).concat(Object.getOwnPropertySymbols(t))}:J=function(t){return Object.getOwnPropertyNames(t)};function Vt(s){console&&console.warn&&console.warn(s)}var Je=Number.isNaN||function(t){return t!==t};function b(){b.init.call(this)}Le.exports=b;Le.exports.once=Gt;b.EventEmitter=b;b.prototype._events=void 0;b.prototype._eventsCount=0;b.prototype._maxListeners=void 0;var Ke=10;function Q(s){if(typeof s!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof s)}Object.defineProperty(b,"defaultMaxListeners",{enumerable:!0,get:function(){return Ke},set:function(s){if(typeof s!="number"||s<0||Je(s))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+s+".");Ke=s}});b.init=function(){(this._events===void 0||this._events===Object.getPrototypeOf(this)._events)&&(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0};b.prototype.setMaxListeners=function(t){if(typeof t!="number"||t<0||Je(t))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+t+".");return this._maxListeners=t,this};function Qe(s){return s._maxListeners===void 0?b.defaultMaxListeners:s._maxListeners}b.prototype.getMaxListeners=function(){return Qe(this)};b.prototype.emit=function(t){for(var e=[],n=1;n<arguments.length;n++)e.push(arguments[n]);var r=t==="error",i=this._events;if(i!==void 0)r=r&&i.error===void 0;else if(!r)return!1;if(r){var a;if(e.length>0&&(a=e[0]),a instanceof Error)throw a;var o=new Error("Unhandled error."+(a?" ("+a.message+")":""));throw o.context=a,o}var d=i[t];if(d===void 0)return!1;if(typeof d=="function")Ue(d,this,e);else for(var c=d.length,l=tt(d,c),n=0;n<c;++n)Ue(l[n],this,e);return!0};function Xe(s,t,e,n){var r,i,a;if(Q(e),i=s._events,i===void 0?(i=s._events=Object.create(null),s._eventsCount=0):(i.newListener!==void 0&&(s.emit("newListener",t,e.listener?e.listener:e),i=s._events),a=i[t]),a===void 0)a=i[t]=e,++s._eventsCount;else if(typeof a=="function"?a=i[t]=n?[e,a]:[a,e]:n?a.unshift(e):a.push(e),r=Qe(s),r>0&&a.length>r&&!a.warned){a.warned=!0;var o=new Error("Possible EventEmitter memory leak detected. "+a.length+" "+String(t)+" listeners added. Use emitter.setMaxListeners() to increase limit");o.name="MaxListenersExceededWarning",o.emitter=s,o.type=t,o.count=a.length,Vt(o)}return s}b.prototype.addListener=function(t,e){return Xe(this,t,e,!1)};b.prototype.on=b.prototype.addListener;b.prototype.prependListener=function(t,e){return Xe(this,t,e,!0)};function Lt(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length===0?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function Ye(s,t,e){var n={fired:!1,wrapFn:void 0,target:s,type:t,listener:e},r=Lt.bind(n);return r.listener=e,n.wrapFn=r,r}b.prototype.once=function(t,e){return Q(e),this.on(t,Ye(this,t,e)),this};b.prototype.prependOnceListener=function(t,e){return Q(e),this.prependListener(t,Ye(this,t,e)),this};b.prototype.removeListener=function(t,e){var n,r,i,a,o;if(Q(e),r=this._events,r===void 0)return this;if(n=r[t],n===void 0)return this;if(n===e||n.listener===e)--this._eventsCount===0?this._events=Object.create(null):(delete r[t],r.removeListener&&this.emit("removeListener",t,n.listener||e));else if(typeof n!="function"){for(i=-1,a=n.length-1;a>=0;a--)if(n[a]===e||n[a].listener===e){o=n[a].listener,i=a;break}if(i<0)return this;i===0?n.shift():$t(n,i),n.length===1&&(r[t]=n[0]),r.removeListener!==void 0&&this.emit("removeListener",t,o||e)}return this};b.prototype.off=b.prototype.removeListener;b.prototype.removeAllListeners=function(t){var e,n,r;if(n=this._events,n===void 0)return this;if(n.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):n[t]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete n[t]),this;if(arguments.length===0){var i=Object.keys(n),a;for(r=0;r<i.length;++r)a=i[r],a!=="removeListener"&&this.removeAllListeners(a);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(e=n[t],typeof e=="function")this.removeListener(t,e);else if(e!==void 0)for(r=e.length-1;r>=0;r--)this.removeListener(t,e[r]);return this};function Ze(s,t,e){var n=s._events;if(n===void 0)return[];var r=n[t];return r===void 0?[]:typeof r=="function"?e?[r.listener||r]:[r]:e?Tt(r):tt(r,r.length)}b.prototype.listeners=function(t){return Ze(this,t,!0)};b.prototype.rawListeners=function(t){return Ze(this,t,!1)};b.listenerCount=function(s,t){return typeof s.listenerCount=="function"?s.listenerCount(t):et.call(s,t)};b.prototype.listenerCount=et;function et(s){var t=this._events;if(t!==void 0){var e=t[s];if(typeof e=="function")return 1;if(e!==void 0)return e.length}return 0}b.prototype.eventNames=function(){return this._eventsCount>0?J(this._events):[]};function tt(s,t){for(var e=new Array(t),n=0;n<t;++n)e[n]=s[n];return e}function $t(s,t){for(;t+1<s.length;t++)s[t]=s[t+1];s.pop()}function Tt(s){for(var t=new Array(s.length),e=0;e<t.length;++e)t[e]=s[e].listener||s[e];return t}function Gt(s,t){return new Promise(function(e,n){function r(a){s.removeListener(t,i),n(a)}function i(){typeof s.removeListener=="function"&&s.removeListener("error",r),e([].slice.call(arguments))}nt(s,t,i,{once:!0}),t!=="error"&&qt(s,r,{once:!0})})}function qt(s,t,e){typeof s.on=="function"&&nt(s,"error",t,e)}function nt(s,t,e,n){if(typeof s.on=="function")n.once?s.once(t,e):s.on(t,e);else if(typeof s.addEventListener=="function")s.addEventListener(t,function r(i){n.once&&s.removeEventListener(t,r),e(i)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof s)}});var ot=oe(I=>{I.endianness=function(){return"LE"};I.hostname=function(){return typeof location!="undefined"?location.hostname:""};I.loadavg=function(){return[]};I.uptime=function(){return 0};I.freemem=function(){return Number.MAX_VALUE};I.totalmem=function(){return Number.MAX_VALUE};I.cpus=function(){return[]};I.type=function(){return"Browser"};I.release=function(){return typeof navigator!="undefined"?navigator.appVersion:""};I.networkInterfaces=I.getNetworkInterfaces=function(){return{}};I.arch=function(){return"javascript"};I.platform=function(){return"browser"};I.tmpdir=I.tmpDir=function(){return"/tmp"};I.EOL=` | ||
`;I.homedir=function(){return"/"}});var ut=oe((Vn,ct)=>{"use strict";function k(s){if(typeof s!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(s))}function dt(s,t){for(var e="",n=0,r=-1,i=0,a,o=0;o<=s.length;++o){if(o<s.length)a=s.charCodeAt(o);else{if(a===47)break;a=47}if(a===47){if(!(r===o-1||i===1))if(r!==o-1&&i===2){if(e.length<2||n!==2||e.charCodeAt(e.length-1)!==46||e.charCodeAt(e.length-2)!==46){if(e.length>2){var d=e.lastIndexOf("/");if(d!==e.length-1){d===-1?(e="",n=0):(e=e.slice(0,d),n=e.length-1-e.lastIndexOf("/")),r=o,i=0;continue}}else if(e.length===2||e.length===1){e="",n=0,r=o,i=0;continue}}t&&(e.length>0?e+="/..":e="..",n=2)}else e.length>0?e+="/"+s.slice(r+1,o):e=s.slice(r+1,o),n=o-r-1;r=o,i=0}else a===46&&i!==-1?++i:i=-1}return e}function Ot(s,t){var e=t.dir||t.root,n=t.base||(t.name||"")+(t.ext||"");return e?e===t.root?e+n:e+s+n:n}var V={resolve:function(){for(var t="",e=!1,n,r=arguments.length-1;r>=-1&&!e;r--){var i;r>=0?i=arguments[r]:(n===void 0&&(n=process.cwd()),i=n),k(i),i.length!==0&&(t=i+"/"+t,e=i.charCodeAt(0)===47)}return t=dt(t,!e),e?t.length>0?"/"+t:"/":t.length>0?t:"."},normalize:function(t){if(k(t),t.length===0)return".";var e=t.charCodeAt(0)===47,n=t.charCodeAt(t.length-1)===47;return t=dt(t,!e),t.length===0&&!e&&(t="."),t.length>0&&n&&(t+="/"),e?"/"+t:t},isAbsolute:function(t){return k(t),t.length>0&&t.charCodeAt(0)===47},join:function(){if(arguments.length===0)return".";for(var t,e=0;e<arguments.length;++e){var n=arguments[e];k(n),n.length>0&&(t===void 0?t=n:t+="/"+n)}return t===void 0?".":V.normalize(t)},relative:function(t,e){if(k(t),k(e),t===e||(t=V.resolve(t),e=V.resolve(e),t===e))return"";for(var n=1;n<t.length&&t.charCodeAt(n)===47;++n);for(var r=t.length,i=r-n,a=1;a<e.length&&e.charCodeAt(a)===47;++a);for(var o=e.length,d=o-a,c=i<d?i:d,l=-1,u=0;u<=c;++u){if(u===c){if(d>c){if(e.charCodeAt(a+u)===47)return e.slice(a+u+1);if(u===0)return e.slice(a+u)}else i>c&&(t.charCodeAt(n+u)===47?l=u:u===0&&(l=0));break}var m=t.charCodeAt(n+u),h=e.charCodeAt(a+u);if(m!==h)break;m===47&&(l=u)}var p="";for(u=n+l+1;u<=r;++u)(u===r||t.charCodeAt(u)===47)&&(p.length===0?p+="..":p+="/..");return p.length>0?p+e.slice(a+l):(a+=l,e.charCodeAt(a)===47&&++a,e.slice(a))},_makeLong:function(t){return t},dirname:function(t){if(k(t),t.length===0)return".";for(var e=t.charCodeAt(0),n=e===47,r=-1,i=!0,a=t.length-1;a>=1;--a)if(e=t.charCodeAt(a),e===47){if(!i){r=a;break}}else i=!1;return r===-1?n?"/":".":n&&r===1?"//":t.slice(0,r)},basename:function(t,e){if(e!==void 0&&typeof e!="string")throw new TypeError('"ext" argument must be a string');k(t);var n=0,r=-1,i=!0,a;if(e!==void 0&&e.length>0&&e.length<=t.length){if(e.length===t.length&&e===t)return"";var o=e.length-1,d=-1;for(a=t.length-1;a>=0;--a){var c=t.charCodeAt(a);if(c===47){if(!i){n=a+1;break}}else d===-1&&(i=!1,d=a+1),o>=0&&(c===e.charCodeAt(o)?--o===-1&&(r=a):(o=-1,r=d))}return n===r?r=d:r===-1&&(r=t.length),t.slice(n,r)}else{for(a=t.length-1;a>=0;--a)if(t.charCodeAt(a)===47){if(!i){n=a+1;break}}else r===-1&&(i=!1,r=a+1);return r===-1?"":t.slice(n,r)}},extname:function(t){k(t);for(var e=-1,n=0,r=-1,i=!0,a=0,o=t.length-1;o>=0;--o){var d=t.charCodeAt(o);if(d===47){if(!i){n=o+1;break}continue}r===-1&&(i=!1,r=o+1),d===46?e===-1?e=o:a!==1&&(a=1):e!==-1&&(a=-1)}return e===-1||r===-1||a===0||a===1&&e===r-1&&e===n+1?"":t.slice(e,r)},format:function(t){if(t===null||typeof t!="object")throw new TypeError('The "pathObject" argument must be of type Object. Received type '+typeof t);return Ot("/",t)},parse:function(t){k(t);var e={root:"",dir:"",base:"",ext:"",name:""};if(t.length===0)return e;var n=t.charCodeAt(0),r=n===47,i;r?(e.root="/",i=1):i=0;for(var a=-1,o=0,d=-1,c=!0,l=t.length-1,u=0;l>=i;--l){if(n=t.charCodeAt(l),n===47){if(!c){o=l+1;break}continue}d===-1&&(c=!1,d=l+1),n===46?a===-1?a=l:u!==1&&(u=1):a!==-1&&(u=-1)}return a===-1||d===-1||u===0||u===1&&a===d-1&&a===o+1?d!==-1&&(o===0&&r?e.base=e.name=t.slice(1,d):e.base=e.name=t.slice(o,d)):(o===0&&r?(e.name=t.slice(1,a),e.base=t.slice(1,d)):(e.name=t.slice(o,a),e.base=t.slice(o,d)),e.ext=t.slice(a,d)),o>0?e.dir=t.slice(0,o-1):r&&(e.dir="/"),e},sep:"/",delimiter:":",win32:null,posix:null};V.posix=V;ct.exports=V});var zt={};Dt(zt,{GDBBackend:()=>q,GDBDebugSession:()=>_,GDBDebugSessionBase:()=>N,GDBTargetDebugSession:()=>qe,MIRequest:()=>de,MIVarPrintValues:()=>Se,base64ToHex:()=>bt,functionBreakpointLocation:()=>j,hexToBase64:()=>gt,sendBreakDelete:()=>W,sendBreakList:()=>z,sendBreakpointInsert:()=>ue,sendDataDisassemble:()=>pe,sendDataEvaluateExpression:()=>he,sendDataListRegisterNames:()=>ge,sendDataListRegisterValues:()=>be,sendDataReadMemoryBytes:()=>U,sendDataWriteMemoryBytes:()=>fe,sendExecArguments:()=>ve,sendExecContinue:()=>D,sendExecFinish:()=>ke,sendExecInterrupt:()=>Be,sendExecNext:()=>Ie,sendExecNextInstruction:()=>Re,sendExecRun:()=>ye,sendExecStep:()=>we,sendExecStepInstruction:()=>xe,sendFunctionBreakpointInsert:()=>le,sendInterpreterExecConsole:()=>Ve,sendSourceBreakpointInsert:()=>me,sendStackInfoDepth:()=>M,sendStackListFramesRequest:()=>De,sendStackListVariables:()=>Me,sendStackSelectFrame:()=>At,sendTargetAttachRequest:()=>Pe,sendTargetSelectRequest:()=>Ae,sendThreadInfoRequest:()=>K,sendThreadSelectRequest:()=>St,sendVarAssign:()=>G,sendVarCreate:()=>B,sendVarDelete:()=>E,sendVarEvaluateExpression:()=>Ct,sendVarInfoPathExpression:()=>Ee,sendVarListChildren:()=>A,sendVarSetFormatToHex:()=>Ce,sendVarUpdate:()=>S,sourceBreakpointLocation:()=>H});module.exports=Mt(zt);var de=class{};function ce(s,t=!0){let e="";for(let n of s)(n==="\\"||n==='"')&&(e+="\\"),n==" "&&(t=!0),e+=n;return t&&(e=`"${e}"`),e}function Pt(s){if(Array.isArray(s.bkpt)){let t=s.bkpt[0],e=s.bkpt.slice(1);return{_class:s._class,bkpt:t,multiple:e}}return{_class:s._class,bkpt:s.bkpt}}function H(s,t,e="",n=!1){let r=s.gdbVersionAtLeast("8.0");if(n){if(r)return`--source ${ce(t)} --line ${e}`;{let i=`"${t}:${e}"`;return`${ce(i,!0)}`}}else return r?`-source ${t} -line ${e}`:`${t}:${e}`}function j(s,t,e=!1){let n=s.gdbVersionAtLeast("8.0");return e?n?`--function ${t}`:t:n?`-function ${t}`:t}function ue(s,t,e){return f(this,null,function*(){let n=e!=null&&e.temporary?"-t ":"",r=e!=null&&e.ignoreCount?`-i ${e==null?void 0:e.ignoreCount} `:"",a=(e!=null&&e.mode?e.mode==="hardware":!!(e!=null&&e.hardware))?"-h ":"",o=e!=null&&e.pending?"-f ":"",d=`-break-insert ${n}${a}${r}${o}${t}`,c=yield s.sendCommand(d),l=Pt(c);return e!=null&&e.condition&&(yield s.sendCommand(`-break-condition ${l.bkpt.number} ${e.condition}`)),l})}function W(s,t){return s.sendCommand(`-break-delete ${t.breakpoints.join(" ")}`)}function z(s){return s.sendCommand("-break-list")}function le(s,t,e){return f(this,null,function*(){let n=yield j(s,t,!0);return ue(s,n,e)})}function me(s,t,e,n){return f(this,null,function*(){let r=yield H(s,t,e,!0);return ue(s,r,n)})}function U(s,t,e,n=0){return s.sendCommand(`-data-read-memory-bytes -o ${n} "${t}" ${e}`)}function fe(s,t,e){return s.sendCommand(`-data-write-memory-bytes "${t}" "${e}"`)}function he(s,t){return s.sendCommand(`-data-evaluate-expression "${t}"`)}function pe(s,t,e){return f(this,null,function*(){let n=s.gdbVersionAtLeast("7.11")?"5":"3",r=yield s.sendCommand(`-data-disassemble -s "${t}" -e "${e}" -- ${n}`);if(r.asm_insns.length>0){if(!Object.prototype.hasOwnProperty.call(r.asm_insns[0],"line_asm_insn")){let i={line_asm_insn:r.asm_insns};r.asm_insns=[i]}for(let i of r.asm_insns)Object.prototype.hasOwnProperty.call(i,"line_asm_insn")||(i.line_asm_insn=[])}return Promise.resolve(r)})}function ge(s,t){let e=`-data-list-register-names --frame ${t.frameId} --thread ${t.threadId}`;return t.regno&&(e+=t.regno.join(" ")),s.sendCommand(e)}function be(s,t){let e=`-data-list-register-values --frame ${t.frameId} --thread ${t.threadId} ${t.fmt}`;return t.regno&&(e+=t.regno.join(" ")),s.sendCommand(e)}function ve(s,t){return s.sendCommand(`-exec-arguments ${t.arguments}`)}function ye(s){return s.sendCommand("-exec-run")}function D(s,t){let e="-exec-continue";return t!==void 0&&(e+=` --thread ${t}`),s.sendCommand(e)}function Ie(s,t){let e="-exec-next";return t!==void 0&&(e+=` --thread ${t}`),s.sendCommand(e)}function Re(s,t){let e="-exec-next-instruction";return t!==void 0&&(e+=` --thread ${t}`),s.sendCommand(e)}function we(s,t){let e="-exec-step";return t!==void 0&&(e+=` --thread ${t}`),s.sendCommand(e)}function xe(s,t){let e="-exec-step-instruction";return t!==void 0&&(e+=` --thread ${t}`),s.sendCommand(e)}function ke(s,t){let e="-exec-finish";return t!==void 0&&(e+=` --thread ${t}`),s.sendCommand(e)}function Be(s,t){let e="-exec-interrupt";return t!==void 0?e+=` --thread ${t}`:e+=" --all",s.sendCommand(e)}function M(s,t){let e="-stack-info-depth";return t.threadId!==void 0&&(e+=` --thread ${t.threadId}`),t.maxDepth&&(e+=` ${t.maxDepth}`),s.sendCommand(e)}function De(s,t){let e="-stack-list-frames";return t.threadId!==void 0&&(e+=` --thread ${t.threadId}`),t.noFrameFilters&&(e+=" -no-frame-filters"),t.lowFrame!==void 0&&(e+=` ${t.lowFrame}`),t.highFrame!==void 0&&(e+=` ${t.highFrame}`),s.sendCommand(e)}function At(s,t){return s.sendCommand(`-stack-select-frame ${t.framenum}`)}function Me(s,t){let e="-stack-list-variables";return t.noFrameFilters&&(e+=" --no-frame-filters"),t.skipUnavailable&&(e+=" --skip-unavailable"),t.thread!==void 0&&(e+=` --thread ${t.thread}`),t.frame!==void 0&&(e+=` --frame ${t.frame}`),e+=` --${t.printValues}`,s.sendCommand(e)}function Pe(s,t){return s.sendCommand(`-target-attach ${t.pid}`)}function Ae(s,t){return s.sendCommand(`-target-select ${t.type} ${t.parameters.join(" ")}`)}function K(s,t){let e="-thread-info";return t.threadId&&(e+=` ${t.threadId}`),s.sendCommand(e)}function St(s,t){return s.sendCommand(`-thread-select ${t.threadId}`)}var Se=(n=>(n.no="0",n.all="1",n.simple="2",n))(Se||{});function Et(s){return`"${s}"`}function B(s,t){let e="-var-create";if(t.threadId!==void 0&&(e+=` --thread ${t.threadId}`),t.frameId!==void 0&&(e+=` --frame ${t.frameId}`),e+=` ${t.name?t.name:"-"}`,t.frameAddr)e+=` ${t.frameAddr}`;else if(t.frame)switch(t.frame){default:case"current":e+=" *";break;case"floating":e+=" @";break}else e+=" *";return e+=` ${Et(t.expression)}`,s.sendCommand(e)}function A(s,t){let e="-var-list-children";return t.printValues&&(e+=` ${t.printValues}`),e+=` ${t.name}`,t.from&&t.to&&(e+=` ${t.from} ${t.to}`),s.sendCommand(e)}function S(s,t){let e="-var-update";return t.printValues?e+=` ${t.printValues}`:e+=" 1",t.name?e+=` ${t.name}`:e+=" *",s.sendCommand(e)}function E(s,t){let e=`-var-delete ${t.varname}`;return s.sendCommand(e)}function G(s,t){let e=`-var-assign ${t.varname} ${t.expression}`;return s.sendCommand(e)}function Ct(s,t){let e=`-var-evaluate-expression ${t.varname}`;return s.sendCommand(e)}function Ee(s,t){let e=`-var-info-path-expression ${t}`;return s.sendCommand(e)}function Ce(s,t){let e=`-var-set-format ${t} hexadecimal`;return s.sendCommand(e)}function Ve(s,t){return s.sendCommand(`-interpreter-exec --thread ${t.threadId} --frame ${t.frameId} console "${t.command}"`)}var at=F(rt()),$e=require("@vscode/debugadapter/lib/logger");var X=class{constructor(t){this.gdb=t;this.variableMap=new Map;this.gdb=t}getKey(t,e,n){return`frame${t}_thread${e}_depth${n}`}getVars(t,e,n){return this.variableMap.get(this.getKey(t,e,n))}getVar(t,e,n,r,i){let a=this.getVars(t,e,n);if(a){for(let o of a)if(o.expression===r&&(i!=="registers"&&(i="local"),i===o.varType))return o}}getVarByName(t,e,n,r){let i=this.getVars(t,e,n);if(i){for(let a of i)if(a.varname===r)return a}}addVar(t,e,n,r,i,a,o,d){let c=this.variableMap.get(this.getKey(t,e,n));c||(c=[],this.variableMap.set(this.getKey(t,e,n),c));let l={varname:o.name,expression:r,numchild:o.numchild,children:[],value:o.value,type:o.type,isVar:i,isChild:a,varType:d||"local"};return c.push(l),l}removeVar(t,e,n,r){return f(this,null,function*(){let i,a=this.variableMap.get(this.getKey(t,e,n));if(a){for(let o of a)if(o.varname===r){i=o;break}if(i){yield E(this.gdb,{varname:i.varname}),a.splice(a.indexOf(i),1);for(let o of i.children)yield this.removeVar(t,e,n,o.varname)}}})}updateVar(t,e,n,r){return f(this,null,function*(){let i=r,o=(yield S(this.gdb,{name:r.varname})).changelist[0];if(o)if(o.in_scope==="true")o.name===r.varname&&(r.value=o.value);else{this.removeVar(t,e,n,r.varname),yield E(this.gdb,{varname:r.varname});let d=yield B(this.gdb,{frame:"current",expression:r.expression,frameId:t,threadId:e});i=this.addVar(t,e,n,r.expression,r.isVar,r.isChild,d)}return Promise.resolve(i)})}};var P=require("@vscode/debugadapter/lib/logger"),st=F(require("utf8")),Y=class{constructor(t){this.gdb=t;this.line="";this.pos=0;this.commandQueue={}}parse(t){return new Promise(e=>{this.waitReady=e;let n=/\r?\n/,r="";t.on("data",i=>{let a=i.toString(),o=n.exec(a);for(o&&(o.index+=r.length),r+=a;o;){let d=r.slice(0,o.index);this.parseLine(d),r=r.slice(o.index+o[0].length),o=n.exec(r)}})})}parseLine(t){this.line=t,this.pos=0,this.handleLine()}queueCommand(t,e){this.commandQueue[t]=e}peek(){return this.pos<this.line.length?this.line[this.pos]:null}next(){return this.pos<this.line.length?this.line[this.pos++]:null}back(){this.pos--}restOfLine(){return this.line.substr(this.pos)}handleToken(t){let e=t,n=this.next();for(;n&&n>="0"&&n<="9";)e+=n,n=this.next();return this.back(),e}handleCString(){let t=this.next();if(!t||t!=='"')return null;let e="",n="";e:for(t=this.next();t;t=this.next()){if(n){n+=t,n.length==3&&(e+=String.fromCodePoint(parseInt(n,8)),n="");continue}switch(t){case'"':break e;case"\\":if(t=this.next(),t)switch(t){case"n":e+=` | ||
`;break;case"t":e+=" ";break;case"r":break;case"0":case"1":case"2":case"3":case"4":case"5":case"6":case"7":n=t;break;default:e+=t}else this.back();break;default:e+=t}}try{return st.decode(e)}catch(r){return P.logger.error(`Failed to decode cstring '${e}'. ${JSON.stringify(r)}`),e}}handleString(){let t="";for(let e=this.next();e;e=this.next()){if(e==="="||e===",")return this.back(),t;t+=e}return t}handleObject(){let t=this.next(),e={};if(t==="{")if(t=this.next(),t!=='"')for(;t!=="}";){t!==","&&this.back();let n=this.handleString();this.next()==="="&&(e[n]=this.handleValue()),t=this.next()}else{this.back();let n=0;for(;t!=="}";){let r=this.handleCString();r&&(e[n++]=r),t=this.next()}}return t==="}"?e:null}handleArray(){let t=this.next(),e=[];if(t==="[")for(t=this.next();t!=="]";)t!==","&&this.back(),e.push(this.handleValue()),t=this.next();return t==="]"?e:null}handleValue(){let t=this.next();switch(this.back(),t){case'"':return this.handleCString();case"{":return this.handleObject();case"[":return this.handleArray();default:if(this.handleString(),this.next()==="=")return this.handleValue()}return null}handleAsyncData(){let t={},e=this.next(),n="missing";for(;e===",";)this.peek()!=="{"?(n=this.handleString(),this.next()==="="&&(t[n]=this.handleValue())):(Array.isArray(t[n])||(t[n]=[t[n]]),t[n].push(this.handleValue())),e=this.next();return t}handleConsoleStream(){let t=this.handleCString();t&&this.gdb.emit("consoleStreamOutput",t,"stdout")}handleLogStream(){let t=this.handleCString();t&&this.gdb.emit("consoleStreamOutput",t,"log")}handleLine(){let t=this.next();if(!t)return;let e="";switch(t>="0"&&t<="9"&&(e=this.handleToken(t),t=this.next()),t){case"^":{let n=this.restOfLine();for(let i=0;i<n.length;i+=1e3){let a=i===0?"result":"-cont-";P.logger.verbose(`GDB ${a}: ${e} ${n.substr(i,1e3)}`)}let r=this.commandQueue[e];if(r){let i=this.handleString(),a=this.handleAsyncData();r(i,a),delete this.commandQueue[e]}else P.logger.error("GDB response with no command: "+e);break}case"~":case"@":this.handleConsoleStream();break;case"&":this.handleLogStream();break;case"=":{P.logger.verbose("GDB notify async: "+this.restOfLine());let n=this.handleString();this.gdb.emit("notifyAsync",n,this.handleAsyncData());break}case"*":{P.logger.verbose("GDB exec async: "+this.restOfLine());let n=this.handleString();this.gdb.emit("execAsync",n,this.handleAsyncData());break}case"+":{P.logger.verbose("GDB status async: "+this.restOfLine());let n=this.handleString();this.gdb.emit("statusAsync",n,this.handleAsyncData());break}case"(":this.waitReady&&(this.waitReady(),this.waitReady=void 0);break;default:this.back(),this.gdb.emit("consoleStreamOutput",this.restOfLine()+` | ||
`,"stdout")}}};function it(s,t){let e=s.split(/\./),n=t.split(/\./);for(let r=0;r<e.length&&r<n.length;r++){let i=parseInt(e[r],10),a=parseInt(n[r],10);if(!(isNaN(i)||isNaN(a))){if(i>a)return 1;if(i<a)return-1}}if(e.length<n.length)for(let r=e.length;r<n.length;r++){let i=parseInt(n[r],10);if(!isNaN(i)&&i!=0)return-1}if(e.length>n.length)for(let r=n.length;r<e.length;r++){let i=parseInt(e[r],10);if(!isNaN(i)&&i!=0)return 1}return 0}var q=class extends at.EventEmitter{constructor(e){super();this.processManager=e;this.parser=new Y(this);this.varMgr=new X(this);this.token=0;this.gdbAsync=!1;this.gdbNonStop=!1;this.hardwareBreakpoint=!1}get varManager(){return this.varMgr}spawn(e){return f(this,null,function*(){if(this.gdbVersion=yield this.processManager.getVersion(e),this.proc=yield this.processManager.start(e),this.proc.stdin==null||this.proc.stdout==null)throw new Error("Spawned GDB does not have stdout or stdin");this.out=this.proc.stdin,this.hardwareBreakpoint=!!e.hardwareBreakpoint,yield this.parser.parse(this.proc.stdout),this.proc.stderr&&this.proc.stderr.on("data",n=>{let r=n.toString();this.emit("consoleStreamOutput",r,"stderr")}),yield this.setNonStopMode(e.gdbNonStop),yield this.setAsyncMode(e.gdbAsync)})}setAsyncMode(e){return f(this,null,function*(){let n=this.gdbVersionAtLeast("7.8")?"mi-async":"target-async";e===void 0&&(e=!0),this.gdbNonStop&&(e=!0);let r=e?"on":"off";try{yield this.sendCommand(`-gdb-set ${n} ${r}`),this.gdbAsync=e}catch(i){yield this.sendCommand(`-gdb-set ${n} off`),this.gdbAsync=!1}})}getAsyncMode(){return this.gdbAsync}setNonStopMode(e){return f(this,null,function*(){e===void 0&&(e=!1),e&&(yield this.sendCommand("-gdb-set pagination off"));let n=e?"on":"off";try{yield this.sendCommand(`-gdb-set non-stop ${n}`),this.gdbNonStop=e}catch(r){yield this.sendCommand("-gdb-set non-stop off"),this.gdbNonStop=!1}})}isNonStopMode(){return this.gdbNonStop}getBreakpointOptions(e,n){return f(this,null,function*(){return n})}isUseHWBreakpoint(){return this.hardwareBreakpoint}pause(e){if(this.gdbAsync)Be(this,e);else{if(!this.proc)throw new Error("GDB is not running, nothing to interrupt");$e.logger.verbose(`GDB signal: SIGINT to pid ${this.proc.pid}`),this.proc.kill("SIGINT")}}gdbVersionAtLeast(e){if(!this.gdbVersion)throw new Error("gdbVersion needs to be set first");return it(this.gdbVersion,e)>=0}sendCommands(e){return f(this,null,function*(){if(e)for(let n of e)yield this.sendCommand(n)})}sendCommand(e){let n=this.nextToken();return $e.logger.verbose(`GDB command: ${n} ${e}`),new Promise((r,i)=>{if(this.out){let a=new Error;this.parser.queueCommand(n,(o,d)=>{switch(o){case"done":case"running":case"connected":case"exit":r(d);break;case"error":a.message=d.msg,i(a);break;default:a.message=`Unknown response ${o}: ${JSON.stringify(d)}`,i(a)}}),this.out.write(`${n}${e} | ||
`)}else i(new Error("gdb is not running."))})}sendEnablePrettyPrint(){return this.sendCommand("-enable-pretty-printing")}standardEscape(e,n=!0){let r="";for(let i of e)(i==="\\"||i==='"')&&(r+="\\"),i==" "&&(n=!0),r+=i;return n&&(r=`"${r}"`),r}sendFileExecAndSymbols(e){return this.sendCommand(`-file-exec-and-symbols ${this.standardEscape(e)}`)}sendFileSymbolFile(e){return this.sendCommand(`-file-symbol-file ${this.standardEscape(e)}`)}sendAddSymbolFile(e,n){return this.sendCommand(`add-symbol-file ${this.standardEscape(e)} ${n}`)}sendLoad(e,n){return this.sendCommand(`load ${this.standardEscape(e)} ${n||""}`)}sendGDBSet(e){return this.sendCommand(`-gdb-set ${e}`)}sendGDBShow(e){return this.sendCommand(`-gdb-show ${e}`)}sendGDBExit(){return this.sendCommand("-gdb-exit")}nextToken(){return this.token++}};var ht=F(ot()),pt=F(ut());var g=require("@vscode/debugadapter");var lt=require("@vscode/debugadapter"),Z=class extends lt.Event{constructor(t,e=!1){super("continued"),this.body={threadId:t,allThreadsContinued:e}}};var mt=require("@vscode/debugadapter"),ee=class extends mt.Event{constructor(t,e,n=!1){super("stopped"),this.body={reason:t,allThreadsStopped:n},typeof e=="number"&&(this.body.threadId=e)}};var te=s=>/^0x[\da-f]+$/i.test(s);var O=(s,t)=>{var e;if(te(s)){let n=s.length-2,r=BigInt(s)+BigInt(t);return r<0?`(0x${"0".padStart(n,"0")})${r}`:`0x${r.toString(16).padStart(n,"0")}`}else{let n=/^([^+-]*)([+-]\d+)?$/g.exec(s),r=n==null?void 0:n[1],i=BigInt((e=n==null?void 0:n[2])!=null?e:0),a=BigInt(t)+i;return`${r}${a<0?"-":"+"}${a<0?-a:a}`}};var Nt=s=>{let t;return s["func-name"]&&s.offset?t=`${s["func-name"]}+${s.offset}`:s["func-name"]?t=s["func-name"]:t=void 0,T({address:s.address,instructionBytes:s.opcodes,instruction:s.inst},t?{symbol:t}:{})},_t=(s,t,e)=>{let n=a=>({address:a,instruction:"failed to retrieve instruction",presentationHint:"invalid"}),r=[],i=s;for(let a=0;a<t;a++)e<0?(i=O(i,e),r.unshift(n(i))):(r.push(n(i)),i=O(i,e));return r},Te=(s,t,e)=>f(void 0,null,function*(){let n=[],i=e<0,a=Math.abs(e),o=h=>`(${t})${h<0?"-":"+"}${Math.abs(h)}`,d=(h,p)=>f(void 0,null,function*(){if(h===p)return[];let v=[],R=yield pe(s,o(h),o(p));for(let y of R.asm_insns){let x=y.line?parseInt(y.line,10):void 0,L={name:y.file,path:y.fullname};for(let ae of y.line_asm_insn)v.push(He(T({},Nt(ae)),{location:L,line:x}))}return v}),c={lower:0,higher:0},l=h=>{i?(c.higher=c.lower,c.lower+=h*4,te(t)&&BigInt(t)+BigInt(c.lower)<0&&(c.lower=Number(t)*-1)):(c.lower=c.higher,c.higher+=h*4)},u=()=>Math.sign(e)*Math.max(a-n.length,0),m=h=>{i?n.unshift(...h):n.push(...h)};try{for(;a>n.length;){l(u());let h=yield d(c.lower,c.higher);if(h.length===0)break;m(h)}}catch(h){if(n.length===0)throw h}if(a<n.length&&(e<0?n.splice(0,n.length-a):n.splice(a,n.length-a)),a>n.length){if(n.length===0)throw new Error("Cannot retrieve instructions!");let h=n[i?0:n.length-1].address,p=_t(h,a-n.length,Math.sign(e)*2);m(p)}return n});var Ge=class{constructor(t,e,n){this.id=t,this.name=e,this.running=n}},Ft=/\s|>/g,ne=/.*\[[\d]+\].*/,ft=/[\d]+/,Ht=/^-?\d+(?:\.\d*)?$/,jt=/\b(?:char|short|int|long|float|double)$/,Wt=/\bbool$/;function gt(s){if(s.length%2!==0)throw new Error("Received memory with incomplete bytes.");let t=Buffer.from(s,"hex").toString("base64");if(t.length===0&&s.length!==0)throw new Error("Received ill-formed hex input: "+s);return t}function bt(s){let t=Buffer.from(s,"base64");if(t.length===0||!t.toString("base64").startsWith(s))throw new Error("Received ill-formed base64 input: "+s);return t.toString("hex")}var N=class extends g.LoggingDebugSession{constructor(e){super();this.backendFactory=e;this.isAttach=!1;this.isRunning=!1;this.supportsRunInTerminalRequest=!1;this.supportsGdbConsole=!1;this.frameHandles=new g.Handles;this.variableHandles=new g.Handles;this.functionBreakpoints=[];this.logPointMessages={};this.threads=[];this.waitPausedThreadId=0;this.waitPausedNeeded=!1;this.isInitialized=!1;this.registerMap=new Map;this.registerMapReverse=new Map;this.logger=g.logger}applyRequestArguments(e,n){return[e,T({},n)]}customRequest(e,n,r){var i,a;if(e==="cdt-gdb-adapter/Memory")this.memoryRequest(n,r);else if(e==="cdt-gdb-tests/executeCommand"){let o=[],d=c=>o.push(c);(i=this.gdb)==null||i.addListener("consoleStreamOutput",d),(a=this.gdb)==null||a.sendCommand(r.command).then(c=>{n.body={status:"Ok",result:c,console:o},this.sendResponse(n)}).catch(c=>{let l=c instanceof Error?c.message:`Encountered a problem executing ${r.command}`;this.sendErrorResponse(n,1,l)}).finally(()=>{var c;(c=this.gdb)==null||c.removeListener("consoleStreamOutput",d)})}else return super.customRequest(e,n,r)}getBreakpointModes(){return[{label:"Hardware Breakpoint",mode:"hardware",appliesTo:["source"]},{label:"Software Breakpoint",mode:"software",appliesTo:["source"]}]}initializeRequest(e,n){this.supportsRunInTerminalRequest=n.supportsRunInTerminalRequest===!0,this.supportsGdbConsole=ht.platform()==="linux"&&this.supportsRunInTerminalRequest,e.body=e.body||{},e.body.supportsConfigurationDoneRequest=!0,e.body.supportsEvaluateForHovers=!0,e.body.supportsSetVariable=!0,e.body.supportsConditionalBreakpoints=!0,e.body.supportsHitConditionalBreakpoints=!0,e.body.supportsLogPoints=!0,e.body.supportsFunctionBreakpoints=!0,e.body.supportsDisassembleRequest=!0,e.body.supportsReadMemoryRequest=!0,e.body.supportsWriteMemoryRequest=!0,e.body.supportsSteppingGranularity=!0,e.body.breakpointModes=this.getBreakpointModes(),this.sendResponse(e)}setupCommonLoggerAndBackends(e){return f(this,null,function*(){g.logger.setup(e.verbose?g.Logger.LogLevel.Verbose:g.Logger.LogLevel.Warn,e.logFile||!1);let n=yield this.backendFactory.createGDBManager(this,e);this.gdb=yield this.backendFactory.createBackend(this,n,e),this.gdb.on("consoleStreamOutput",(r,i)=>{this.sendEvent(new g.OutputEvent(r,i))}),this.gdb.on("execAsync",(r,i)=>this.handleGDBAsync(r,i)),this.gdb.on("notifyAsync",(r,i)=>this.handleGDBNotify(r,i))})}attachOrLaunchRequest(e,n,r){return f(this,null,function*(){if(yield this.setupCommonLoggerAndBackends(r),yield this.spawn(r),!r.program){this.sendErrorResponse(e,1,"The program must be specified in the request arguments");return}if(yield this.gdb.sendFileExecAndSymbols(r.program),yield this.gdb.sendEnablePrettyPrint(),n==="attach"){this.isAttach=!0;let i=r;yield Pe(this.gdb,{pid:i.processId}),this.sendEvent(new g.OutputEvent(`attached to process ${i.processId}`))}if(yield this.gdb.sendCommands(r.initCommands),n==="launch"){let i=r;i.arguments&&(yield ve(this.gdb,{arguments:i.arguments}))}this.sendEvent(new g.InitializedEvent),this.sendResponse(e),this.isInitialized=!0})}attachRequest(e,n){return f(this,null,function*(){try{let[r,i]=this.applyRequestArguments("attach",n);yield this.attachOrLaunchRequest(e,r,i)}catch(r){this.sendErrorResponse(e,1,r instanceof Error?r.message:String(r))}})}launchRequest(e,n){return f(this,null,function*(){try{let[r,i]=this.applyRequestArguments("launch",n);yield this.attachOrLaunchRequest(e,r,i)}catch(r){this.sendErrorResponse(e,1,r instanceof Error?r.message:String(r))}})}spawn(e){return f(this,null,function*(){var n;return(n=this.gdb)==null?void 0:n.spawn(e)})}pauseIfNeeded(e=!1){return f(this,null,function*(){if(this.waitPausedNeeded=this.isRunning&&(!e||this.gdb.getAsyncMode()),this.waitPausedNeeded){let n=new Promise(r=>{this.waitPaused=r});if(this.gdb.isNonStopMode()){let r=yield K(this.gdb,{});this.waitPausedThreadId=parseInt(r["current-thread-id"],10),this.gdb.pause(this.waitPausedThreadId)}else this.gdb.pause();yield n}})}continueIfNeeded(){return f(this,null,function*(){this.waitPausedNeeded&&(this.gdb.isNonStopMode()?yield D(this.gdb,this.waitPausedThreadId):yield D(this.gdb))})}setBreakPointsRequest(e,n){return f(this,null,function*(){yield this.pauseIfNeeded();try{let r=yield z(this.gdb),i=n.source.path,a=yield H(this.gdb,i),o=r.BreakpointTable.body.filter(m=>m.number.includes(".")||!m["original-location"]||!m["original-location"].startsWith(a)?!1:this.functionBreakpoints.indexOf(m.number)===-1),{resolved:d,deletes:c}=this.resolveBreakpoints(n.breakpoints||[],o,(m,h)=>{if(m.hitCondition)return!1;let p=m.condition||void 0,v=h.cond||void 0,R=m.mode?m.mode==="hardware":this.gdb.isUseHWBreakpoint(),y=h.type==="hw breakpoint",x=`${a}${m.line}`;return h["original-location"]===x&&p===v&&R===y});c.length>0&&(yield W(this.gdb,{breakpoints:c}),c.forEach(m=>delete this.logPointMessages[m])),this.logPointMessages={};let l=(m,h)=>{m.logMessage&&(this.logPointMessages[h.number]=m.logMessage);let p=0;return h.line?p=parseInt(h.line,10):m.line&&(p=m.line),{id:parseInt(h.number,10),line:p,verified:!0}},u=[];for(let m of d){if(m.gdbbp){u.push(l(m.vsbp,m.gdbbp));continue}let h=!1,p,v=m.vsbp;if(v.hitCondition!==void 0){if(p=parseInt(v.hitCondition.replace(Ft,""),10),isNaN(p)){this.sendEvent(new g.OutputEvent(`Unable to decode expression: ${v.hitCondition}`));continue}h=!v.hitCondition.startsWith(">"),h&&p--}try{let R=v.line.toString(),y=v.mode,x=yield this.gdb.getBreakpointOptions({locationType:"source",source:i,line:R},{condition:v.condition,temporary:h,ignoreCount:p,mode:y,hardware:y?y==="hardware":this.gdb.isUseHWBreakpoint()}),L=yield me(this.gdb,i,R,x);u.push(l(v,L.bkpt))}catch(R){u.push({verified:!1,message:R instanceof Error?R.message:String(R)})}}e.body={breakpoints:u},this.sendResponse(e)}catch(r){this.sendErrorResponse(e,1,r instanceof Error?r.message:String(r))}yield this.continueIfNeeded()})}setFunctionBreakPointsRequest(e,n){return f(this,null,function*(){yield this.pauseIfNeeded();try{let i=(yield z(this.gdb)).BreakpointTable.body.filter(l=>this.functionBreakpoints.indexOf(l.number)>-1),{resolved:a,deletes:o}=this.resolveBreakpoints(n.breakpoints,i,(l,u)=>{if(l.hitCondition)return!1;let m=l.condition||void 0,h=u.cond||void 0,p=j(this.gdb,l.name);return u["original-location"]===p&&m===h});o.length>0&&(yield W(this.gdb,{breakpoints:o}),this.functionBreakpoints=this.functionBreakpoints.filter(l=>o.indexOf(l)===-1));let d=l=>({id:parseInt(l.number,10),verified:!0}),c=[];for(let l of a){if(l.gdbbp){c.push(d(l.gdbbp));continue}try{let u=yield this.gdb.getBreakpointOptions({locationType:"function",fn:l.vsbp.name},{hardware:this.gdb.isUseHWBreakpoint()}),m=yield le(this.gdb,l.vsbp.name,u);this.functionBreakpoints.push(m.bkpt.number),c.push(d(m.bkpt))}catch(u){c.push({verified:!1,message:u instanceof Error?u.message:String(u)})}}e.body={breakpoints:c},this.sendResponse(e)}catch(r){this.sendErrorResponse(e,1,r instanceof Error?r.message:String(r))}yield this.continueIfNeeded()})}resolveBreakpoints(e,n,r){let i=e.map(o=>({vsbp:o,gdbbp:n.find(d=>r(o,d))})),a=n.filter(o=>!e.find(d=>r(d,o))).map(o=>o.number);return{resolved:i,deletes:a}}configurationDoneRequest(e,n){return f(this,null,function*(){try{this.sendEvent(new g.OutputEvent(` | ||
In the Debug Console view you can interact directly with GDB. | ||
@@ -12,6 +12,6 @@ To display the value of an expression, type that expression which can reference | ||
`,"console")),this.isAttach?yield D(this.gdb):yield ye(this.gdb),this.sendResponse(e)}catch(r){this.sendErrorResponse(e,100,r instanceof Error?r.message:String(r))}})}convertThread(e){let n=e.name||e.id;e.details&&(n+=` (${e.details})`);let r=e.state==="running";return new Ge(parseInt(e.id,10),n,r)}threadsRequest(e){return f(this,null,function*(){try{if(!this.isRunning){let n=yield U(this.gdb,{});this.threads=n.threads.map(r=>this.convertThread(r)).sort((r,i)=>r.id-i.id)}e.body={threads:this.threads},this.sendResponse(e)}catch(n){this.sendErrorResponse(e,1,n instanceof Error?n.message:String(n))}})}stackTraceRequest(e,n){return f(this,null,function*(){try{let r=n.threadId,i=yield P(this.gdb,{maxDepth:100,threadId:r}),a=parseInt(i.depth,10),o=n.levels?n.levels>a?a:n.levels:a,d=n.startFrame||0,c=d+o-1,u=(yield De(this.gdb,{lowFrame:d,highFrame:c,threadId:r})).stack.map(m=>{let h;m.fullname&&(h=new g.Source(pt.basename(m.file||m.fullname),m.fullname));let p;m.line&&(p=parseInt(m.line,10));let v=this.frameHandles.create({threadId:n.threadId,frameId:parseInt(m.level,10)}),R=m.func||m.fullname||"",y=new g.StackFrame(v,R,h,p);return y.instructionPointerReference=m.addr,y});e.body={stackFrames:u,totalFrames:a},this.sendResponse(e)}catch(r){this.sendErrorResponse(e,1,r instanceof Error?r.message:String(r))}})}nextRequest(e,n){return f(this,null,function*(){try{yield n.granularity==="instruction"?Re(this.gdb,n.threadId):Ie(this.gdb,n.threadId),this.sendResponse(e)}catch(r){this.sendErrorResponse(e,1,r instanceof Error?r.message:String(r))}})}stepInRequest(e,n){return f(this,null,function*(){try{yield n.granularity==="instruction"?we(this.gdb,n.threadId):xe(this.gdb,n.threadId),this.sendResponse(e)}catch(r){this.sendErrorResponse(e,1,r instanceof Error?r.message:String(r))}})}stepOutRequest(e,n){return f(this,null,function*(){try{yield ke(this.gdb,n.threadId),this.sendResponse(e)}catch(r){this.sendErrorResponse(e,1,r instanceof Error?r.message:String(r))}})}continueRequest(e,n){return f(this,null,function*(){try{yield D(this.gdb,n.threadId);let r;this.gdb.isNonStopMode()?r=!n.threadId:r=!0,e.body={allThreadsContinued:r},this.sendResponse(e)}catch(r){this.sendErrorResponse(e,1,r instanceof Error?r.message:String(r))}})}pauseRequest(e,n){return f(this,null,function*(){try{this.gdb.pause(n.threadId),this.sendResponse(e)}catch(r){this.sendErrorResponse(e,1,r instanceof Error?r.message:String(r))}})}scopesRequest(e,n){let r={type:"frame",frameHandle:n.frameId},i={type:"registers",frameHandle:n.frameId};e.body={scopes:[new g.Scope("Local",this.variableHandles.create(r),!1),new g.Scope("Registers",this.variableHandles.create(i),!0)]},this.sendResponse(e)}variablesRequest(e,n){return f(this,null,function*(){let r=new Array;e.body={variables:r};try{let i=this.variableHandles.get(n.variablesReference);if(!i){this.sendResponse(e);return}i.type==="registers"?e.body.variables=yield this.handleVariableRequestRegister(i):i.type==="frame"?e.body.variables=yield this.handleVariableRequestFrame(i):i.type==="object"&&(e.body.variables=yield this.handleVariableRequestObject(i)),this.sendResponse(e)}catch(i){this.sendErrorResponse(e,1,i instanceof Error?i.message:String(i))}})}setVariableRequest(e,n){return f(this,null,function*(){try{let r=this.variableHandles.get(n.variablesReference);if(!r){this.sendResponse(e);return}let i=this.frameHandles.get(r.frameHandle);if(!i){this.sendResponse(e);return}let a=r.type==="object"?r.varobjName:"",o=a+(a===""?"":".")+n.name.replace(/^\[(\d+)\]/,"$1"),d=yield P(this.gdb,{maxDepth:100}),c=parseInt(d.depth,10),l=this.gdb.varManager.getVar(i.frameId,i.threadId,c,o,r.type);if(!l&&r.type==="registers"){let m=yield B(this.gdb,{expression:"$"+n.name,frameId:i.frameId,threadId:i.threadId});l=this.gdb.varManager.addVar(i.frameId,i.threadId,c,n.name,!1,!1,m,r.type),yield Ce(this.gdb,l.varname)}let u;if(l)u=yield T(this.gdb,{varname:l.varname,expression:n.value});else try{u=yield T(this.gdb,{varname:o,expression:n.value})}catch(m){if(a==="")throw m;let h=yield M(this.gdb,{name:a,printValues:"1"});for(let p of h.children)if(this.isChildOfClass(p)){let v=p.name+"."+n.name.replace(/^\[(\d+)\]/,"$1");l=this.gdb.varManager.getVar(i.frameId,i.threadId,c,v);try{u=yield T(this.gdb,{varname:v,expression:n.value});break}catch(R){continue}}if(!u)throw m}e.body={value:u.value,type:l?l.type:void 0,variablesReference:l&&parseInt(l.numchild,10)>0?this.variableHandles.create({type:"object",frameHandle:r.frameHandle,varobjName:l.varname}):0}}catch(r){this.sendErrorResponse(e,1,r instanceof Error?r.message:String(r))}this.sendResponse(e)})}evaluateRequest(e,n){return f(this,null,function*(){e.body={result:"Error: could not evaluate expression",variablesReference:0};try{if(n.frameId===void 0)throw new Error("Evaluation of expression without frameId is not supported.");let r=this.frameHandles.get(n.frameId);if(!r){this.sendResponse(e);return}if(n.expression.startsWith(">")&&n.context==="repl"){n.expression[1]==="-"?yield this.gdb.sendCommand(n.expression.slice(1)):yield Ve(this.gdb,{threadId:r.threadId,frameId:r.frameId,command:n.expression.slice(1)}),e.body={result:"\r",variablesReference:0},this.sendResponse(e);return}let i=yield P(this.gdb,{maxDepth:100}),a=parseInt(i.depth,10),o=this.gdb.varManager.getVar(r.frameId,r.threadId,a,n.expression);if(o){let c=(yield S(this.gdb,{name:o.varname})).changelist[0];if(c)if(c.in_scope==="true")c.name===o.varname&&(o.value=c.value);else{this.gdb.varManager.removeVar(r.frameId,r.threadId,a,o.varname),yield E(this.gdb,{varname:o.varname});let l=yield B(this.gdb,{expression:n.expression,frameId:r.frameId,threadId:r.threadId});o=this.gdb.varManager.addVar(r.frameId,r.threadId,a,n.expression,!1,!1,l)}}else{let d=yield B(this.gdb,{expression:n.expression,frameId:r.frameId,threadId:r.threadId});o=this.gdb.varManager.addVar(r.frameId,r.threadId,a,n.expression,!1,!1,d)}if(o){let d=n.context==="variables"&&Number(o.numchild)?yield this.getChildElements(o,n.frameId):o.value;e.body={result:d,type:o.type,variablesReference:parseInt(o.numchild,10)>0?this.variableHandles.create({type:"object",frameHandle:n.frameId,varobjName:o.varname}):0}}this.sendResponse(e)}catch(r){this.sendErrorResponse(e,1,r instanceof Error?r.message:String(r))}})}getChildElements(e,n){return f(this,null,function*(){if(Number(e.numchild)>0){let r={type:"object",frameHandle:n,varobjName:e.varname},i=yield this.handleVariableRequestObject(r),a=ft.test(e.type)?i.map(o=>this.convertValue(o)):i.reduce((o,d)=>(o[d.name]=this.convertValue(d),o),{});return JSON.stringify(a,null,2)}return e.value})}convertValue(e){let n=e.value,r=String(e.type);return Ht.test(r)?jt.test(n)?Number(n):String(n):zt.test(r)?!!n:n}memoryRequest(e,n){return f(this,null,function*(){try{if(typeof n.address!="string")throw new Error(`Invalid type for 'address', expected string, got ${typeof n.address}`);if(typeof n.length!="number")throw new Error(`Invalid type for 'length', expected number, got ${typeof n.length}`);if(typeof n.offset!="number"&&typeof n.offset!="undefined")throw new Error(`Invalid type for 'offset', expected number or undefined, got ${typeof n.offset}`);let r=n,i=yield W(this.gdb,r.address,r.length,r.offset);e.body={data:i.memory[0].contents,address:i.memory[0].begin},this.sendResponse(e)}catch(r){this.sendErrorResponse(e,1,r instanceof Error?r.message:String(r))}})}disassembleRequest(e,n){return f(this,null,function*(){var r;try{if(!n.memoryReference)throw new Error("Target memory reference is not specified!");let i=(r=n.instructionOffset)!=null?r:0,a=n.instructionCount+i,o=[],d=n.offset===void 0?n.memoryReference:q(n.memoryReference,n.offset);if(i<0){let c=yield Te(this.gdb,d,i);o.push(...c)}if(a>0){let c=yield Te(this.gdb,d,a);o.push(...c)}e.body={instructions:o},this.sendResponse(e)}catch(i){let a=i instanceof Error?i.message:String(i);this.sendEvent(new g.OutputEvent(`Error: ${a}`)),this.sendErrorResponse(e,1,a)}})}readMemoryRequest(e,n){return f(this,null,function*(){try{if(n.count){let r=yield W(this.gdb,n.memoryReference,n.count,n.offset);e.body={data:gt(r.memory[0].contents),address:r.memory[0].begin},this.sendResponse(e)}else this.sendResponse(e)}catch(r){this.sendErrorResponse(e,1,r instanceof Error?r.message:String(r))}})}writeMemoryRequest(e,n){return f(this,null,function*(){try{let{memoryReference:r,data:i}=n,a=typeof r,o=typeof i;if(a!=="string")throw new Error(`Invalid type for 'address', expected string, got ${a}`);if(o!=="string")throw new Error(`Invalid type for 'content', expected string, got ${o}`);let d=bt(i);yield fe(this.gdb,r,d),this.sendResponse(e)}catch(r){this.sendErrorResponse(e,1,r instanceof Error?r.message:String(r))}})}disconnectRequest(e,n){return f(this,null,function*(){try{yield this.gdb.sendGDBExit(),this.sendResponse(e)}catch(r){this.sendErrorResponse(e,1,r instanceof Error?r.message:String(r))}})}sendStoppedEvent(e,n,r){this.frameHandles.reset(),this.variableHandles.reset(),this.sendEvent(new Z(e,n,r))}handleGDBStopped(e){let n=i=>parseInt(i["thread-id"],10),r=i=>!!i["stopped-threads"]&&i["stopped-threads"]==="all";switch(e.reason){case"exited":case"exited-normally":this.sendEvent(new g.TerminatedEvent);break;case"breakpoint-hit":if(this.logPointMessages[e.bkptno])this.sendEvent(new g.OutputEvent(this.logPointMessages[e.bkptno])),D(this.gdb);else{let i=this.functionBreakpoints.indexOf(e.bkptno)>-1?"function breakpoint":"breakpoint";this.sendStoppedEvent(i,n(e),r(e))}break;case"end-stepping-range":case"function-finished":this.sendStoppedEvent("step",n(e),r(e));break;case"signal-received":{let i=e["signal-name"]||"signal";this.sendStoppedEvent(i,n(e),r(e));break}default:this.sendStoppedEvent("generic",n(e),r(e))}}sendContinuedEvent(e,n){this.frameHandles.reset(),this.variableHandles.reset(),this.sendEvent(new Y(e,n))}handleGDBResume(e){var a;let n=o=>parseInt(o["thread-id"],10);if((o=>!!o["thread-id"]&&o["thread-id"]==="all")(e)){let o=(a=this.threads[0])==null?void 0:a.id;return this.sendContinuedEvent(o!==void 0?o:1,!0)}return this.sendContinuedEvent(n(e))}handleGDBAsync(e,n){let r=()=>{this.isRunning=!!this.threads.length;for(let i of this.threads)i.running||(this.isRunning=!1)};switch(e){case"running":if(this.gdb.isNonStopMode()){let i=n["thread-id"],a=parseInt(i,10);for(let o of this.threads)(o.id===a||i==="all")&&(o.running=!0)}else for(let i of this.threads)i.running=!0;r(),this.isInitialized&&this.handleGDBResume(n);break;case"stopped":{let i=!1;if(this.gdb.isNonStopMode()){let o=parseInt(n["thread-id"],10);for(let d of this.threads)d.id===o&&(d.running=!1);this.waitPaused&&n.reason==="signal-received"&&this.waitPausedThreadId===o&&(i=!0)}else{for(let o of this.threads)o.running=!1;this.waitPaused&&n.reason==="signal-received"&&(i=!0)}this.waitPaused&&(i||(this.waitPausedNeeded=!1),this.waitPaused(),this.waitPaused=void 0);let a=this.isRunning;r(),!i&&(this.gdb.isNonStopMode()||a&&!this.isRunning)&&this.isInitialized&&this.handleGDBStopped(n);break}default:g.logger.warn(`GDB unhandled async: ${e}: ${JSON.stringify(n)}`)}}handleGDBNotify(e,n){switch(e){case"thread-created":this.threads.push(this.convertThread(n));break;case"thread-exited":{let i=parseInt(n.id,10);this.threads=this.threads.filter(a=>a.id!==i);break}case"thread-selected":case"thread-group-added":case"thread-group-started":case"thread-group-exited":case"library-loaded":case"breakpoint-modified":case"breakpoint-deleted":case"cmd-param-changed":break;default:g.logger.warn(`GDB unhandled notify: ${e}: ${JSON.stringify(n)}`)}}handleVariableRequestFrame(e){return f(this,null,function*(){let n=[],r=this.frameHandles.get(e.frameHandle);if(!r)return Promise.resolve(n);let i=!1,a=0,o=yield P(this.gdb,{maxDepth:100}),d=parseInt(o.depth,10),c=new Array,l=this.gdb.varManager.getVars(r.frameId,r.threadId,d);if(l){for(let u of l)if(u.isVar&&!u.isChild){let h=(yield S(this.gdb,{name:u.varname})).changelist[0],p=!0;if(h?h.in_scope==="true"?(a++,h.name===u.varname&&(u.value=h.value)):(i=!0,p=!1,c.push(h.name)):u.value&&a++,p){let v=u.value;te.test(u.type)&&(v=yield this.getAddr(u)),n.push({name:u.expression,evaluateName:u.expression,value:v,type:u.type,memoryReference:`&(${u.expression})`,variablesReference:parseInt(u.numchild,10)>0?this.variableHandles.create({type:"object",frameHandle:e.frameHandle,varobjName:u.varname}):0})}}for(let u of c)yield this.gdb.varManager.removeVar(r.frameId,r.threadId,d,u)}if(i===!0||a===0){let u=yield Pe(this.gdb,{thread:r.threadId,frame:r.frameId,printValues:"simple-values"});for(let m of u.variables){let h=this.gdb.varManager.getVar(r.frameId,r.threadId,d,m.name);if(h)h=yield this.gdb.varManager.updateVar(r.frameId,r.threadId,d,h),h.isVar=!0;else{let v=yield B(this.gdb,{expression:m.name,frameId:r.frameId,threadId:r.threadId});h=this.gdb.varManager.addVar(r.frameId,r.threadId,d,m.name,!0,!1,v)}let p=h.value;te.test(h.type)&&(p=yield this.getAddr(h)),n.push({name:h.expression,evaluateName:h.expression,value:p,type:h.type,memoryReference:`&(${h.expression})`,variablesReference:parseInt(h.numchild,10)>0?this.variableHandles.create({type:"object",frameHandle:e.frameHandle,varobjName:h.varname}):0})}}return Promise.resolve(n)})}handleVariableRequestObject(e){return f(this,null,function*(){var u;let n=[],r=this.frameHandles.get(e.frameHandle);if(!r)return Promise.resolve(n);let i=yield P(this.gdb,{maxDepth:100}),a=parseInt(i.depth,10),o,d=e.varobjName,c=this.gdb.varManager.getVarByName(r.frameId,r.threadId,a,e.varobjName);c?(o=yield M(this.gdb,{name:c.varname,printValues:"1"}),d=c.varname):o=yield M(this.gdb,{name:e.varobjName,printValues:"1"});let l=(u=c==null?void 0:c.expression)!=null?u:yield this.getFullPathExpression(d);for(let m of o.children)if(this.isChildOfClass(m)){let p=`${d}.${m.exp}`,v=yield M(this.gdb,{name:p,printValues:"1"}),R=`${l}.${m.exp}`;for(let y of v.children){let k=`${p}.${y.exp}`;n.push({name:y.exp,evaluateName:`${R}.${y.exp}`,value:y.value?y.value:y.type,type:y.type,variablesReference:parseInt(y.numchild,10)>0?this.variableHandles.create({type:"object",frameHandle:e.frameHandle,varobjName:k}):0})}}else{let p=`${e.varobjName}.${m.exp}`,v=p,R=m.value?m.value:m.type,y=te.test(m.type),k=c!==void 0?te.test(c.type)&&ft.test(m.exp):!1;k&&(p=`[${m.exp}]`);let ie=k?p:m.exp,ae=y||k?`${l}[${m.exp}]`:`${l}.${m.exp}`;n.push({name:ie,evaluateName:ae,value:R,type:m.type,variablesReference:parseInt(m.numchild,10)>0?this.variableHandles.create({type:"object",frameHandle:e.frameHandle,varobjName:v}):0})}return Promise.resolve(n)})}getFullPathExpression(e){return f(this,null,function*(){return(yield Ee(this.gdb,e)).path_expr.replace(/[()]/g,"")})}handleVariableRequestRegister(e){return f(this,null,function*(){let n=[],r=this.frameHandles.get(e.frameHandle);if(!r)return Promise.resolve(n);if(this.registerMap.size===0){let o=yield ge(this.gdb,{frameId:r.frameId,threadId:r.threadId}),d=0,c=o["register-names"];for(let l of c)l!==""&&(this.registerMap.set(l,d),this.registerMapReverse.set(d,l)),d++}let a=(yield be(this.gdb,{fmt:"x",frameId:r.frameId,threadId:r.threadId}))["register-values"];for(let o of a){let d=o.number,c=this.registerMapReverse.get(parseInt(d));if(c){let l=o.value,u={name:c,evaluateName:"$"+c,value:l,variablesReference:0};n.push(u)}else throw new Error("Unable to parse response for reg. values")}return Promise.resolve(n)})}getAddr(e){return f(this,null,function*(){let n=yield he(this.gdb,`&(${e.expression})`);return n.value?n.value:e.value})}isChildOfClass(e){return e.type===void 0&&e.value===""&&(e.exp==="public"||e.exp==="protected"||e.exp==="private")}};var se=require("@vscode/debugadapter");var vt=require("@vscode/debugadapter/lib/logger");var ne=class{getVersion(t){return f(this,null,function*(){throw new Error("Method not implemented yet!")})}start(t){return f(this,null,function*(){throw new Error("Method not implemented yet!")})}stop(){return f(this,null,function*(){throw new Error("Method not implemented yet!")})}};var re=class{constructor(){this.logger=vt.logger}createGDBManager(t,e){return f(this,null,function*(){return new ne})}createBackend(t,e,n){return f(this,null,function*(){return new G(e)})}};var N=class extends O{constructor(t){super(t||new re),this.logger=se.logger}static run(t){se.DebugSession.run(t)}};var x=require("@vscode/debugadapter");var qe=class s extends N{constructor(e,n){super(e);this.killGdbServer=!0;this.gdbserverFactory=n,this.logger=x.logger}setupCommonLoggerAndBackends(e){return f(this,null,function*(){var n;yield ze(s.prototype,this,"setupCommonLoggerAndBackends").call(this,e),this.gdbserverProcessManager=yield(n=this.gdbserverFactory)==null?void 0:n.createGDBServerManager(e)})}attachOrLaunchRequest(e,n,r){return f(this,null,function*(){var i;if(yield this.setupCommonLoggerAndBackends(r),n==="launch"){let a=r;if(((i=a.target)==null?void 0:i.serverParameters)===void 0&&!a.program){this.sendErrorResponse(e,1,"The program must be specified in the launch request arguments");return}yield this.startGDBServer(a)}yield this.startGDBAndAttachToTarget(e,r)})}launchRequest(e,n){return f(this,null,function*(){try{let[r,i]=this.applyRequestArguments("launch",n);yield this.attachOrLaunchRequest(e,r,i)}catch(r){this.sendErrorResponse(e,1,r instanceof Error?r.message:String(r))}})}attachRequest(e,n){return f(this,null,function*(){try{let[r,i]=this.applyRequestArguments("attach",n);yield this.attachOrLaunchRequest(e,r,i)}catch(r){this.sendErrorResponse(e,1,r instanceof Error?r.message:String(r))}})}startGDBServer(e){return f(this,null,function*(){e.target===void 0&&(e.target={});let n=e.target;this.killGdbServer=n.automaticallyKillServer!==!1,yield new Promise((r,i)=>f(this,null,function*(){if(!this.gdbserverProcessManager)throw new Error("GDBServer process manager is not initialised!");this.gdbserver=yield this.gdbserverProcessManager.start(e);let a=!1,o="",d="",c=l=>{};if(n.port&&n.serverParameters?setTimeout(()=>{a=!0,r()},n.serverStartupDelay!==void 0?n.serverStartupDelay:0):c=l=>{let m=new RegExp(n.serverPortRegExp?n.serverPortRegExp:`Listening on port ([0-9]+)\r? | ||
`).exec(l);m!==null&&(n.port=m[1],c=h=>{},setTimeout(()=>{a=!0,r()},n.serverStartupDelay!==void 0?n.serverStartupDelay:0))},this.gdbserver.stdout)this.gdbserver.stdout.on("data",l=>{let u=l.toString();a||(o+=u),this.sendEvent(new x.OutputEvent(u,"server")),c(o)});else throw new Error("Missing stdout in spawned gdbserver");if(this.gdbserver.stderr)this.gdbserver.stderr.on("data",l=>{let u=l.toString();a||(d+=u),this.sendEvent(new x.OutputEvent(u,"server")),c(d)});else throw new Error("Missing stderr in spawned gdbserver");this.gdbserver.on("exit",(l,u)=>{let m;l===null?m=`gdbserver is killed by signal ${u}`:m=`gdbserver has exited with code ${l}`,this.sendEvent(new x.OutputEvent(m,"server")),a||(a=!0,i(new Error(m+` | ||
`+d)))}),this.gdbserver.on("error",l=>{let u=`gdbserver has hit error ${l}`;this.sendEvent(new x.OutputEvent(u,"server")),a||(a=!0,i(new Error(u+` | ||
`+d)))})}))})}startGDBAndAttachToTarget(e,n){return f(this,null,function*(){n.target===void 0&&(n.target={});let r=n.target;try{if(this.isAttach=!0,yield this.spawn(n),yield this.gdb.sendFileExecAndSymbols(n.program),yield this.gdb.sendEnablePrettyPrint(),n.imageAndSymbols&&n.imageAndSymbols.symbolFileName&&(n.imageAndSymbols.symbolOffset?yield this.gdb.sendAddSymbolFile(n.imageAndSymbols.symbolFileName,n.imageAndSymbols.symbolOffset):yield this.gdb.sendFileSymbolFile(n.imageAndSymbols.symbolFileName)),r.connectCommands===void 0){this.targetType=r.type!==void 0?r.type:"remote";let i;r.port!==void 0?i=[r.host!==void 0?`${r.host}:${r.port}`:`localhost:${r.port}`]:i=[];let a=r.parameters!==void 0?r.parameters:i;yield Me(this.gdb,{type:this.targetType,parameters:a}),this.sendEvent(new x.OutputEvent(`connected to ${this.targetType} target ${a.join(" ")}`))}else yield this.gdb.sendCommands(r.connectCommands),this.sendEvent(new x.OutputEvent("connected to target using provided connectCommands"));yield this.gdb.sendCommands(n.initCommands),n.imageAndSymbols&&n.imageAndSymbols.imageFileName&&(yield this.gdb.sendLoad(n.imageAndSymbols.imageFileName,n.imageAndSymbols.imageOffset)),yield this.gdb.sendCommands(n.preRunCommands),this.sendEvent(new x.InitializedEvent),this.sendResponse(e),this.isInitialized=!0}catch(i){this.sendErrorResponse(e,1,i instanceof Error?i.message:String(i))}})}stopGDBServer(){return f(this,null,function*(){var e;return(e=this.gdbserverProcessManager)==null?void 0:e.stop()})}disconnectRequest(e,n){return f(this,null,function*(){try{this.targetType==="remote"&&(yield this.pauseIfNeeded(!0),yield this.gdb.sendCommand("disconnect")),yield this.gdb.sendGDBExit(),this.killGdbServer&&(yield this.stopGDBServer(),this.sendEvent(new x.OutputEvent("gdbserver stopped","server"))),this.sendResponse(e)}catch(r){this.sendErrorResponse(e,1,r instanceof Error?r.message:String(r))}})}}; | ||
`,"console")),this.isAttach?yield D(this.gdb):yield ye(this.gdb),this.sendResponse(e)}catch(r){this.sendErrorResponse(e,100,r instanceof Error?r.message:String(r))}})}convertThread(e){let n=e.name||e.id;e.details&&(n+=` (${e.details})`);let r=e.state==="running";return new Ge(parseInt(e.id,10),n,r)}threadsRequest(e){return f(this,null,function*(){try{if(!this.isRunning){let n=yield K(this.gdb,{});this.threads=n.threads.map(r=>this.convertThread(r)).sort((r,i)=>r.id-i.id)}e.body={threads:this.threads},this.sendResponse(e)}catch(n){this.sendErrorResponse(e,1,n instanceof Error?n.message:String(n))}})}stackTraceRequest(e,n){return f(this,null,function*(){try{let r=n.threadId,i=yield M(this.gdb,{maxDepth:100,threadId:r}),a=parseInt(i.depth,10),o=n.levels?n.levels>a?a:n.levels:a,d=n.startFrame||0,c=d+o-1,u=(yield De(this.gdb,{lowFrame:d,highFrame:c,threadId:r})).stack.map(m=>{let h;m.fullname&&(h=new g.Source(pt.basename(m.file||m.fullname),m.fullname));let p;m.line&&(p=parseInt(m.line,10));let v=this.frameHandles.create({threadId:n.threadId,frameId:parseInt(m.level,10)}),R=m.func||m.fullname||"",y=new g.StackFrame(v,R,h,p);return y.instructionPointerReference=m.addr,y});e.body={stackFrames:u,totalFrames:a},this.sendResponse(e)}catch(r){this.sendErrorResponse(e,1,r instanceof Error?r.message:String(r))}})}nextRequest(e,n){return f(this,null,function*(){try{yield n.granularity==="instruction"?Re(this.gdb,n.threadId):Ie(this.gdb,n.threadId),this.sendResponse(e)}catch(r){this.sendErrorResponse(e,1,r instanceof Error?r.message:String(r))}})}stepInRequest(e,n){return f(this,null,function*(){try{yield n.granularity==="instruction"?xe(this.gdb,n.threadId):we(this.gdb,n.threadId),this.sendResponse(e)}catch(r){this.sendErrorResponse(e,1,r instanceof Error?r.message:String(r))}})}stepOutRequest(e,n){return f(this,null,function*(){try{yield ke(this.gdb,n.threadId),this.sendResponse(e)}catch(r){this.sendErrorResponse(e,1,r instanceof Error?r.message:String(r))}})}continueRequest(e,n){return f(this,null,function*(){try{yield D(this.gdb,n.threadId);let r;this.gdb.isNonStopMode()?r=!n.threadId:r=!0,e.body={allThreadsContinued:r},this.sendResponse(e)}catch(r){this.sendErrorResponse(e,1,r instanceof Error?r.message:String(r))}})}pauseRequest(e,n){return f(this,null,function*(){try{this.gdb.pause(n.threadId),this.sendResponse(e)}catch(r){this.sendErrorResponse(e,1,r instanceof Error?r.message:String(r))}})}scopesRequest(e,n){let r={type:"frame",frameHandle:n.frameId},i={type:"registers",frameHandle:n.frameId};e.body={scopes:[new g.Scope("Local",this.variableHandles.create(r),!1),new g.Scope("Registers",this.variableHandles.create(i),!0)]},this.sendResponse(e)}variablesRequest(e,n){return f(this,null,function*(){let r=new Array;e.body={variables:r};try{let i=this.variableHandles.get(n.variablesReference);if(!i){this.sendResponse(e);return}i.type==="registers"?e.body.variables=yield this.handleVariableRequestRegister(i):i.type==="frame"?e.body.variables=yield this.handleVariableRequestFrame(i):i.type==="object"&&(e.body.variables=yield this.handleVariableRequestObject(i)),this.sendResponse(e)}catch(i){this.sendErrorResponse(e,1,i instanceof Error?i.message:String(i))}})}setVariableRequest(e,n){return f(this,null,function*(){try{let r=this.variableHandles.get(n.variablesReference);if(!r){this.sendResponse(e);return}let i=this.frameHandles.get(r.frameHandle);if(!i){this.sendResponse(e);return}let a=r.type==="object"?r.varobjName:"",o=a+(a===""?"":".")+n.name.replace(/^\[(\d+)\]/,"$1"),d=yield M(this.gdb,{maxDepth:100}),c=parseInt(d.depth,10),l=this.gdb.varManager.getVar(i.frameId,i.threadId,c,o,r.type);if(!l&&r.type==="registers"){let m=yield B(this.gdb,{expression:"$"+n.name,frameId:i.frameId,threadId:i.threadId});l=this.gdb.varManager.addVar(i.frameId,i.threadId,c,n.name,!1,!1,m,r.type),yield Ce(this.gdb,l.varname)}let u;if(l)u=yield G(this.gdb,{varname:l.varname,expression:n.value});else try{u=yield G(this.gdb,{varname:o,expression:n.value})}catch(m){if(a==="")throw m;let h=yield A(this.gdb,{name:a,printValues:"1"});for(let p of h.children)if(this.isChildOfClass(p)){let v=p.name+"."+n.name.replace(/^\[(\d+)\]/,"$1");l=this.gdb.varManager.getVar(i.frameId,i.threadId,c,v);try{u=yield G(this.gdb,{varname:v,expression:n.value});break}catch(R){continue}}if(!u)throw m}e.body={value:u.value,type:l?l.type:void 0,variablesReference:l&&parseInt(l.numchild,10)>0?this.variableHandles.create({type:"object",frameHandle:r.frameHandle,varobjName:l.varname}):0}}catch(r){this.sendErrorResponse(e,1,r instanceof Error?r.message:String(r))}this.sendResponse(e)})}evaluateRequest(e,n){return f(this,null,function*(){e.body={result:"Error: could not evaluate expression",variablesReference:0};try{if(n.frameId===void 0)throw new Error("Evaluation of expression without frameId is not supported.");let r=this.frameHandles.get(n.frameId);if(!r){this.sendResponse(e);return}if(n.expression.startsWith(">")&&n.context==="repl"){n.expression[1]==="-"?yield this.gdb.sendCommand(n.expression.slice(1)):yield Ve(this.gdb,{threadId:r.threadId,frameId:r.frameId,command:n.expression.slice(1)}),e.body={result:"\r",variablesReference:0},this.sendResponse(e);return}let i=yield M(this.gdb,{maxDepth:100}),a=parseInt(i.depth,10),o=this.gdb.varManager.getVar(r.frameId,r.threadId,a,n.expression);if(o){let c=(yield S(this.gdb,{name:o.varname})).changelist[0];if(c)if(c.in_scope==="true")c.name===o.varname&&(o.value=c.value);else{this.gdb.varManager.removeVar(r.frameId,r.threadId,a,o.varname),yield E(this.gdb,{varname:o.varname});let l=yield B(this.gdb,{expression:n.expression,frameId:r.frameId,threadId:r.threadId});o=this.gdb.varManager.addVar(r.frameId,r.threadId,a,n.expression,!1,!1,l)}}else{let d=yield B(this.gdb,{expression:n.expression,frameId:r.frameId,threadId:r.threadId});o=this.gdb.varManager.addVar(r.frameId,r.threadId,a,n.expression,!1,!1,d)}if(o){let d=n.context==="variables"&&Number(o.numchild)?yield this.getChildElements(o,n.frameId):o.value;e.body={result:d,type:o.type,variablesReference:parseInt(o.numchild,10)>0?this.variableHandles.create({type:"object",frameHandle:n.frameId,varobjName:o.varname}):0}}this.sendResponse(e)}catch(r){this.sendErrorResponse(e,1,r instanceof Error?r.message:String(r))}})}getChildElements(e,n){return f(this,null,function*(){if(Number(e.numchild)>0){let r={type:"object",frameHandle:n,varobjName:e.varname},i=yield this.handleVariableRequestObject(r),a=ft.test(e.type)?i.map(o=>this.convertValue(o)):i.reduce((o,d)=>(o[d.name]=this.convertValue(d),o),{});return JSON.stringify(a,null,2)}return e.value})}convertValue(e){let n=e.value,r=String(e.type);return jt.test(r)?Ht.test(n)?Number(n):String(n):Wt.test(r)?!!n:n}memoryRequest(e,n){return f(this,null,function*(){try{if(typeof n.address!="string")throw new Error(`Invalid type for 'address', expected string, got ${typeof n.address}`);if(typeof n.length!="number")throw new Error(`Invalid type for 'length', expected number, got ${typeof n.length}`);if(typeof n.offset!="number"&&typeof n.offset!="undefined")throw new Error(`Invalid type for 'offset', expected number or undefined, got ${typeof n.offset}`);let r=n,i=yield U(this.gdb,r.address,r.length,r.offset);e.body={data:i.memory[0].contents,address:i.memory[0].begin},this.sendResponse(e)}catch(r){this.sendErrorResponse(e,1,r instanceof Error?r.message:String(r))}})}disassembleRequest(e,n){return f(this,null,function*(){var r;try{if(!n.memoryReference)throw new Error("Target memory reference is not specified!");let i=(r=n.instructionOffset)!=null?r:0,a=n.instructionCount+i,o=[],d=n.offset===void 0?n.memoryReference:O(n.memoryReference,n.offset);if(i<0){let c=yield Te(this.gdb,d,i);o.push(...c)}if(a>0){let c=yield Te(this.gdb,d,a);o.push(...c)}e.body={instructions:o},this.sendResponse(e)}catch(i){let a=i instanceof Error?i.message:String(i);this.sendEvent(new g.OutputEvent(`Error: ${a}`)),this.sendErrorResponse(e,1,a)}})}readMemoryRequest(e,n){return f(this,null,function*(){try{if(n.count){let r=yield U(this.gdb,n.memoryReference,n.count,n.offset);e.body={data:gt(r.memory[0].contents),address:r.memory[0].begin},this.sendResponse(e)}else this.sendResponse(e)}catch(r){this.sendErrorResponse(e,1,r instanceof Error?r.message:String(r))}})}writeMemoryRequest(e,n){return f(this,null,function*(){try{let{memoryReference:r,data:i}=n,a=typeof r,o=typeof i;if(a!=="string")throw new Error(`Invalid type for 'address', expected string, got ${a}`);if(o!=="string")throw new Error(`Invalid type for 'content', expected string, got ${o}`);let d=bt(i);yield fe(this.gdb,r,d),this.sendResponse(e)}catch(r){this.sendErrorResponse(e,1,r instanceof Error?r.message:String(r))}})}disconnectRequest(e,n){return f(this,null,function*(){try{yield this.gdb.sendGDBExit(),this.sendResponse(e)}catch(r){this.sendErrorResponse(e,1,r instanceof Error?r.message:String(r))}})}sendStoppedEvent(e,n,r){this.frameHandles.reset(),this.variableHandles.reset(),this.sendEvent(new ee(e,n,r))}handleGDBStopped(e){let n=i=>parseInt(i["thread-id"],10),r=i=>!!i["stopped-threads"]&&i["stopped-threads"]==="all";switch(e.reason){case"exited":case"exited-normally":this.sendEvent(new g.TerminatedEvent);break;case"breakpoint-hit":if(this.logPointMessages[e.bkptno])this.sendEvent(new g.OutputEvent(this.logPointMessages[e.bkptno])),D(this.gdb);else{let i=this.functionBreakpoints.indexOf(e.bkptno)>-1?"function breakpoint":"breakpoint";this.sendStoppedEvent(i,n(e),r(e))}break;case"end-stepping-range":case"function-finished":this.sendStoppedEvent("step",n(e),r(e));break;case"signal-received":{let i=e["signal-name"]||"signal";this.sendStoppedEvent(i,n(e),r(e));break}default:this.sendStoppedEvent("generic",n(e),r(e))}}sendContinuedEvent(e,n){this.frameHandles.reset(),this.variableHandles.reset(),this.sendEvent(new Z(e,n))}handleGDBResume(e){var a;let n=o=>parseInt(o["thread-id"],10);if((o=>!!o["thread-id"]&&o["thread-id"]==="all")(e)){let o=(a=this.threads[0])==null?void 0:a.id;return this.sendContinuedEvent(o!==void 0?o:1,!0)}return this.sendContinuedEvent(n(e))}handleGDBAsync(e,n){let r=()=>{this.isRunning=!!this.threads.length;for(let i of this.threads)i.running||(this.isRunning=!1)};switch(e){case"running":if(this.gdb.isNonStopMode()){let i=n["thread-id"],a=parseInt(i,10);for(let o of this.threads)(o.id===a||i==="all")&&(o.running=!0)}else for(let i of this.threads)i.running=!0;r(),this.isInitialized&&this.handleGDBResume(n);break;case"stopped":{let i=!1;if(this.gdb.isNonStopMode()){let o=parseInt(n["thread-id"],10);for(let d of this.threads)d.id===o&&(d.running=!1);this.waitPaused&&n.reason==="signal-received"&&this.waitPausedThreadId===o&&(i=!0)}else{for(let o of this.threads)o.running=!1;this.waitPaused&&n.reason==="signal-received"&&(i=!0)}this.waitPaused&&(i||(this.waitPausedNeeded=!1),this.waitPaused(),this.waitPaused=void 0);let a=this.isRunning;r(),!i&&(this.gdb.isNonStopMode()||a&&!this.isRunning)&&this.isInitialized&&this.handleGDBStopped(n);break}default:g.logger.warn(`GDB unhandled async: ${e}: ${JSON.stringify(n)}`)}}handleGDBNotify(e,n){switch(e){case"thread-created":this.threads.push(this.convertThread(n));break;case"thread-exited":{let i=parseInt(n.id,10);this.threads=this.threads.filter(a=>a.id!==i);break}case"thread-selected":case"thread-group-added":case"thread-group-started":case"thread-group-exited":case"library-loaded":case"breakpoint-modified":case"breakpoint-deleted":case"cmd-param-changed":break;default:g.logger.warn(`GDB unhandled notify: ${e}: ${JSON.stringify(n)}`)}}handleVariableRequestFrame(e){return f(this,null,function*(){let n=[],r=this.frameHandles.get(e.frameHandle);if(!r)return Promise.resolve(n);let i=!1,a=0,o=yield M(this.gdb,{maxDepth:100}),d=parseInt(o.depth,10),c=new Array,l=this.gdb.varManager.getVars(r.frameId,r.threadId,d);if(l){for(let u of l)if(u.isVar&&!u.isChild){let h=(yield S(this.gdb,{name:u.varname})).changelist[0],p=!0;if(h?h.in_scope==="true"?(a++,h.name===u.varname&&(u.value=h.value)):(i=!0,p=!1,c.push(h.name)):u.value&&a++,p){let v=u.value;ne.test(u.type)&&(v=yield this.getAddr(u)),n.push({name:u.expression,evaluateName:u.expression,value:v,type:u.type,memoryReference:`&(${u.expression})`,variablesReference:parseInt(u.numchild,10)>0?this.variableHandles.create({type:"object",frameHandle:e.frameHandle,varobjName:u.varname}):0})}}for(let u of c)yield this.gdb.varManager.removeVar(r.frameId,r.threadId,d,u)}if(i===!0||a===0){let u=yield Me(this.gdb,{thread:r.threadId,frame:r.frameId,printValues:"simple-values"});for(let m of u.variables){let h=this.gdb.varManager.getVar(r.frameId,r.threadId,d,m.name);if(h)h=yield this.gdb.varManager.updateVar(r.frameId,r.threadId,d,h),h.isVar=!0;else{let v=yield B(this.gdb,{expression:m.name,frameId:r.frameId,threadId:r.threadId});h=this.gdb.varManager.addVar(r.frameId,r.threadId,d,m.name,!0,!1,v)}let p=h.value;ne.test(h.type)&&(p=yield this.getAddr(h)),n.push({name:h.expression,evaluateName:h.expression,value:p,type:h.type,memoryReference:`&(${h.expression})`,variablesReference:parseInt(h.numchild,10)>0?this.variableHandles.create({type:"object",frameHandle:e.frameHandle,varobjName:h.varname}):0})}}return Promise.resolve(n)})}handleVariableRequestObject(e){return f(this,null,function*(){var u;let n=[],r=this.frameHandles.get(e.frameHandle);if(!r)return Promise.resolve(n);let i=yield M(this.gdb,{maxDepth:100}),a=parseInt(i.depth,10),o,d=e.varobjName,c=this.gdb.varManager.getVarByName(r.frameId,r.threadId,a,e.varobjName);c?(o=yield A(this.gdb,{name:c.varname,printValues:"1"}),d=c.varname):o=yield A(this.gdb,{name:e.varobjName,printValues:"1"});let l=(u=c==null?void 0:c.expression)!=null?u:yield this.getFullPathExpression(d);for(let m of o.children)if(this.isChildOfClass(m)){let p=`${d}.${m.exp}`,v=yield A(this.gdb,{name:p,printValues:"1"}),R=`${l}.${m.exp}`;for(let y of v.children){let x=`${p}.${y.exp}`;n.push({name:y.exp,evaluateName:`${R}.${y.exp}`,value:y.value?y.value:y.type,type:y.type,variablesReference:parseInt(y.numchild,10)>0?this.variableHandles.create({type:"object",frameHandle:e.frameHandle,varobjName:x}):0})}}else{let p=`${e.varobjName}.${m.exp}`,v=p,R=m.value?m.value:m.type,y=ne.test(m.type),x=c!==void 0?ne.test(c.type)&&ft.test(m.exp):!1;x&&(p=`[${m.exp}]`);let L=x?p:m.exp,ae=y||x?`${l}[${m.exp}]`:`${l}.${m.exp}`;n.push({name:L,evaluateName:ae,value:R,type:m.type,variablesReference:parseInt(m.numchild,10)>0?this.variableHandles.create({type:"object",frameHandle:e.frameHandle,varobjName:v}):0})}return Promise.resolve(n)})}getFullPathExpression(e){return f(this,null,function*(){return(yield Ee(this.gdb,e)).path_expr.replace(/[()]/g,"")})}handleVariableRequestRegister(e){return f(this,null,function*(){let n=[],r=this.frameHandles.get(e.frameHandle);if(!r)return Promise.resolve(n);if(this.registerMap.size===0){let o=yield ge(this.gdb,{frameId:r.frameId,threadId:r.threadId}),d=0,c=o["register-names"];for(let l of c)l!==""&&(this.registerMap.set(l,d),this.registerMapReverse.set(d,l)),d++}let a=(yield be(this.gdb,{fmt:"x",frameId:r.frameId,threadId:r.threadId}))["register-values"];for(let o of a){let d=o.number,c=this.registerMapReverse.get(parseInt(d));if(c){let l=o.value,u={name:c,evaluateName:"$"+c,value:l,variablesReference:0};n.push(u)}else throw new Error("Unable to parse response for reg. values")}return Promise.resolve(n)})}getAddr(e){return f(this,null,function*(){let n=yield he(this.gdb,`&(${e.expression})`);return n.value?n.value:e.value})}isChildOfClass(e){return e.type===void 0&&e.value===""&&(e.exp==="public"||e.exp==="protected"||e.exp==="private")}};var ie=require("@vscode/debugadapter");var vt=require("@vscode/debugadapter/lib/logger");var re=class{getVersion(t){return f(this,null,function*(){throw new Error("Method not implemented yet!")})}start(t){return f(this,null,function*(){throw new Error("Method not implemented yet!")})}stop(){return f(this,null,function*(){throw new Error("Method not implemented yet!")})}};var se=class{constructor(){this.logger=vt.logger}createGDBManager(t,e){return f(this,null,function*(){return new re})}createBackend(t,e,n){return f(this,null,function*(){return new q(e)})}};var _=class extends N{constructor(t){super(t||new se),this.logger=ie.logger}static run(t){ie.DebugSession.run(t)}};var w=require("@vscode/debugadapter");var qe=class s extends _{constructor(e,n){super(e);this.killGdbServer=!0;this.gdbserverFactory=n,this.logger=w.logger}setupCommonLoggerAndBackends(e){return f(this,null,function*(){var n;yield We(s.prototype,this,"setupCommonLoggerAndBackends").call(this,e),this.gdbserverProcessManager=yield(n=this.gdbserverFactory)==null?void 0:n.createGDBServerManager(e)})}attachOrLaunchRequest(e,n,r){return f(this,null,function*(){var i;if(yield this.setupCommonLoggerAndBackends(r),n==="launch"){let a=r;if(((i=a.target)==null?void 0:i.serverParameters)===void 0&&!a.program){this.sendErrorResponse(e,1,"The program must be specified in the launch request arguments");return}yield this.startGDBServer(a)}yield this.startGDBAndAttachToTarget(e,r)})}launchRequest(e,n){return f(this,null,function*(){try{let[r,i]=this.applyRequestArguments("launch",n);yield this.attachOrLaunchRequest(e,r,i)}catch(r){this.sendErrorResponse(e,1,r instanceof Error?r.message:String(r))}})}attachRequest(e,n){return f(this,null,function*(){try{let[r,i]=this.applyRequestArguments("attach",n);yield this.attachOrLaunchRequest(e,r,i)}catch(r){this.sendErrorResponse(e,1,r instanceof Error?r.message:String(r))}})}startGDBServer(e){return f(this,null,function*(){e.target===void 0&&(e.target={});let n=e.target;this.killGdbServer=n.automaticallyKillServer!==!1,yield new Promise((r,i)=>f(this,null,function*(){if(!this.gdbserverProcessManager)throw new Error("GDBServer process manager is not initialised!");this.gdbserver=yield this.gdbserverProcessManager.start(e);let a=!1,o="",d="",c=l=>{};if(n.port&&n.serverParameters?setTimeout(()=>{a=!0,r()},n.serverStartupDelay!==void 0?n.serverStartupDelay:0):c=l=>{let m=new RegExp(n.serverPortRegExp?n.serverPortRegExp:`Listening on port ([0-9]+)\r? | ||
`).exec(l);m!==null&&(n.port=m[1],c=h=>{},setTimeout(()=>{a=!0,r()},n.serverStartupDelay!==void 0?n.serverStartupDelay:0))},this.gdbserver.stdout)this.gdbserver.stdout.on("data",l=>{let u=l.toString();a||(o+=u),this.sendEvent(new w.OutputEvent(u,"server")),c(o)});else throw new Error("Missing stdout in spawned gdbserver");if(this.gdbserver.stderr)this.gdbserver.stderr.on("data",l=>{let u=l.toString();a||(d+=u),this.sendEvent(new w.OutputEvent(u,"server")),c(d)});else throw new Error("Missing stderr in spawned gdbserver");this.gdbserver.on("exit",(l,u)=>{let m;l===null?m=`gdbserver is killed by signal ${u}`:m=`gdbserver has exited with code ${l}`,this.sendEvent(new w.OutputEvent(m,"server")),a||(a=!0,i(new Error(m+` | ||
`+d)))}),this.gdbserver.on("error",l=>{let u=`gdbserver has hit error ${l}`;this.sendEvent(new w.OutputEvent(u,"server")),a||(a=!0,i(new Error(u+` | ||
`+d)))})}))})}startGDBAndAttachToTarget(e,n){return f(this,null,function*(){n.target===void 0&&(n.target={});let r=n.target;try{if(this.isAttach=!0,yield this.spawn(n),yield this.gdb.sendFileExecAndSymbols(n.program),yield this.gdb.sendEnablePrettyPrint(),n.imageAndSymbols&&n.imageAndSymbols.symbolFileName&&(n.imageAndSymbols.symbolOffset?yield this.gdb.sendAddSymbolFile(n.imageAndSymbols.symbolFileName,n.imageAndSymbols.symbolOffset):yield this.gdb.sendFileSymbolFile(n.imageAndSymbols.symbolFileName)),r.connectCommands===void 0){this.targetType=r.type!==void 0?r.type:"remote";let i;r.port!==void 0?i=[r.host!==void 0?`${r.host}:${r.port}`:`localhost:${r.port}`]:i=[];let a=r.parameters!==void 0?r.parameters:i;yield Ae(this.gdb,{type:this.targetType,parameters:a}),this.sendEvent(new w.OutputEvent(`connected to ${this.targetType} target ${a.join(" ")}`))}else yield this.gdb.sendCommands(r.connectCommands),this.sendEvent(new w.OutputEvent("connected to target using provided connectCommands"));yield this.gdb.sendCommands(n.initCommands),n.imageAndSymbols&&n.imageAndSymbols.imageFileName&&(yield this.gdb.sendLoad(n.imageAndSymbols.imageFileName,n.imageAndSymbols.imageOffset)),yield this.gdb.sendCommands(n.preRunCommands),this.sendEvent(new w.InitializedEvent),this.sendResponse(e),this.isInitialized=!0}catch(i){this.sendErrorResponse(e,1,i instanceof Error?i.message:String(i))}})}stopGDBServer(){return f(this,null,function*(){var e;return(e=this.gdbserverProcessManager)==null?void 0:e.stop()})}disconnectRequest(e,n){return f(this,null,function*(){try{this.targetType==="remote"&&(yield this.pauseIfNeeded(!0),yield this.gdb.sendCommand("disconnect")),yield this.gdb.sendGDBExit(),this.killGdbServer&&(yield this.stopGDBServer(),this.sendEvent(new w.OutputEvent("gdbserver stopped","server"))),this.sendResponse(e)}catch(r){this.sendErrorResponse(e,1,r instanceof Error?r.message:String(r))}})}}; | ||
//# sourceMappingURL=web.js.map |
@@ -58,2 +58,3 @@ import * as mi from '../mi'; | ||
protected customRequest(command: string, response: DebugProtocol.Response, args: any): void; | ||
protected getBreakpointModes(): DebugProtocol.BreakpointMode[] | undefined; | ||
protected initializeRequest(response: DebugProtocol.InitializeResponse, args: DebugProtocol.InitializeRequestArguments): void; | ||
@@ -60,0 +61,0 @@ protected setupCommonLoggerAndBackends(args: LaunchRequestArguments | AttachRequestArguments): Promise<void>; |
@@ -32,2 +32,7 @@ #!/usr/bin/env node | ||
const hardwareBreakpointFalse = process.argv.includes('--hardware-breakpoint-false'); | ||
// Breakpoint mode to override | ||
const breakpointModeIndex = process.argv.indexOf('--breakpoint-mode'); | ||
const breakpointMode = breakpointModeIndex < 0 | ||
? undefined | ||
: process.argv[breakpointModeIndex + 1]; | ||
const throwError = process.argv.includes('--throw-error'); | ||
@@ -45,3 +50,4 @@ class DynamicBreakpointOptionsGDBBackend extends GDBBackend_1.GDBBackend { | ||
: initialOptions.hardware; | ||
return Object.assign(Object.assign({}, initialOptions), { hardware }); | ||
const mode = breakpointMode !== null && breakpointMode !== void 0 ? breakpointMode : initialOptions.mode; | ||
return Object.assign(Object.assign({}, initialOptions), { mode, hardware }); | ||
}); | ||
@@ -48,0 +54,0 @@ } |
@@ -37,4 +37,24 @@ /********************************************************************* | ||
} | ||
export type MIBreakpointMode = 'hardware' | 'software'; | ||
export interface MIBreakpointInsertOptions { | ||
temporary?: boolean; | ||
/** | ||
* The `mode` property is prioritised over the `hardware` property. | ||
* If `mode` is defined, then the information in the `hardware` flag | ||
* is ignored during the insert breakpoint operation. | ||
* | ||
* The value of the mode wil be: | ||
* | ||
* - `'hardware'`: If user explicitly selects the breakpoint mode as | ||
* 'Hardware Breakpoint' at the user interface. | ||
* - `'software'`: If user explicitly selects the breakpoint mode as | ||
* 'Software Breakpoint' at the user interface. | ||
* - `undefined`: If user didn't make an explicitly breakpoint mode | ||
* selection, in this case the `hardware` flag will be used. | ||
*/ | ||
mode?: MIBreakpointMode; | ||
/** | ||
* @deprecated The `hardware` property will be removed soon. Please | ||
* use the `mode` property instead of the `hardware`. | ||
*/ | ||
hardware?: boolean; | ||
@@ -41,0 +61,0 @@ pending?: boolean; |
@@ -63,3 +63,7 @@ "use strict"; | ||
const ignore = (options === null || options === void 0 ? void 0 : options.ignoreCount) ? `-i ${options === null || options === void 0 ? void 0 : options.ignoreCount} ` : ''; | ||
const hwBreakpoint = (options === null || options === void 0 ? void 0 : options.hardware) ? '-h ' : ''; | ||
// prefers options.mode information over options.hardware information. | ||
const isHwBreakpoint = (options === null || options === void 0 ? void 0 : options.mode) | ||
? options.mode === 'hardware' | ||
: !!(options === null || options === void 0 ? void 0 : options.hardware); | ||
const hwBreakpoint = isHwBreakpoint ? '-h ' : ''; | ||
const pend = (options === null || options === void 0 ? void 0 : options.pending) ? '-f ' : ''; | ||
@@ -66,0 +70,0 @@ const command = `-break-insert ${temp}${hwBreakpoint}${ignore}${pend}${location}`; |
{ | ||
"name": "cdt-gdb-adapter", | ||
"version": "1.0.4", | ||
"version": "1.0.5", | ||
"description": "gdb adapter implementing the debug adapter protocol", | ||
@@ -84,3 +84,3 @@ "main": "dist/index.js", | ||
"@typescript-eslint/parser": "^5.54.0", | ||
"@vscode/debugadapter-testsupport": "^1.59.0", | ||
"@vscode/debugadapter-testsupport": "^1.68.0", | ||
"browserify": "^17.0.0", | ||
@@ -87,0 +87,0 @@ "chai": "^4.3.7", |
@@ -52,4 +52,27 @@ /********************************************************************* | ||
export type MIBreakpointMode = 'hardware' | 'software'; | ||
export interface MIBreakpointInsertOptions { | ||
temporary?: boolean; | ||
/** | ||
* The `mode` property is prioritised over the `hardware` property. | ||
* If `mode` is defined, then the information in the `hardware` flag | ||
* is ignored during the insert breakpoint operation. | ||
* | ||
* The value of the mode wil be: | ||
* | ||
* - `'hardware'`: If user explicitly selects the breakpoint mode as | ||
* 'Hardware Breakpoint' at the user interface. | ||
* - `'software'`: If user explicitly selects the breakpoint mode as | ||
* 'Software Breakpoint' at the user interface. | ||
* - `undefined`: If user didn't make an explicitly breakpoint mode | ||
* selection, in this case the `hardware` flag will be used. | ||
*/ | ||
mode?: MIBreakpointMode; | ||
/** | ||
* @deprecated The `hardware` property will be removed soon. Please | ||
* use the `mode` property instead of the `hardware`. | ||
*/ | ||
hardware?: boolean; | ||
@@ -132,3 +155,8 @@ pending?: boolean; | ||
const ignore = options?.ignoreCount ? `-i ${options?.ignoreCount} ` : ''; | ||
const hwBreakpoint = options?.hardware ? '-h ' : ''; | ||
// prefers options.mode information over options.hardware information. | ||
const isHwBreakpoint = options?.mode | ||
? options.mode === 'hardware' | ||
: !!options?.hardware; | ||
const hwBreakpoint = isHwBreakpoint ? '-h ' : ''; | ||
const pend = options?.pending ? '-f ' : ''; | ||
@@ -135,0 +163,0 @@ const command = `-break-insert ${temp}${hwBreakpoint}${ignore}${pend}${location}`; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Unidentified License
License(Experimental) Something that seems like a license was found, but its contents could not be matched with a known license.
Found 16 instances in 1 package
Unidentified License
License(Experimental) Something that seems like a license was found, but its contents could not be matched with a known license.
Found 16 instances in 1 package
1297192
285
14146