• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

rokucommunity / roku-debug / #1977

pending completion
#1977

push

TwitchBronBron
Fix issue with truncated debugger paths

999 of 1900 branches covered (52.58%)

Branch coverage included in aggregate %.

2082 of 3571 relevant lines covered (58.3%)

16.0 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

13.04
/src/debugProtocol/responses/ThreadsResponse.ts
1
import * as path from 'path';
1✔
2
import { SmartBuffer } from 'smart-buffer';
1✔
3
import { STOP_REASONS } from '../Constants';
1✔
4
import { util } from '../../util';
1✔
5

6
export class ThreadsResponse {
1✔
7

8
    constructor(buffer: Buffer) {
9
        // The smallest a threads request response can be
10
        if (buffer.byteLength >= 21) {
×
11
            try {
×
12
                let bufferReader = SmartBuffer.fromBuffer(buffer);
×
13
                this.requestId = bufferReader.readUInt32LE();
×
14

15
                // Any request id less then one is an update and we should not process it here
16
                if (this.requestId > 0) {
×
17
                    this.errorCode = bufferReader.readUInt32LE();
×
18
                    this.threadsCount = bufferReader.readUInt32LE();
×
19

20
                    for (let i = 0; i < this.threadsCount; i++) {
×
21
                        let stackEntry = new ThreadInfo(bufferReader);
×
22
                        if (stackEntry.success) {
×
23
                            // All the necessary stack entry data was present. Push to the entries array.
24
                            this.threads.push(stackEntry);
×
25
                        }
26
                    }
27

28
                    this.readOffset = bufferReader.readOffset;
×
29
                    this.success = (this.threads.length === this.threadsCount);
×
30
                }
31
            } catch (error) {
32
                // Could not parse
33
            }
34
        }
35
    }
36
    public success = false;
×
37
    public readOffset = 0;
×
38

39
    // response fields
40
    public requestId = -1;
×
41
    public errorCode = -1;
×
42
    public threadsCount = -1;
×
43
    public threads = [];
×
44
}
45

46
export class ThreadInfo {
1✔
47

48
    constructor(bufferReader: SmartBuffer) {
49
        // NOTE: The docs say the flags should be unit8 and uint32. In testing it seems like they are sending uint32 but meant to send unit8.
50
        // eslint-disable-next-line no-bitwise
51
        this.isPrimary = (bufferReader.readUInt32LE() & 0x01) > 0;
×
52
        this.stopReason = STOP_REASONS[bufferReader.readUInt8()];
×
53
        this.stopReasonDetail = util.readStringNT(bufferReader);
×
54
        this.lineNumber = bufferReader.readUInt32LE();
×
55
        this.functionName = util.readStringNT(bufferReader);
×
56
        this.fileName = util.readStringNT(bufferReader);
×
57
        this.codeSnippet = util.readStringNT(bufferReader);
×
58

59
        let fileExtension = path.extname(this.fileName).toLowerCase();
×
60
        // NOTE: Make sure we have a full valid path (?? can be valid because the device might not know the file) and that we have a codeSnippet.
61
        this.success = (fileExtension === '.brs' || fileExtension === '.xml' || this.fileName === '??') && this.codeSnippet.length > 1;
×
62
    }
63
    public success = false;
×
64

65
    // response fields
66
    public isPrimary: boolean;
67
    public stopReason: string;
68
    public stopReasonDetail: string;
69
    public lineNumber = -1;
×
70
    public functionName: string;
71
    public fileName: string;
72
    public codeSnippet: string;
73
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc