From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: fee84,3de8e6fdafeaf53 X-Google-Attributes: gidfee84,public From: Peter Thompson Subject: Re: A problem with debugger dbx Date: 1996/12/18 Message-ID: <32B8236C.41C6@zk3.dec.com>#1/1 X-Deja-AN: 204783733 references: <01bbe8e7$c25413c0$83c660ca@pcnode.sta.net.cn> content-type: text/plain; charset=us-ascii organization: CTG mime-version: 1.0 newsgroups: comp.unix.osf.osf1 x-mailer: Mozilla 3.0 (X11; I; OSF1 V4.0 alpha) legend@public.sta.net.cn wrote: > (dbx) patch 0x120001350=0x4421e801 > >[main,0x120001350] xor r1, r1, r1 > > (dbx) 0x120001350/10i > >[main,0x120001350] xor r1, r1, r1 > [main,0x120001354] call_pal halt > The problem is that I want to change the instruction > 'lda sp, -352(sp)' > at address 0x120001350 to that instruction ' xor r1, r1, r1' ONLY, > but the next intruction at address 0x120001354 is changed to > 'call_pal halt' unexpectedly. > > Why ? Is this a bug of Digital UNIX 3.2D ? We prefer to think of this as feature (or a consequence). The problem is that there is no clear way of specifying that what you want to change is an instruction, which is 32 bits long. By using the address format to the patch command, dbx expects you to be changing the quadword, or 64bit value at that address. But you've only supplied the (needed) 32 bits, so dbx sign extends for you and it replaces the whole 64 bit area. I know I've answered this exact question internally, so you may have already been informed of this, but there is something you can do. Print out the hex values of both instructions and change the part that you want. So it would look something like: (dbx) li > [main:10, 0x120001310] addq r31, 0x14, r16 [main:10, 0x120001314] ldq r17, -32664(gp) [main:10, 0x120001318] ldq r27, -32456(gp) [main:10, 0x12000131c] jsr r26, (r27), 0x11fffec90 [main:10, 0x120001320] ldah gp, 8192(r26) [main:10, 0x120001324] lda gp, 28080(gp) [main:11, 0x120001328] ldq r27, -32520(gp) [main:11, 0x12000132c] jsr r26, (r27), 0x120007160 [main:11, 0x120001330] ldah gp, 8192(r26) [main:11, 0x120001334] lda gp, 28064(gp) (dbx) 0x120001310/10X 0000000120001310: a63d806843e29410 6b5b765ca77d8138 0000000120001320: 23bd6db027ba2000 6b5b578ca77d80f8 0000000120001330: 23bd6da027ba2000 a03e0028b01e0028 0000000120001340: 261dfffff4200011 a77d811822107f40 0000000120001350: 27ba20006b5b57df 43e0541023bd6d7c (dbx) patch 0x120001310 = 0xa63d80684421e801 [main:10, 0x120001310] xor r1, r1, r1 (dbx) 0x120001310/10i [main:10, 0x120001310] xor r1, r1, r1 [main:10, 0x120001314] ldq r17, -32664(gp) [main:10, 0x120001318] ldq r27, -32456(gp) [main:10, 0x12000131c] jsr r26, (r27), 0x11fffec90 [main:10, 0x120001320] ldah gp, 8192(r26) etc... PeterT