Menu

#127 more debug output on exec fnc

Unstable_(example)
accepted
nobody
None
5
2014-06-19
2014-06-17
franta
No

it is attempt to give more info when dosemu performs INT21 0x4B load/exec - it prints command name and its command line (which proved to be very useful when I was debugging of my black-box DOS program, which attempt to run several others programs - and they sometimes triggered even other programs).

This path is maybe a smut and should be reviewed.

1 Attachments

Discussion

  • franta

    franta - 2014-06-17

    One thing which I not understand are these debug output redefinitions. When pick out ifprint(debug_level(... [un]definitions from src/include/dosemu_debug.h, then got:

    int log_printf(int, const char *,...) FORMAT(printf, 2, 3);
    int vlog_printf(int, const char *,va_list);
    #  define ifprintf(flg,fmt,a...)    do{ if (flg) log_printf(0x10000|__LINE__,fmt,##a); }while(0)
    #  define ifprintf(flg,fmt,a...)    do{ if (flg) log_printf(flg,fmt,##a); }while(0)
    #define dbug_printf(f,a...) ifprintf(10,f,##a)
    #define flush_log()     { if (dbg_fd) log_printf(-1, "\n"); }
    #define b_printf(f,a...)    ifprintf(debug_level('b'),f,##a)
    #define c_printf(f,a...)    ifprintf(debug_level('c'),f,##a)
    #define d_printf(f,a...)    ifprintf(debug_level('d'),f,##a)
    #define e_printf(f,a...)    ifprintf(debug_level('e'),f,##a)
    #define f_printf(f,a...)    ifprintf(debug_level('f'),f,##a)
    #define g_printf(f,a...)    ifprintf(debug_level('g'),f,##a)
    #define h_printf(f,a...)    ifprintf(debug_level('h'),f,##a)
    #define i_printf(f,a...)    ifprintf(debug_level('i'),f,##a)
    #define j_printf(f,a...)    ifprintf(debug_level('j'),f,##a)
    #define k_printf(f,a...)    ifprintf(debug_level('k'),f,##a)
    #define l_printf(f,a...)    ifprintf(debug_level('l'),f,##a)
    #define m_printf(f,a...)    ifprintf(debug_level('m'),f,##a)
    #define n_printf(f,a...)    ifprintf(debug_level('n'),f,##a)
    #define o_printf(f,a...)    ifprintf(debug_level('o'),f,##a)
    #define p_printf(f,a...)    ifprintf(debug_level('p'),f,##a)
    #define q_printf(f,a...)    ifprintf(debug_level('q'),f,##a)
    #define r_printf(f,a...)    ifprintf(debug_level('r'),f,##a)
    #define s_printf(f,a...)    ifprintf(debug_level('s'),f,##a)
    #define t_printf(f,a...)    ifprintf(debug_level('t'),f,##a)
    #define u_printf(f,a...)    ifprintf(debug_level('u'),f,##a)
    #define v_printf(f,a...)    ifprintf(debug_level('v'),f,##a)
    #define w_printf(f,a...)    ifprintf(debug_level('w'),f,##a)
    #define x_printf(f,a...)    ifprintf(debug_level('x'),f,##a)
    #define y_printf(f,a...)    ifprintf(debug_level('y'),f,##a)
    #define z_printf(f,a...)    ifprintf(debug_level('z'),f,##a)
    #define A_printf(f,a...)    ifprintf(debug_level('A'),f,##a)
    #define B_printf(f,a...)    ifprintf(debug_level('B'),f,##a)
    #define C_printf(f,a...)    ifprintf(debug_level('C'),f,##a)
    #define D_printf(f,a...)    ifprintf(debug_level('D'),f,##a)
    #define E_printf(f,a...)    ifprintf(debug_level('E'),f,##a)
    #define F_printf(f,a...)    ifprintf(debug_level('F'),f,##a)
    #define G_printf(f,a...)    ifprintf(debug_level('G'),f,##a)
    #define H_printf(f,a...)    ifprintf(debug_level('H'),f,##a)
    #define I_printf(f,a...)    ifprintf(debug_level('I'),f,##a)
    #define J_printf(f,a...)    ifprintf(debug_level('J'),f,##a)
    #define K_printf(f,a...)    ifprintf(debug_level('K'),f,##a)
    #define L_printf(f,a...)    ifprintf(debug_level('L'),f,##a)
    #define M_printf(f,a...)    ifprintf(debug_level('M'),f,##a)
    #define N_printf(f,a...)    ifprintf(debug_level('N'),f,##a)
    #define O_printf(f,a...)    ifprintf(debug_level('O'),f,##a)
    #define P_printf(f,a...)    ifprintf(debug_level('P'),f,##a)
    #define Q_printf(f,a...)    ifprintf(debug_level('Q'),f,##a)
    #define R_printf(f,a...)    ifprintf(debug_level('R'),f,##a)
    #define S_printf(f,a...)    ifprintf(debug_level('S'),f,##a)
    #define T_printf(f,a...)    ifprintf(debug_level('T'),f,##a)
    #define U_printf(f,a...)    ifprintf(debug_level('U'),f,##a)
    #define V_printf(f,a...)    ifprintf(debug_level('V'),f,##a)
    #define W_printf(f,a...)    ifprintf(debug_level('W'),f,##a)
    #define X_printf(f,a...)    ifprintf(debug_level('X'),f,##a)
    #define Y_printf(f,a...)    ifprintf(debug_level('Y'),f,##a)
    #define Z_printf(f,a...)    ifprintf(debug_level('Z'),f,##a)
    #define di_printf(f,a...)   ifprintf(debug_level('#'),f,##a)
    #undef D_printf
    #undef M_printf
    #undef w_printf
    #undef P_printf
    #define ds_printf(f,a...)   ifprintf(debug_level('D'),f,##a)
    #define D_printf(f,a...)    ifprintf(debug_level('M'),f,##a)
    #define warn(f,a...)    ifprintf(debug_level('w'),f,##a)
    #define pd_printf(f,a...)   ifprintf(debug_level('P'),f,##a)
    

    (reason for those redifinitions?)
    and when I print where certain debug outputs are, then I get this:

    cd src; for i in D M w P ds pd j; do echo -e "\n* '${i}_printf':";\
     grep -rc "\<${i}_printf" *; done|grep -v ':0$'
    
    * 'D_printf':
    arch/linux/async/signal.c:2
    base/dev/misc/timers.c:1
    base/async/int.c:5
    dosext/dpmi/msdos.c:56
    dosext/dpmi/windefs.h:5
    dosext/dpmi/memory.c:29
    dosext/dpmi/dpmi.c:215
    dosext/dpmi/emu-ldt.c:4
    dosext/dpmi/vxd.c:27
    emu-i386/simx86/cpu-emu.c:1
    include/dosemu_debug.h:3
    
    * 'M_printf':
    include/dosemu_debug.h:2
    
    * 'w_printf':
    include/dosemu_debug.h:2
    
    * 'P_printf':
    include/dosemu_debug.h:2
    
    * 'ds_printf':
    base/async/int.c:18
    dosext/mfs/mfs.c:5
    include/dosemu_debug.h:1
    
    * 'pd_printf':
    doc/README/new:1
    doc/README/net:1
    dosext/net/pktnew.c:30
    dosext/net/libpacket.c:5
    include/dosemu_debug.h:1
    plugin/vde/vde.c:4
    
    * 'j_printf':
    base/dev/misc/joystick.c:4
    base/misc/dos2linux.c:5
    include/dosemu_debug.h:1
    plugin/commands/unix.c:10
    

    it seems as e.g. I must enable joystick debug to see debug outputs from base/misc/dos2linux.c and plugin/commands/unix.c - which isn't too clear without reading dosemu sources.

     
  • Stas Sergeev

    Stas Sergeev - 2014-06-17

    it seems as e.g. I must enable joystick debug to see debug outputs from
    base/misc/dos2linux.c and plugin/commands/unix.c - which isn't too clear
    without reading dosemu sources.

    Looks like a bug, patches welcome.

    As for your patch.
    - Why do you think "AL=03h:load overlay hasnot cmdline in EPB"?
    - Please remove unrelated bits, like int28
    - Please use 'git format-patch'

     
  • franta

    franta - 2014-06-19

    Hi Stas, thanks for all Your advices. Revised patch is attached.
    Regarding to cmdline for subfn "AL=03h":load overlay, I take this info from Ralf Browns Interrupt list v61, "INTERRUP.G", INT21 AH=0x4B description:

    Format of EXEC parameter block for AL=00h,01h,04h:
    Offset  Size    Description     (Table 01590)
     00h    WORD    segment of environment to copy for child process (copy caller's environment if 0000h)
     02h    DWORD   pointer to command tail to be copied into child's PSP
    
    Format of EXEC parameter block for AL=03h:
    Offset  Size    Description     (Table 01591)
     00h    WORD    segment at which to load overlay
     02h    WORD    relocation factor to apply to overlay if in .EXE format
    

    From my tests, I found that AX=0x4B03 is called for "DEVICE=progdrivername"
    statements in config.sys, and on EPB offset 2 is anything else than pointer to command line (although "DEVICE=" allows parameters !). It seems as loaded program/driver has another way to obtain their options - but I not know them.
    Perhaps do you?

     
  • Stas Sergeev

    Stas Sergeev - 2014-06-19
    • status: open --> accepted
     
  • Stas Sergeev

    Stas Sergeev - 2014-06-19

    Applied, thanks.

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.