maint: added make-apt.sh to create signed apt repositories
[barry/progweb.git] / src / m_jvmdebug.cc
blobd5058daed14bc0516b01806dada586b8c68f3362
1 ///
2 /// \file m_jvmdebug.cc
3 /// Mode class for the JVMDebug mode
4 ///
6 /*
7 Copyright (C) 2005-2011, Net Direct Inc. (http://www.netdirect.ca/)
8 Copyright (C) 2008-2009, Nicolas VIVIEN
10 This program is free software; you can redistribute it and/or modify
11 it under the terms of the GNU General Public License as published by
12 the Free Software Foundation; either version 2 of the License, or
13 (at your option) any later version.
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
19 See the GNU General Public License in the COPYING file at the
20 root directory of this project for more details.
23 #include "m_jvmdebug.h"
24 #include "data.h"
25 #include "protocol.h"
26 #include "protostructs.h"
27 #include "packet.h"
28 #include "endian.h"
29 #include "error.h"
30 #include "usbwrap.h"
31 #include "controller.h"
32 #include "cod.h"
33 #include <stdexcept>
34 #include <sstream>
35 #include <iomanip>
36 #include <vector>
37 #include <string.h>
38 #include <time.h>
39 #include <stdio.h>
40 #include "ios_state.h"
42 #include "debug.h"
44 using namespace std;
45 using namespace Barry::Protocol;
47 namespace Barry {
49 ///////////////////////////////////////////////////////////////////////////////
50 // JDModulesList class
52 void JVMModulesList::Parse(const Data &entry_packet)
54 uint16_t count = 0;
56 size_t size = entry_packet.GetSize();
58 while (count < size) {
59 uint16_t len = 0;
61 const unsigned char *ptr = (entry_packet.GetData() + count);
62 Protocol::JVMModulesEntry *e = (Protocol::JVMModulesEntry *) ptr;
64 len = SB_JVMMODULES_ENTRY_HEADER_SIZE + be_btohs(e->sizename);
65 if( (count + len) > size )
66 break;
68 JVMModulesEntry entry;
70 entry.Id = be_btohl(e->id);
71 entry.UniqueID = be_btohl(e->uniqueId);
72 (entry.Name).assign((char *) (ptr + SB_JVMMODULES_ENTRY_HEADER_SIZE), be_btohs(e->sizename));
74 push_back(entry);
76 count += len;
81 void JVMModulesList::Dump(std::ostream &os) const
83 ios_format_state state(os);
85 const_iterator i = begin(), e = end();
87 os << " ID " << "|";
88 os << " UniqueID " << "|";
89 os << " Module Name" << endl;
91 os << "------------+";
92 os << "------------+";
93 os << "-------------";
94 os << endl;
96 for( ; i != e; ++i ) {
97 (*i).Dump(os);
102 ///////////////////////////////////////////////////////////////////////////////
103 // JVMModulesEntry class
105 void JVMModulesEntry::Dump(std::ostream &os) const
107 ios_format_state state(os);
109 os << " 0x" << setfill('0') << setw(8) << hex << Id << " |";
110 os << " 0x" << setfill('0') << setw(8) << hex << UniqueID << " |";
111 os << " " << Name << endl;
115 ///////////////////////////////////////////////////////////////////////////////
116 // JVMThreadsList class
118 void JVMThreadsList::Parse(const Data &entry_packet)
120 uint16_t count = 0;
122 size_t size = entry_packet.GetSize();
124 while (count < size) {
125 uint16_t len = 0;
127 const unsigned char *ptr = (entry_packet.GetData() + count);
128 uint32_t *e = (uint32_t *) ptr;
130 len = sizeof(uint32_t);
131 if( (count + len) > size )
132 break;
134 JVMThreadsEntry entry;
136 entry.Id = be_btohl(*e);
138 push_back(entry);
140 count += len;
145 void JVMThreadsList::Dump(std::ostream &os) const
147 ios_format_state state(os);
149 const_iterator i = begin(), e = end();
151 os << " Thread " << "|";
152 os << " Address " << "|";
153 os << " Byte " << "|";
154 os << " Unknown01 " << "|";
155 os << " Unknown02 " << "|";
156 os << " Unknown03 " << "|";
157 os << " Unknown04 " << "|";
158 os << " Unknown05 " << "|";
159 os << " Unknown06 " << "|";
161 os << "------------+";
162 os << "------------+";
163 os << "------+";
164 os << "------------+";
165 os << "------------+";
166 os << "------------+";
167 os << "------------+";
168 os << "------------+";
169 os << "-------------";
170 os << endl;
172 for(int k=0 ; i != e; ++i, k++ ) {
173 (*i).Dump(os, k);
178 void JVMThreadsEntry::Dump(std::ostream &os, int num) const
180 ios_format_state state(os);
182 os << " " << setfill(' ') << setw(8) << dec << num << " |";
183 os << " 0x" << setfill('0') << setw(8) << hex << (Id) << " |";
184 os << " 0x" << setfill('0') << setw(2) << hex << (Byte) << " |";
185 os << " 0x" << setfill('0') << setw(8) << hex << (Address) << " |";
186 os << " 0x" << setfill('0') << setw(8) << hex << (Unknown01) << " |";
187 os << " 0x" << setfill('0') << setw(8) << hex << (Unknown02) << " |";
188 os << " 0x" << setfill('0') << setw(8) << hex << (Unknown03) << " |";
189 os << " 0x" << setfill('0') << setw(8) << hex << (Unknown04) << " |";
190 os << " 0x" << setfill('0') << setw(8) << hex << (Unknown05) << " |";
191 os << " 0x" << setfill('0') << setw(8) << hex << (Unknown06) << endl;
195 namespace Mode {
197 ///////////////////////////////////////////////////////////////////////////////
198 // JVMDebug Mode class
200 JVMDebug::JVMDebug(Controller &con)
201 : Mode(con, Controller::JVMDebug)
202 , m_Attached(false)
206 JVMDebug::~JVMDebug()
208 if( m_Attached )
209 Detach();
212 ///////////////////////////////////////////////////////////////////////////////
213 // protected members
216 ///////////////////////////////////////////////////////////////////////////////
217 // public API
219 void JVMDebug::OnOpen()
223 // FIXME - is this necessary? and if it is, wouldn't it be better
224 // in the m_jvmdebug mode class? I'm not convinced that applications
225 // should have to bother with socket-level details.
226 void JVMDebug::Close()
228 if( m_ModeSocket ) {
229 m_socket->Close();
230 m_socket.reset();
231 m_ModeSocket = 0;
236 // Attach
238 /// These commands are sent to prepare the debug communication.
239 /// Must be called at the start of a JVMDebug session.
241 void JVMDebug::Attach()
246 // Detach
248 /// Must be called at the end of a JVMDebug session. The JVM_GOODBYE
249 /// command is sent to the device.
251 void JVMDebug::Detach()
256 void JVMDebug::ThrowJVMError(const std::string &msg, uint8_t cmd)
258 std::ostringstream oss;
259 oss << msg << ": unexpected packet command code: 0x"
260 << std::hex << (unsigned int) cmd;
261 throw Error(oss.str());
266 // Unknown 01 ???
268 void JVMDebug::Unknown01()
270 uint16_t expect = 0;
272 Data command(-1, 8), response;
273 JVMPacket packet(command, response);
275 // Send the command packet
276 packet.Unknown01();
277 m_socket->Packet(packet);
278 expect = packet.Size();
280 if (expect == 0)
281 return;
283 // Read the data stream
284 m_socket->Receive(response);
286 size_t bytereceived = response.GetSize() - SB_JVMPACKET_HEADER_SIZE;
288 // Check the size read into the previous packet
289 if( expect != bytereceived ) {
290 ThrowJVMError("JVMDebug::Attach expect", expect);
296 // Unknown 02 ???
298 void JVMDebug::Unknown02()
300 uint16_t expect = 0;
302 Data command(-1, 8), response;
303 JVMPacket packet(command, response);
305 // Send the command packet
306 packet.Unknown02();
307 m_socket->Packet(packet);
308 expect = packet.Size();
310 if (expect == 0)
311 return;
313 // Read the data stream
314 m_socket->Receive(response);
316 size_t bytereceived = response.GetSize() - SB_JVMPACKET_HEADER_SIZE;
318 // Check the size read into the previous packet
319 if( expect != bytereceived ) {
320 ThrowJVMError("JVMDebug::Attach expect", expect);
326 // Unknown 03 ???
328 void JVMDebug::Unknown03()
330 uint16_t expect = 0;
332 Data command(-1, 8), response;
333 JVMPacket packet(command, response);
335 // Send the command packet
336 packet.Unknown03();
337 m_socket->Packet(packet);
338 expect = packet.Size();
340 if (expect == 0)
341 return;
343 // Read the data stream
344 m_socket->Receive(response);
346 size_t bytereceived = response.GetSize() - SB_JVMPACKET_HEADER_SIZE;
348 // Check the size read into the previous packet
349 if( expect != bytereceived ) {
350 ThrowJVMError("JVMDebug::Attach expect", expect);
356 // Unknown 04 ???
358 void JVMDebug::Unknown04()
360 uint16_t expect = 0;
362 Data command(-1, 8), response;
363 JVMPacket packet(command, response);
365 // Send the command packet
366 packet.Unknown04();
367 m_socket->Packet(packet);
368 expect = packet.Size();
370 if (expect == 0)
371 return;
373 // Read the data stream
374 m_socket->Receive(response);
376 size_t bytereceived = response.GetSize() - SB_JVMPACKET_HEADER_SIZE;
378 // Check the size read into the previous packet
379 if( expect != bytereceived ) {
380 ThrowJVMError("JVMDebug::Attach expect", expect);
386 // Unknown 05 ???
388 void JVMDebug::Unknown05()
390 uint16_t expect = 0;
392 Data command(-1, 8), response;
393 JVMPacket packet(command, response);
395 // Send the command packet
396 packet.Unknown05();
397 m_socket->Packet(packet);
398 expect = packet.Size();
400 if (expect == 0)
401 return;
403 // Read the data stream
404 m_socket->Receive(response);
406 size_t bytereceived = response.GetSize() - SB_JVMPACKET_HEADER_SIZE;
408 // Check the size read into the previous packet
409 if( expect != bytereceived ) {
410 ThrowJVMError("JVMDebug::Attach expect", expect);
416 // Unknown 06 ???
418 void JVMDebug::Unknown06()
420 uint16_t expect = 0;
422 Data command(-1, 8), response;
423 JVMPacket packet(command, response);
425 // Send the command packet
426 packet.Unknown06();
427 m_socket->Packet(packet);
428 expect = packet.Size();
430 if (expect == 0)
431 return;
433 // Read the data stream
434 m_socket->Receive(response);
436 size_t bytereceived = response.GetSize() - SB_JVMPACKET_HEADER_SIZE;
438 // Check the size read into the previous packet
439 if( expect != bytereceived ) {
440 ThrowJVMError("JVMDebug::Attach expect", expect);
446 // Unknown 07 ???
448 void JVMDebug::Unknown07()
450 uint16_t expect = 0;
452 Data command(-1, 8), response;
453 JVMPacket packet(command, response);
455 // Send the command packet
456 packet.Unknown07();
457 m_socket->Packet(packet);
458 expect = packet.Size();
460 if (expect == 0)
461 return;
463 // Read the data stream
464 m_socket->Receive(response);
466 size_t bytereceived = response.GetSize() - SB_JVMPACKET_HEADER_SIZE;
468 // Check the size read into the previous packet
469 if( expect != bytereceived ) {
470 ThrowJVMError("JVMDebug::Attach expect", expect);
476 // Unknown 08 ???
478 void JVMDebug::Unknown08()
480 uint16_t expect = 0;
482 Data command(-1, 8), response;
483 JVMPacket packet(command, response);
485 // Send the command packet
486 packet.Unknown08();
487 m_socket->Packet(packet);
488 expect = packet.Size();
490 if (expect == 0)
491 return;
493 // Read the data stream
494 m_socket->Receive(response);
496 size_t bytereceived = response.GetSize() - SB_JVMPACKET_HEADER_SIZE;
498 // Check the size read into the previous packet
499 if( expect != bytereceived ) {
500 ThrowJVMError("JVMDebug::Attach expect", expect);
506 // Unknown 09 ???
508 void JVMDebug::Unknown09()
510 uint16_t expect = 0;
512 Data command(-1, 8), response;
513 JVMPacket packet(command, response);
515 // Send the command packet
516 packet.Unknown09();
517 m_socket->Packet(packet);
518 expect = packet.Size();
520 if (expect == 0)
521 return;
523 // Read the data stream
524 m_socket->Receive(response);
526 size_t bytereceived = response.GetSize() - SB_JVMPACKET_HEADER_SIZE;
528 // Check the size read into the previous packet
529 if( expect != bytereceived ) {
530 ThrowJVMError("JVMDebug::Attach expect", expect);
536 // Unknown 10 ???
538 void JVMDebug::Unknown10()
540 uint16_t expect = 0;
542 Data command(-1, 8), response;
543 JVMPacket packet(command, response);
545 // Send the command packet
546 packet.Unknown10();
547 m_socket->Packet(packet);
548 expect = packet.Size();
550 if (expect == 0)
551 return;
553 // Read the data stream
554 m_socket->Receive(response);
556 size_t bytereceived = response.GetSize() - SB_JVMPACKET_HEADER_SIZE;
558 // Check the size read into the previous packet
559 if( expect != bytereceived ) {
560 ThrowJVMError("JVMDebug::Attach expect", expect);
566 // Get Status
568 bool JVMDebug::GetStatus(int &status)
570 uint16_t expect = 0;
572 Data command(-1, 8), response;
573 JVMPacket packet(command, response);
575 // Send the command packet
576 packet.GetStatus();
578 m_socket->Packet(packet);
580 expect = packet.Size();
582 if (expect == 0)
583 return false;
585 // Read the data stream
586 m_socket->Receive(response);
588 MAKE_JVMPACKET(dpack, response);
590 size_t bytereceived = response.GetSize() - SB_JVMPACKET_HEADER_SIZE;
592 // Check the size read into the previous packet
593 if( expect != bytereceived ) {
594 ThrowJVMError("JVMDebug::GetModulesList expect", expect);
597 // Make sure we have a header to read
598 CheckSize(response, SB_JVMPACKET_HEADER_SIZE + sizeof(dpack->u.status));
600 // Return status
601 status = dpack->u.status;
603 return true;
608 // Wait Status
610 bool JVMDebug::WaitStatus(int &status)
612 uint16_t expect = 0;
614 Data command(-1, 8), response;
615 JVMPacket packet(command, response);
617 // Prepare the command packet
618 packet.GetStatus();
620 try {
621 m_socket->Receive(packet.GetReceive(), 100);
622 } catch (Usb::Timeout &to ) {
623 return false;
626 expect = packet.Size();
628 if (expect == 0)
629 return false;
631 // Read the data stream
632 m_socket->Receive(response);
634 MAKE_JVMPACKET(dpack, response);
636 size_t bytereceived = response.GetSize() - SB_JVMPACKET_HEADER_SIZE;
638 // Check the size read into the previous packet
639 if( expect != bytereceived ) {
640 ThrowJVMError("JVMDebug::GetModulesList expect", expect);
643 // Make sure we have a header to read
644 CheckSize(response, SB_JVMPACKET_HEADER_SIZE + sizeof(dpack->u.status));
646 // Return status
647 status = dpack->u.status;
649 return true;
654 // Get Console Message
655 // Sample, display the output of System.out.println(...) and all JVM messages output
657 // Return the length message or -1 if message doesn't exit or is empty
659 int JVMDebug::GetConsoleMessage(std::string &message)
661 uint16_t expect = 0;
663 Data command(-1, 8), response;
664 JVMPacket packet(command, response);
666 // Send the command packet
667 packet.GetConsoleMessage();
669 m_socket->Packet(packet);
671 expect = packet.Size();
673 if (expect == 0)
674 return -1;
676 // Read the data stream
677 m_socket->Receive(response);
679 MAKE_JVMPACKET(dpack, response);
681 size_t bytereceived = response.GetSize() - SB_JVMPACKET_HEADER_SIZE;
683 // Check the size read into the previous packet
684 if( expect != bytereceived ) {
685 ThrowJVMError("JVMDebug::GetModulesList expect", expect);
688 // Make sure we have a header to read
689 CheckSize(response, SB_JVMPACKET_HEADER_SIZE + sizeof(dpack->u.msglength));
691 // Length of message
692 uint16_t length = be_btohs(dpack->u.msglength);
694 if (length == 0)
695 return -1;
697 CheckSize(response, SB_JVMPACKET_HEADER_SIZE + sizeof(dpack->u.msglength) + length);
699 // Parse the ID of nextmodules
700 const unsigned char *ptr = (response.GetData() + SB_JVMPACKET_HEADER_SIZE + sizeof(dpack->u.msglength));
702 message.assign((char *) ptr, length);
704 return length;
709 // Get list of Java modules
711 void JVMDebug::GetModulesList(JVMModulesList &mylist)
713 uint32_t size = 0;
714 uint32_t count = 0;
715 uint32_t offset = 0;
716 uint16_t expect = 0;
718 Data command(-1, 8), response;
719 JVMPacket packet(command, response);
721 do {
722 // Send the command packet
723 packet.GetModulesList(offset);
725 m_socket->Packet(packet);
727 expect = packet.Size();
729 if (expect == 0)
730 break;
732 // Read the data stream
733 m_socket->Receive(response);
735 MAKE_JVMPACKET(dpack, response);
737 size_t bytereceived = response.GetSize() - SB_JVMPACKET_HEADER_SIZE;
739 // Check the size read into the previous packet
740 if( expect != bytereceived ) {
741 ThrowJVMError("JVMDebug::GetModulesList expect", expect);
744 // Make sure there's enough for packet header + module list
745 // header + 4 bytes of ID
746 CheckSize(response, SB_JVMPACKET_HEADER_SIZE + SB_JVMMODULES_LIST_HEADER_SIZE + 4);
748 // Number of modules entries in the list
749 count = be_btohl(dpack->u.moduleslist.nbr);
751 // Size of modules list
752 // I remove the header of packet (contains the field 'number of modules')
753 // and 4 bytes (contains the field 'ID of next modules')
754 size = bytereceived - SB_JVMMODULES_LIST_HEADER_SIZE - 4;
756 // Parse the modules list
757 mylist.Parse(Data(response.GetData() + SB_JVMPACKET_HEADER_SIZE + SB_JVMMODULES_LIST_HEADER_SIZE, size));
759 // Parse the ID of nextmodules
760 size_t id_offset = SB_JVMPACKET_HEADER_SIZE + SB_JVMMODULES_LIST_HEADER_SIZE + size;
761 const unsigned char *ptr = (response.GetData() + id_offset);
762 CheckSize(response, id_offset + sizeof(uint32_t));
763 uint32_t *poffset = (uint32_t *) ptr;
765 offset = be_btohl(*poffset);
766 } while (offset != 0); // When the offset != 0, there is some modules
771 // Get list of Java threads
773 void JVMDebug::GetThreadsList(JVMThreadsList &mylist)
775 uint32_t size = 0;
776 uint32_t count = 0;
777 uint16_t expect = 0;
779 Data command(-1, 8), response;
780 JVMPacket packet(command, response);
782 // Send the command packet
783 packet.GetThreadsList();
785 m_socket->Packet(packet);
787 expect = packet.Size();
789 if (expect == 0)
790 return;
792 // Read the data stream
793 m_socket->Receive(response);
795 MAKE_JVMPACKET(dpack, response);
797 size_t bytereceived = response.GetSize() - SB_JVMPACKET_HEADER_SIZE;
799 // Check the size read into the previous packet
800 if( expect != bytereceived ) {
801 ThrowJVMError("JVMDebug::GetThreadsList expect", expect);
804 CheckSize(response, SB_JVMPACKET_HEADER_SIZE + SB_JVMTHREADS_LIST_HEADER_SIZE);
806 // Number of threads entries in the list
807 count = be_btohl(dpack->u.threadslist.nbr);
809 // Size of threads list
810 // I remove the header of packet (contains the field 'number of threads')
811 size = bytereceived - SB_JVMTHREADS_LIST_HEADER_SIZE;
813 // Parse the threads list
814 mylist.Parse(Data(response.GetData() + SB_JVMPACKET_HEADER_SIZE + SB_JVMTHREADS_LIST_HEADER_SIZE, size));
816 // Complete threads list
817 JVMThreadsList::iterator b = mylist.begin();
818 for( ; b != mylist.end(); b++ ) {
819 JVMThreadsEntry entry = (*b);
821 // 1°/
822 // Send the command packet
823 packet.Unknown11(entry.Id);
825 m_socket->Packet(packet);
827 expect = packet.Size();
829 if (expect == 0)
830 return;
832 // Read the data stream
833 m_socket->Receive(response);
835 MAKE_JVMPACKET(dpack, response);
837 bytereceived = response.GetSize() - SB_JVMPACKET_HEADER_SIZE;
839 // Check the size read into the previous packet
840 if( expect != bytereceived ) {
841 ThrowJVMError("JVMDebug::GetThreadsList (1) expect", expect);
844 CheckSize(response, SB_JVMPACKET_HEADER_SIZE + SB_JVMUNKNOWN01_HEADER_SIZE);
846 // Save values
847 entry.Byte = dpack->u.unknown01.byte;
848 entry.Address = be_btohl(dpack->u.unknown01.address);
850 // 2°/
851 if (entry.Address != 0) {
852 // Send the command packet
853 packet.Unknown12(entry.Address);
855 m_socket->Packet(packet);
857 expect = packet.Size();
859 if (expect == 0)
860 return;
862 // Read the data stream
863 m_socket->Receive(response);
865 MAKE_JVMPACKET(dpack, response);
867 bytereceived = response.GetSize() - SB_JVMPACKET_HEADER_SIZE;
869 // Check the size read into the previous packet
870 if( expect != bytereceived ) {
871 ThrowJVMError("JVMDebug::GetThreadsList (2) expect", expect);
875 // Save values
876 CheckSize(response, SB_JVMPACKET_HEADER_SIZE + sizeof(dpack->u.address));
877 entry.Unknown01 = be_btohl(dpack->u.address);
879 else
880 entry.Unknown01 = 0;
882 // 3°/
883 // Send the command packet
884 packet.Unknown13(entry.Id);
886 m_socket->Packet(packet);
888 expect = packet.Size();
890 if (expect == 0)
891 return;
893 // Read the data stream
894 m_socket->Receive(response);
896 dpack = (const Protocol::JVMPacket *) response.GetData();
898 bytereceived = response.GetSize() - SB_JVMPACKET_HEADER_SIZE;
900 // Check the size read into the previous packet
901 if( expect != bytereceived ) {
902 ThrowJVMError("JVMDebug::GetThreadsList (2) expect", expect);
905 // Save values
906 CheckSize(response, SB_JVMPACKET_HEADER_SIZE + sizeof(dpack->u.address));
907 entry.Unknown02 = be_btohl(dpack->u.address);
909 // 4°/
910 // Send the command packet
911 packet.Unknown14(entry.Id);
913 m_socket->Packet(packet);
915 expect = packet.Size();
917 if (expect == 0)
918 return;
920 // Read the data stream
921 m_socket->Receive(response);
923 dpack = (const Protocol::JVMPacket *) response.GetData();
925 bytereceived = response.GetSize() - SB_JVMPACKET_HEADER_SIZE;
927 // Check the size read into the previous packet
928 if( expect != bytereceived ) {
929 ThrowJVMError("JVMDebug::GetThreadsList (2) expect", expect);
932 // Save values
933 CheckSize(response, SB_JVMPACKET_HEADER_SIZE + SB_JVMUNKNOWN02_HEADER_SIZE);
934 entry.Unknown03 = be_btohl(dpack->u.unknown02.address1);
935 entry.Unknown04 = be_btohl(dpack->u.unknown02.address2);
937 // 5°/
938 // Send the command packet
939 packet.Unknown15(entry.Id);
941 m_socket->Packet(packet);
943 expect = packet.Size();
945 if (expect == 0)
946 return;
948 // Read the data stream
949 m_socket->Receive(response);
951 dpack = (const Protocol::JVMPacket *) response.GetData();
953 bytereceived = response.GetSize() - SB_JVMPACKET_HEADER_SIZE;
955 // Check the size read into the previous packet
956 if( expect != bytereceived ) {
957 ThrowJVMError("JVMDebug::GetThreadsList (2) expect", expect);
960 // Save values
961 CheckSize(response, SB_JVMPACKET_HEADER_SIZE + SB_JVMUNKNOWN02_HEADER_SIZE);
962 entry.Unknown05 = be_btohl(dpack->u.unknown02.address1);
963 entry.Unknown06 = be_btohl(dpack->u.unknown02.address2);
965 // Save...
966 (*b) = entry;
972 // Go
974 void JVMDebug::Go()
976 uint16_t expect = 0;
978 Data command(-1, 8), response;
979 JVMPacket packet(command, response);
981 // Send the command packet
982 packet.Go();
983 m_socket->Packet(packet);
984 expect = packet.Size();
986 while (expect == 0) {
987 m_socket->Receive(packet.GetReceive());
989 expect = packet.Size();
992 // Read the data stream
993 m_socket->Receive(response);
995 size_t bytereceived = response.GetSize() - SB_JVMPACKET_HEADER_SIZE;
997 // Check the size read into the previous packet
998 if( expect != bytereceived ) {
999 ThrowJVMError("JVMDebug::Attach expect", expect);
1005 // Stop
1007 void JVMDebug::Stop()
1009 uint16_t expect = 0;
1011 Data command(-1, 8), response;
1012 JVMPacket packet(command, response);
1014 // Send the command packet
1015 packet.Stop();
1016 m_socket->Packet(packet);
1017 expect = packet.Size();
1019 while (expect == 0) {
1020 m_socket->Receive(packet.GetReceive());
1022 expect = packet.Size();
1025 // Read the data stream
1026 m_socket->Receive(response);
1028 size_t bytereceived = response.GetSize() - SB_JVMPACKET_HEADER_SIZE;
1030 // Check the size read into the previous packet
1031 if( expect != bytereceived ) {
1032 ThrowJVMError("JVMDebug::Attach expect", expect);
1037 }} // namespace Barry::Mode