User Tools

Site Tools


blog:pushbx:2023:1204_november_december_work_on_ldebug_lmacros_traclist

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

blog:pushbx:2023:1204_november_december_work_on_ldebug_lmacros_traclist [2023-12-04 20:45:35 +0100 Dec Mon] (current)
ecm created
Line 1: Line 1:
 +====== November December work on lDebug, lmacros, TracList ======
  
 +**2023-12-03**
 +
 +This week I worked on several projects related to lDebug and its Extensions for lDebug.
 +
 +
 +===== lmacros =====
 +
 +[[https://hg.pushbx.org/ecm/lmacros/rev/54a8c35131aa|The patch to lmacros enables the reloc-abs-byte warning]] and marks it as an error. This catches byte relocations such as ''int label'' or ''db label'' in the new NASM version 2.16.02.
 +
 +<code> ; These warnings were added in NASM 2.16.02. They are
 + ;  useful, as here, to detect undesired relocations.
 + ; Refer to the report that added these warnings [1]
 + ;  and the report desiring an "int label" warning [2].</code>
 +
 +  - https://bugzilla.nasm.us/show_bug.cgi?id=3392571
 +  - https://bugzilla.nasm.us/show_bug.cgi?id=3392678
 +
 +
 +===== TracList =====
 +
 +The communication between the tractest scanner and the TracList perl script [[https://hg.pushbx.org/ecm/tractest/rev/0e59dff2022b|gained a new file, the hint file]]. The tractest program now expects the hint file name in the third argument passed to it. Conversely, traclist.pl accepts a new switch called ''-%%%%-hint'' or will use the default hint file name of ''/tmp/trace.hin''.
 +
 +The purpose of the hint file is to store the most recent ELD offset hints detected by tractest. That means when traclist.pl is restarted, it can reread the hint file so that it gets the correct offsets even when the line file no longer contains a hint. (The hint file is never truncated by the tractest program, but it can be truncated manually if need be.)
 +
 +This addition supports the common use case in which TracList has lost track of the current tracing and won't find it again using the R command. Instead, it must be restarted. With the hint file, it will be able to reread the hints when being started again.
 +
 +
 +===== lDebug =====
 +
 +==== extpak.eld ====
 +
 +The extpak ELD [[https://hg.pushbx.org/ecm/ldebug/rev/53c1c5481a12|gained a new mode]], when invoked as ''ext extpak.eld test''. This is only included if a build option is enabled. It [[https://hg.pushbx.org/ecm/ldebug/rev/245044c21c44|tests some operations]] of [[https://hg.pushbx.org/ecm/ldebug/rev/8dc761128bee|decompressing part of the compressed library image]].
 +
 +[[https://hg.pushbx.org/ecm/ldebug/rev/359813b393ac|An error that turned up during this]] was that the depacked data included a stray byte with the value 0FFh. This was the ''partialdepack'' variable accidentally included in the to-be-packed library image.
 +
 +The same variable was also included in the uncompressed extlib.eld even though it was never read. This [[https://hg.pushbx.org/ecm/ldebug/rev/dbc73423234e|has been corrected]].
 +
 +
 +==== Documentation ====
 +
 +The manual [[https://hg.pushbx.org/ecm/ldebug/rev/eb6275193a7b|now lists heatshrink]] as being used to pack the extpak.eld library image.
 +
 +
 +==== dosdir.eld / bootdir.eld ====
 +
 +The new sort modifier keywords [[https://hg.pushbx.org/ecm/ldebug/rev/16ca326d193c|are listed in the online help page]] now.
 +
 +
 +==== quit.eld ====
 +
 +This ELD is [[https://hg.pushbx.org/ecm/ldebug/rev/2ffe8421f8d9|a port of the small quit tool]] which was already available as the BOOT QUIT command. The ELD is also available in the DOS loaded modes however. [[https://hg.pushbx.org/ecm/ldebug/rev/80aac73b4899|A subsequent revision changed the ELD]] so that it can operate in Protected Mode as well. Like many ELDs, the quit ELD can be installed residently as well.
 +
 +
 +==== depack.asm ====
 +
 +=== Depacker bug ===
 +
 +The depacker [[https://hg.pushbx.org/ecm/ldebug/rev/eb790065e654|had a bug fixed]]: The match source could start near the end of the circular buffer, but overlap the match destination and thus the source could cross the ending boundary of the circular buffer. If the destination started just past the boundary (ie, at the start of the circular buffer) the copy would overflow the source buffer.
 +
 +This is now fixed by jumping to a new label, ''.start_maybe_part'', which includes the check for a source that overlaps the boundary. The bx register is used to hold a special flag to indicate a literal, so that the part check is never run for literals.
 +
 +
 +=== Depacker stand alone test program ===
 +
 +This test program [[https://hg.pushbx.org/ecm/ldebug/rev/4edf06a652d9|gained some protocol comments]] for its file access functions.
 +
 +Further, the test program [[https://hg.pushbx.org/ecm/ldebug/rev/ad56558de3cb|gained a file write buffer to speed up the writing to a file]]. It is filled byte by byte until full, at which point it is dumped. After the depack function returns, any trailing contents of the file output buffer are dumped as well, if any.
 +
 +On a large test case like the extpak compressed library image, the performance improvement is easily noticeable.
 +
 +
 +=== Common depack infrastructure ===
 +
 +The functions read_and_depack, get_file_byte, and put_file_data from extlib.asm [[https://hg.pushbx.org/ecm/ldebug/rev/a6f9b058a3e4|were moved into depack.asm]] as it turned out that both non-standalone users of depack.asm needed these exact functions.
 +
 +
 +=== eldstrict mode ===
 +
 +For use in list.eld, the depack.asm non-standalone functions [[https://hg.pushbx.org/ecm/ldebug/rev/31c669da61d6|were marked with the reloc mmacros for eldstrict mode]]. This affected only the support functions moved from extlib.asm as listed in the prior section. The depack function itself does not generate any relocations, as it only uses pointers passed in registers or local variables in the lframe.
 +
 +
 +==== extpak.eld error handling ====
 +
 +File read errors during the get_file_byte function [[https://hg.pushbx.org/ecm/ldebug/rev/d597228736c6|are now passed back to the depack-internal caller]] rather than branching to ''error''. This allows the caller of depack to detect an I/O error in such cases.
 +
 +To test this change, I truncated the extpak.eld file then attempted to run the last contained ELD, x.eld.
 +
 +[[https://hg.pushbx.org/ecm/ldebug/rev/4119faf8bdf3|A related bugfix]] was that when the depack function returned, ''read_and_depack'' would override the returned Carry Flag to always be NC. The instruction that did this was an ''or'' to reset the depack_saved_sp variable. The solution was to replace the instruction by a ''mov'', which is 1 byte longer but preserves the flags.
 +
 +
 +==== dosseek.eld ====
 +
 +This ELD does something new: It [[https://hg.pushbx.org/ecm/ldebug/file/390d366242c3/source/eld/dosseek.asm#l94|steals a process file handle from the debuggee process]] to DUP it into a debugger process handle. Then it operates on the DUPed handle.
 +
 +The purpose of this ELD is to display or modify the current (32-bit) seek value of the handle that is being stolen. This would have come in handy during debugging of the extpak.eld.
 +
 +Something else this ELD does is to accept a ''VAR index'' trailer to its GET command. This allows to read the seek value into one of the 256 V variables.
 +
 +
 +==== amitsrs.eld check for valid int 2Dh handler ====
 +
 +This ELD [[https://hg.pushbx.org/ecm/ldebug/rev/4859c8325198|will now check for a valid interrupt 2Dh handler]] in its run function before calling the handler.
 +
 +
 +==== alias.eld ====
 +
 +This ELD allows to create simple aliases. Aliases are detected in a command preprocess handler and replaced by their expansions. The idea for this ELD was contributed by a user.
 +
 +
 +==== extlib.eld allow trailing name extension ====
 +
 +The extlib and extpak ELDs now [[https://hg.pushbx.org/ecm/ldebug/rev/00d71ba16823|allow to specify an ELD name with a cap-insensitive trailing ".ELD" or ".XLD" filename extension]]. That means inserting or removing just the filename of the library ELD is sufficient to convert a stand alone ELD load to a library ELD load or vice versa.
 +
 +
 +==== extpak.eld library table format 2 ====
 +
 +The third format of the library table, format 2, [[https://hg.pushbx.org/ecm/ldebug/rev/79bdba87e80d|was added to aid the use]] by the list ELD. In this format, [[https://hg.pushbx.org/ecm/ldebug/rev/31f31570d83b|the table has a trailing dword]] not present in format 0 or format 1 tables. This dword contains the length of the compressed library image.
 +
 +As a side effect, extpak.eld now reads this table field rather than hardcoding the value in mov immediate instructions. As the new field is also overwritten by the ''zerooffsets'' function, that means a default build of extpak.eld will not turn up any mismatches when their help command is run using eldcomp.
 +
 +
 +==== list.eld support for extpak.eld ====
 +
 +The list.eld [[https://hg.pushbx.org/ecm/ldebug/rev/7c55cd9860c4|can now read packed library ELDs]]. This was achieved by adding most of the depack-related code from extlib.asm to list.asm. There is a build option that can be used to disable the compression support.
 +
 +Nested library ELDs are still supported, but only the innermost library may be compressed. This is so because a library ELD within a compressed library would not be able to read its data from the file, as it does not know its data is compressed. On the list.eld side, an uncompressed library within a compressed library would be easy to support, but a compressed library within another compressed library would require decompressing twice.
 +
 +The ''read_and_depack'' function is used by list.eld by calling ''read_compressed_or_dos_or_boot_io'', which must be called with ah = 3Fh and will test the "uncompressed" flag of the ''commonhandle'' function's stack lframe. If the current ELD is not in a compressed library, it will instead branch to ''dos_or_boot_io''.
 +
 +The set up of the ''depackskip'' variable is done using two functions: ''seek_compressed_or_dos_or_boot_io'' must be called with ax = 4200h or ax = 4201h. Like the read function, if not reading from a compressed library then the call is chained to ''dos_or_boot_io''.
 +
 +The second function is ''seek_compressed_continue_read'' which is newly required in list.eld because it may repeatedly read from the same chunk of the compressed ELD without seeking in between. This function resets ''depackskip'' to the current ''depackseek'', allowing the next ''read_and_depack'' call to continue reading exactly after the point the prior read ended. I am still considering whether to change this interface to something easier to use.
 +
 +
 +==== ELD loader changes ====
 +
 +The first change is [[https://hg.pushbx.org/ecm/ldebug/rev/aa73de89254c|to reserve only the image length]] for library ELDs loading subsequent ELDs. This is an optimisation that reduces the memory needed by the library ELD. The check for the final allocation size was amended by adding in the size used by the current library ELD instance itself.
 +
 +The second change is [[https://hg.pushbx.org/ecm/ldebug/rev/3d279e6d3c7f|a bugfix to the first]]: The relocator field of the data image length was initialised later to equal the data image length from the ELD header. However, at this point the di register was already overwritten. The fix involves reading the data image length earlier.
 +
 +
 +==== extlib.asm build option for zeroing offsets ====
 +
 +[[https://hg.pushbx.org/ecm/ldebug/rev/682d32424c62|This build option]] allows to exclude the code to zero library table offsets for use with eldcomp. This is purely an optimisation.
 +
 +
 +==== linkinfo bug ====
 +
 +The functions for testing a segment for being 32-bits [[https://hg.pushbx.org/ecm/ldebug/rev/d9f39c10b2c5|were accidentally listed in the expr.asm code section]] of the linkinfo.asm file. This blew up during building the dual code debugger with the expr.asm code in the second code section.
 +
 +
 +==== ELD data area growing ====
 +
 +The ELD data area [[https://hg.pushbx.org/ecm/ldebug/rev/e4098c13e997|moved to the end of the data/entry/stack segment]]. This allows a relatively painless growing of this area during the debugger init (only in DOS loaded modes so far). The /Y switch is provided for this.
 +
 +Initially, the maximum size was specified in a build option. However, in a subsequent changeset [[https://hg.pushbx.org/ecm/ldebug/rev/cfb1e604d1a1|I changed this so the maximum size is always calculated from the maximum allowable size of the segment]], so as to fill it to 0FFF0h bytes (65_520 bytes). For the dual code, symbolic, immasm build of the debugger, the resulting maximum size of the data area is about 20 KiB, whereas for the lCDebugX build without dual code, symbolic, or immasm options, the maximum size is about 26 KiB.
 +
 +The relocation was fairly easy to copy from the /T switch relocation, just stripping out the few final relocations of the entry segment itself. It was more difficult to adapt the second init relocation need detection. This used to work with only two variable-sized areas, of which the auxiliary buffer could only ever change with a positive delta (grow or stay the init size). But both the ELD data area and the ELD code section can either grow, or shrink. The solution was to read the paragraphs to change values into 32-bit variables, so at the end of adding up the three areas we can tell reliably if the final value is less-than-or-equal zero (needing no relocation in any case) or not.
 +
 +
 +==== ldmem.eld: Display ELD instance names of free instances ====
 +
 +Finally, the ldmem ELD's ELD listing [[https://hg.pushbx.org/ecm/ldebug/rev/74d318a7fc1e|was changed to also display the name for ELD instances marked as free]]. The name is displayed behind the usual area display. This includes the ldmem.eld's own allocation when run in oneshot mode. It also includes when uninstalling an ELD has resulted in memory fragmentation.
 +
 +{{tag>ldebug eld heatshrink traclist lmacros}}
 +
 +
 +~~DISCUSSION~~
blog/pushbx/2023/1204_november_december_work_on_ldebug_lmacros_traclist.txt ยท Last modified: 2023-12-04 20:45:35 +0100 Dec Mon by ecm