• 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

12.5
/src/debugProtocol/responses/StackTraceResponse.ts
1
import * as path from 'path';
1✔
2
import { SmartBuffer } from 'smart-buffer';
1✔
3
import { util } from '../../util';
1✔
4

5
export class StackTraceResponse {
1✔
6

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

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

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

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

38
    // response fields
39
    public requestId = -1;
×
40
    public errorCode = -1;
×
41
    public stackSize = -1;
×
42
    public entries = [];
×
43
}
44

45
export class StackEntry {
1✔
46

47
    constructor(bufferReader: SmartBuffer) {
48
        this.lineNumber = bufferReader.readUInt32LE();
×
49
        // NOTE: this is documented as being function name then file name but it is being returned by the device backwards.
50
        this.fileName = util.readStringNT(bufferReader);
×
51
        this.functionName = util.readStringNT(bufferReader);
×
52

53
        let fileExtension = path.extname(this.fileName).toLowerCase();
×
54
        // NOTE:Make sure we have a full valid path (?? can be valid because the device might not know the file).
55
        this.success = (fileExtension === '.brs' || fileExtension === '.xml' || this.fileName === '??');
×
56
    }
57
    public success = false;
×
58

59
    // response fields
60
    public lineNumber = -1;
×
61
    public functionName: string;
62
    public fileName: string;
63
}
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